Skip to content

Commit b83f823

Browse files
authored
Merge pull request #11 from christoph2/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2 parents fb89f6b + 250aaef commit b83f823

File tree

6 files changed

+63
-46
lines changed

6 files changed

+63
-46
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repos:
1313
description: "Forces line endings to LF."
1414

1515
- repo: https://github.com/pre-commit/mirrors-clang-format
16-
rev: v21.1.5
16+
rev: v21.1.6
1717
hooks:
1818
- id: clang-format
1919
types_or: [c, c++]

examples/debug_on_pico/usb_descriptors.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ tusb_desc_device_t const desc_device = {
6767

6868
// Invoked when received GET DEVICE DESCRIPTOR
6969
// Application return pointer to descriptor
70-
uint8_t const * tud_descriptor_device_cb(void) {
70+
uint8_t const *tud_descriptor_device_cb(void) {
7171
return (uint8_t const *)&desc_device;
7272
}
7373

@@ -161,14 +161,14 @@ tusb_desc_device_qualifier_t const desc_device_qualifier = { .bLength =
161161
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete.
162162
// device_qualifier descriptor describes information about a high-speed capable device that would
163163
// change if the device were operating at the other speed. If not highspeed capable stall this request.
164-
uint8_t const * tud_descriptor_device_qualifier_cb(void) {
164+
uint8_t const *tud_descriptor_device_qualifier_cb(void) {
165165
return (uint8_t const *)&desc_device_qualifier;
166166
}
167167

168168
// Invoked when received GET OTHER SEED CONFIGURATION DESCRIPTOR request
169169
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
170170
// Configuration descriptor in the other speed e.g if high speed then this is for full speed and vice versa
171-
uint8_t const * tud_descriptor_other_speed_configuration_cb(uint8_t index) {
171+
uint8_t const *tud_descriptor_other_speed_configuration_cb(uint8_t index) {
172172
(void)index; // for multiple configurations
173173

174174
// if link speed is high return fullspeed config, and vice versa
@@ -188,7 +188,7 @@ uint8_t const * tud_descriptor_other_speed_configuration_cb(uint8_t index) {
188188
// Invoked when received GET CONFIGURATION DESCRIPTOR
189189
// Application return pointer to descriptor
190190
// Descriptor contents must exist long enough for transfer to complete
191-
uint8_t const * tud_descriptor_configuration_cb(uint8_t index) {
191+
uint8_t const *tud_descriptor_configuration_cb(uint8_t index) {
192192
(void)index; // for multiple configurations
193193

194194
#if TUD_OPT_HIGH_SPEED
@@ -212,7 +212,7 @@ enum {
212212
};
213213

214214
// array of pointer to string descriptors
215-
char const * string_desc_arr[] = {
215+
char const *string_desc_arr[] = {
216216
(const char[]){ 0x09, 0x04 }, // 0: is supported language is English (0x0409)
217217
"TinyUSB", // 1: Manufacturer
218218
"TinyUSB Device", // 2: Product
@@ -224,7 +224,7 @@ static uint16_t _desc_str[32 + 1];
224224

225225
// Invoked when received GET STRING DESCRIPTOR request
226226
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
227-
uint16_t const * tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
227+
uint16_t const *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
228228
(void)langid;
229229
size_t chr_count;
230230

@@ -245,7 +245,7 @@ uint16_t const * tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
245245
if (!(index < sizeof(string_desc_arr) / sizeof(string_desc_arr[0])))
246246
return NULL;
247247

248-
const char* str = string_desc_arr[index];
248+
const char *str = string_desc_arr[index];
249249

250250
// Cap at max char
251251
chr_count = strlen(str);

inc/xcp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
#define XCP_ON_ETHERNET_USE_TCP (1)
101101

102102
#if !defined(XCP_ON_ETHERNET_PROTOCOL)
103-
#define XCP_ON_ETHERNET_PROTOCOL XCP_ON_ETHERNET_USE_UDP
103+
#define XCP_ON_ETHERNET_PROTOCOL XCP_ON_ETHERNET_USE_UDP
104104
#endif /* * XCP_ON_ETHERNET_PROTOCOL */
105105

106106
#if XCP_ENABLE_EXTERN_C_GUARDS == XCP_ON

src/tl/eth/arduino_networking.cpp

Lines changed: 52 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#include <SPI.h>
4444
#endif
4545

46-
4746
const unsigned long READ_TIMEOUT_MS = 2000;
4847

4948
class ClientWrapper {
@@ -357,37 +356,37 @@ class WiFiAdapter : public ArduinoNetworkIf {
357356

358357
bool begin() override {
359358
// Put ESP32 in station mode and try to keep things deterministic during connect
360-
WiFi.persistent(false); // avoid writing credentials repeatedly to NVS
359+
WiFi.persistent(false); // avoid writing credentials repeatedly to NVS
361360
WiFi.mode(WIFI_STA);
362-
WiFi.setSleep(false); // keep radio awake during provisioning/UDP XCP
363-
// Optional set TX power (requires Arduino-ESP32 supporting WiFi.setTxPower)
364-
#ifdef XCP_ON_WIFI_TX_POWER
361+
WiFi.setSleep(false); // keep radio awake during provisioning/UDP XCP
362+
// Optional set TX power (requires Arduino-ESP32 supporting WiFi.setTxPower)
363+
#ifdef XCP_ON_WIFI_TX_POWER
365364
WiFi.setTxPower(XCP_ON_WIFI_TX_POWER);
366-
#endif
365+
#endif
367366

368367
// Optional static IP configuration (do this BEFORE begin())
369368
{
370-
#if defined(XCP_ON_ETHERNET_IP_OCTETS)
369+
#if defined(XCP_ON_ETHERNET_IP_OCTETS)
371370
IPAddress ip(XCP_ON_ETHERNET_IP_OCTETS);
372371
if (!WiFi.config(ip)) {
373372
Serial.println("[WiFi] Failed to apply static IP config");
374373
}
375-
#elif defined(XCP_ON_ETHERNET_IP)
374+
#elif defined(XCP_ON_ETHERNET_IP)
376375
IPAddress ip;
377376
ip.fromString(XCP_ON_ETHERNET_IP);
378377
if (!WiFi.config(ip)) {
379378
Serial.println("[WiFi] Failed to apply static IP config");
380379
}
381-
#endif
380+
#endif
382381
}
383382

384383
Serial.print("[WiFi] Connecting to SSID: ");
385384
Serial.println(m_ssid ? m_ssid : "<null>");
386385
wl_status_t startStatus = WiFi.begin(m_ssid, m_pass);
387-
(void)startStatus; // not all cores return a meaningful value here
386+
(void)startStatus; // not all cores return a meaningful value here
388387

389-
const unsigned long timeoutMs = 15000; // allow a bit more time on congested APs
390-
unsigned long start = millis();
388+
const unsigned long timeoutMs = 15000; // allow a bit more time on congested APs
389+
unsigned long start = millis();
391390
wl_status_t st;
392391
while ((st = WiFi.status()) != WL_CONNECTED && (millis() - start < timeoutMs)) {
393392
switch (st) {
@@ -455,7 +454,7 @@ class WiFiAdapter : public ArduinoNetworkIf {
455454
Serial.println("[WiFi] UDP listener started after reconnect");
456455
}
457456
}
458-
m_reconnect_backoff_ms = 2000; // reset backoff on success
457+
m_reconnect_backoff_ms = 2000; // reset backoff on success
459458
} else {
460459
// Ensure UDP is not used while disconnected/connecting
461460
if (m_udp_active) {
@@ -491,8 +490,8 @@ class WiFiAdapter : public ArduinoNetworkIf {
491490
const char* m_ssid;
492491
const char* m_pass;
493492
WiFiUdpClientWrapper m_udpClientWrapper;
494-
bool m_udp_active = false;
495-
unsigned long m_reconnect_backoff_ms = 2000; // start with 2s backoff
493+
bool m_udp_active = false;
494+
unsigned long m_reconnect_backoff_ms = 2000; // start with 2s backoff
496495
};
497496
#endif // XCP_ON_ETHERNET_ARDUINO_DRIVER == XCP_ON_ETHERNET_DRIVER_WIFI
498497

@@ -554,63 +553,80 @@ class FrameParser {
554553
/* TCP client wrapper and adapter for WiFi (ESP32) */
555554
class WiFiClientWrapper : public ClientWrapper {
556555
public:
557-
explicit WiFiClientWrapper(WiFiClient c = WiFiClient()) : m_client(c) {}
558556

559-
void set(WiFiClient c) { m_client = c; }
557+
explicit WiFiClientWrapper(WiFiClient c = WiFiClient()) : m_client(c) {
558+
}
560559

561-
int available() override { return m_client ? m_client.available() : 0; }
560+
void set(WiFiClient c) {
561+
m_client = c;
562+
}
562563

563-
int read_bytes(uint8_t* buf, size_t len) override { return m_client.read(buf, len); }
564+
int available() override {
565+
return m_client ? m_client.available() : 0;
566+
}
564567

565-
size_t write_bytes(const uint8_t* buf, size_t len) override { return m_client.write(buf, len); }
568+
int read_bytes(uint8_t* buf, size_t len) override {
569+
return m_client.read(buf, len);
570+
}
566571

567-
bool connected() override { return m_client && m_client.connected(); }
572+
size_t write_bytes(const uint8_t* buf, size_t len) override {
573+
return m_client.write(buf, len);
574+
}
575+
576+
bool connected() override {
577+
return m_client && m_client.connected();
578+
}
568579

569580
void stop() override {
570581
if (m_client) {
571582
m_client.stop();
572583
}
573584
}
574585

575-
bool is_datagram() const override { return false; }
586+
bool is_datagram() const override {
587+
return false;
588+
}
576589

577590
private:
591+
578592
WiFiClient m_client;
579593
};
580594

581595
class WiFiTcpAdapter : public ArduinoNetworkIf {
582596
public:
583-
WiFiTcpAdapter(const char* s, const char* p, uint16_t port) : m_port(port), m_ssid(s), m_pass(p), m_server(port) {}
597+
598+
WiFiTcpAdapter(const char* s, const char* p, uint16_t port) : m_port(port), m_ssid(s), m_pass(p), m_server(port) {
599+
}
584600

585601
bool begin() override {
586602
// Station mode tweaks
587603
WiFi.persistent(false);
588604
WiFi.mode(WIFI_STA);
589605
WiFi.setSleep(false);
590-
#ifdef XCP_ON_WIFI_TX_POWER
606+
#ifdef XCP_ON_WIFI_TX_POWER
591607
WiFi.setTxPower(XCP_ON_WIFI_TX_POWER);
592-
#endif
608+
#endif
593609
Serial.begin(115200);
594610
while (!Serial) {
595611
;
596612
}
597613
Serial.println("\nBlueparrot XCP (TCP) on WiFi");
598614

599615
// Optional static IP configuration
600-
#if defined(XCP_ON_ETHERNET_IP_OCTETS)
616+
#if defined(XCP_ON_ETHERNET_IP_OCTETS)
601617
IPAddress ip(XCP_ON_ETHERNET_IP_OCTETS);
602618
if (!WiFi.config(ip)) {
603619
Serial.println("[WiFi] Failed to apply static IP config");
604620
}
605-
#elif defined(XCP_ON_ETHERNET_IP)
621+
#elif defined(XCP_ON_ETHERNET_IP)
606622
{
607623
IPAddress ip;
608624
ip.fromString(XCP_ON_ETHERNET_IP);
609625
if (!WiFi.config(ip)) {
610626
Serial.println("[WiFi] Failed to apply static IP config (string)");
611627
}
612628
}
613-
#endif
629+
#endif
614630
WiFi.begin(m_ssid, m_pass);
615631
unsigned long start = millis();
616632
while (WiFi.status() != WL_CONNECTED && (millis() - start) < 15000UL) {
@@ -657,11 +673,12 @@ class WiFiTcpAdapter : public ArduinoNetworkIf {
657673
}
658674

659675
private:
660-
uint16_t m_port;
661-
const char* m_ssid;
662-
const char* m_pass;
663-
WiFiServer m_server;
664-
WiFiClient m_client;
676+
677+
uint16_t m_port;
678+
const char* m_ssid;
679+
const char* m_pass;
680+
WiFiServer m_server;
681+
WiFiClient m_client;
665682
WiFiClientWrapper m_wrapper;
666683
};
667684

@@ -722,9 +739,9 @@ extern "C" {
722739
/* Initialize backend network adapter and start listening. */
723740
#if XCP_ON_ETHERNET_ARDUINO_DRIVER == XCP_ON_ETHERNET_DRIVER_WIFI
724741
#if (XCP_ON_ETHERNET_PROTOCOL == XCP_ON_ETHERNET_USE_TCP)
725-
s_net = new WiFiTcpAdapter(XCP_ON_ETHERNET_WIFI_SSID, XCP_ON_ETHERNET_WIFI_PASSWORD, XCP_ON_ETHERNET_PORT);
742+
s_net = new WiFiTcpAdapter(XCP_ON_ETHERNET_WIFI_SSID, XCP_ON_ETHERNET_WIFI_PASSWORD, XCP_ON_ETHERNET_PORT);
726743
#else
727-
s_net = new WiFiAdapter(XCP_ON_ETHERNET_WIFI_SSID, XCP_ON_ETHERNET_WIFI_PASSWORD, XCP_ON_ETHERNET_PORT);
744+
s_net = new WiFiAdapter(XCP_ON_ETHERNET_WIFI_SSID, XCP_ON_ETHERNET_WIFI_PASSWORD, XCP_ON_ETHERNET_PORT);
728745
#endif
729746
#else
730747
#if defined(XCP_ON_ETHERNET_IP_OCTETS)

tools/arduino/hello_xcp/xcp_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
#elif defined(TP_ETHER)
7676
#define XCP_TRANSPORT_LAYER XCP_ON_ETHERNET
7777

78-
#define XCP_ON_ETHERNET_PROTOCOL XCP_ON_ETHERNET_USE_UDP
78+
#define XCP_ON_ETHERNET_PROTOCOL XCP_ON_ETHERNET_USE_UDP
7979
#define XCP_ON_ETHERNET_IP_OCTETS 192, 168, 137, 100
8080
#define XCP_ON_ETHERNET_PORT (5555)
8181

tools/xcp_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
#elif defined(TP_ETHER)
7676
#define XCP_TRANSPORT_LAYER XCP_ON_ETHERNET
7777

78-
#define XCP_ON_ETHERNET_PROTOCOL XCP_ON_ETHERNET_USE_UDP
78+
#define XCP_ON_ETHERNET_PROTOCOL XCP_ON_ETHERNET_USE_UDP
7979
#define XCP_ON_ETHERNET_IP_OCTETS 192, 168, 137, 100
8080
#define XCP_ON_ETHERNET_PORT (5555)
8181

0 commit comments

Comments
 (0)