-
Notifications
You must be signed in to change notification settings - Fork 521
Pr3265 #3266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pr3265 #3266
Changes from all commits
8e3432f
5aa6573
57f3700
7aa5371
8b20b79
ae142c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -610,7 +610,12 @@ | |
| product_rev[0] = 0; | ||
| } | ||
|
|
||
|
|
||
| extern "C" bool tud_network_recv_cb(const uint8_t *src, uint16_t size) __attribute__((weak)); | ||
| extern "C" bool tud_network_recv_cb(const uint8_t *src, uint16_t size) { | ||
| (void) src; | ||
| (void) size; | ||
Check warningCode scanning / CodeQL Expression has no effect Warning
This expression has no effect.
Copilot AutofixAI 3 days ago Copilot could not generate an autofix suggestion Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support. |
||
| return false; | ||
| } | ||
|
|
||
| #ifdef ENABLE_PICOTOOL_USB | ||
| // Support for Microsoft OS 2.0 descriptor | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| // Dummy shim to be overridden by lwip_usb_ncm | ||
| #include <Arduino.h> | ||
| #include "tusb_option.h" | ||
|
|
||
| #if (CFG_TUD_ENABLED && CFG_TUD_NCM) | ||
|
|
||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdio.h> | ||
|
|
||
| #include "device/usbd.h" | ||
| #include "device/usbd_pvt.h" | ||
|
|
||
| #include "../../../pico-sdk/lib/tinyusb/src/class/net/ncm.h" | ||
| #include "../../../pico-sdk/lib/tinyusb/src/class/net/net_device.h" | ||
|
|
||
|
|
||
| extern bool tud_network_can_xmit(uint16_t size) __attribute((weak)); | ||
| bool tud_network_can_xmit(uint16_t size) { | ||
| (void) size; | ||
| return false; | ||
| } | ||
|
|
||
| extern void tud_network_xmit(void *ref, uint16_t arg) __attribute((weak)); | ||
| void tud_network_xmit(void *ref, uint16_t arg) { | ||
| (void) ref; | ||
| (void) arg; | ||
| return; | ||
| } | ||
|
|
||
| extern void tud_network_recv_renew(void) __attribute((weak)); | ||
| void tud_network_recv_renew(void) { | ||
| } | ||
|
|
||
| extern void netd_init(void) __attribute((weak)); | ||
| void netd_init(void) { | ||
| } | ||
|
|
||
| extern bool netd_deinit(void) __attribute((weak)); | ||
| bool netd_deinit(void) { | ||
| return true; | ||
| } | ||
|
|
||
| extern void netd_reset(uint8_t rhport) __attribute((weak)); | ||
| void netd_reset(uint8_t rhport) { | ||
| (void) rhport; | ||
| } | ||
|
|
||
| extern uint16_t netd_open(uint8_t rhport, tusb_desc_interface_t const *itf_desc, uint16_t max_len) __attribute((weak)); | ||
| uint16_t netd_open(uint8_t rhport, tusb_desc_interface_t const *itf_desc, uint16_t max_len) { | ||
| (void) rhport; | ||
| (void) itf_desc; | ||
| (void) max_len; | ||
| return 0; | ||
| } | ||
|
|
||
| extern bool netd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes) __attribute((weak)); | ||
| bool netd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes) { | ||
| (void) rhport; | ||
| (void) ep_addr; | ||
| (void) result; | ||
| (void) xferred_bytes; | ||
| return false; | ||
| } | ||
|
|
||
| extern bool netd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const *request) __attribute((weak)); | ||
| bool netd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const *request) { | ||
| (void) rhport; | ||
| (void) stage; | ||
| (void) request; | ||
| return false; | ||
| } | ||
|
|
||
| #endif // ( CFG_TUD_ENABLED && CFG_TUD_NCM ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| **/.pio/ | ||
| **/.vscode/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| .pio | ||
| .vscode/.browse.c_cpp.db* | ||
| .vscode/c_cpp_properties.json | ||
| .vscode/launch.json | ||
| .vscode/ipch | ||
| */README | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| ; PlatformIO Project Configuration File | ||
| ; | ||
| ; Build options: build flags, source filter | ||
| ; Upload options: custom upload port, speed and extra flags | ||
| ; Library options: dependencies, extra library storages | ||
| ; Advanced options: extra scripting | ||
| ; | ||
| ; Please visit documentation for the other options and examples | ||
| ; https://docs.platformio.org/page/projectconf.html | ||
|
|
||
| [platformio] | ||
| default_envs = pico | ||
|
|
||
| [env:pico] | ||
| platform = https://github.com/maxgerhardt/platform-raspberrypi.git | ||
| board = rpipico | ||
| framework = arduino | ||
| board_build.core = earlephilhower | ||
| platform_packages = | ||
| framework-arduinopico@symlink://path/to/arduino-pico | ||
|
|
||
| ;build_flags = -DLWIP_DEBUG=1 -DDEBUG_RP2040_PORT=Serial1 | ||
|
|
||
| [env:pico2] | ||
| platform = https://github.com/maxgerhardt/platform-raspberrypi.git | ||
| board = rpipico2 | ||
| framework = arduino | ||
| board_build.core = earlephilhower | ||
| platform_packages = | ||
| framework-arduinopico@symlink://path/to/arduino-pico | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| /* | ||
| This sketch establishes a TCP connection to a "quote of the day" service. | ||
| It sends a "hello" message, and then prints received data. | ||
| */ | ||
|
|
||
| #include <Arduino.h> | ||
| #include <NCMEthernetlwIP.h> | ||
|
|
||
| const char* host = "djxmmx.net"; | ||
| const uint16_t port = 17; | ||
|
|
||
| NCMEthernetlwIP eth; | ||
| IPAddress my_static_ip_addr(192, 168, 137, 100); | ||
| IPAddress my_static_gateway_and_dns_addr(192, 168, 137, 1); | ||
|
|
||
| #define USE_REAL_UART | ||
|
|
||
| #if defined(USE_REAL_UART) | ||
| #define SER Serial1 | ||
| #else | ||
| #define SER Serial | ||
| #endif | ||
|
|
||
| void setup() { | ||
| // enable Serial1 so it can be used by USE_REAL_UART or by DEBUG_RP2040_PORT | ||
| Serial1.end(); | ||
| Serial1.setTX(16); | ||
| Serial1.setRX(17); | ||
| Serial1.begin(115200); | ||
|
|
||
| pinMode(LED_BUILTIN, OUTPUT); | ||
| digitalWrite(LED_BUILTIN, HIGH); | ||
|
|
||
| Serial.begin(115200); | ||
| delay(3000); | ||
| SER.println(); | ||
| SER.println(); | ||
| SER.println("Starting NCM Ethernet port"); | ||
|
|
||
|
|
||
| //optional static config | ||
| // eth.config(my_static_ip_addr, my_static_gateway_and_dns_addr, IPAddress(255, 255, 255, 0), my_static_gateway_and_dns_addr); | ||
|
|
||
| // Start the Ethernet port | ||
| // This starts DHCP in case config() was not called before | ||
| bool ok = eth.begin(); | ||
| delay(1000); | ||
| if (!ok) { | ||
| while (1) { | ||
| SER.println("Failed to initialize NCM Ethernet."); | ||
| delay(1000); | ||
| } | ||
| } else { | ||
| SER.println("NCM Ethernet started successfully."); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| void loop() { | ||
| static unsigned long next_msg = 0; | ||
| static bool led_on = false; | ||
| if(millis() > next_msg) { | ||
| SER.println("."); | ||
| next_msg = millis() + 1000; | ||
| digitalWrite(LED_BUILTIN, led_on); | ||
| led_on ^=1; | ||
| } | ||
|
|
||
| static bool connected = false; | ||
| if(!eth.connected()) { | ||
| connected = false; | ||
| return; | ||
| } else if(!connected){ | ||
| SER.println(""); | ||
| SER.println("Ethernet connected"); | ||
| SER.println("IP address: "); | ||
| SER.println(eth.localIP()); | ||
| connected = true; | ||
| } | ||
|
|
||
| static bool wait = false; | ||
|
|
||
| SER.printf("connecting to %s:%i\n", host, port); | ||
|
|
||
| // Use WiFiClient class to create TCP connections | ||
| WiFiClient client; | ||
| if (!client.connect(host, port)) { | ||
| SER.println("connection failed"); | ||
| delay(5000); | ||
| return; | ||
| } | ||
|
|
||
| // This will send a string to the server | ||
| SER.println("sending data to server"); | ||
| if (client.connected()) { | ||
| client.println("hello from RP2040"); | ||
| } | ||
|
|
||
| // wait for data to be available | ||
| unsigned long timeout = millis(); | ||
| while (client.available() == 0) { | ||
| if (millis() - timeout > 5000) { | ||
| SER.println(">>> Client Timeout !"); | ||
| client.stop(); | ||
| delay(60000); | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| // Read all the lines of the reply from server and print them to Serial | ||
| SER.println("receiving from remote server"); | ||
| // not testing 'client.connected()' since we do not need to send data here | ||
| while (client.available()) { | ||
| char ch = static_cast<char>(client.read()); | ||
| SER.print(ch); | ||
| } | ||
|
|
||
| // Close the connection | ||
| SER.println(); | ||
| SER.println("closing connection"); | ||
| client.stop(); | ||
|
|
||
| if (wait) { | ||
| delay(300000); // execute once every 5 minutes, don't flood remote service | ||
| } | ||
| wait = true; | ||
| } |
Check warning
Code scanning / CodeQL
Expression has no effect Warning
Copilot Autofix
AI 3 days ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.