Skip to content

Commit 4ab96d4

Browse files
committed
Add more logging
1 parent 1a07443 commit 4ab96d4

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

platformio.ini

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,32 @@ platform = platformio/espressif32@^6.11.0
1414
framework = arduino
1515
board = esp-wrover-kit
1616
; disable the next two lines for automatic port assignment
17-
monitor_port = /dev/cu.wchusbserial58900018531
18-
upload_port = /dev/cu.wchusbserial58900018531
17+
monitor_port = /dev/cu.usbmodem1101
18+
upload_port = /dev/cu.usbmodem1101
1919
upload_speed = 921600
2020
monitor_speed = 115200
2121
board_build.flash_size = 8MB
2222
board_build.partitions = huge_app.csv
2323
;board_build.f_cpu = 240000000L
2424
monitor_filters = esp32_exception_decoder, time
25-
lib_deps = h2zero/NimBLE-Arduino@^2.3.2
26-
suculent/AESLib@^2.3.6
25+
lib_deps = ;h2zero/NimBLE-Arduino@^2.3.2
26+
;suculent/AESLib@^2.3.6
2727
bblanchon/ArduinoJson@^7.4.2
28-
fastled/FastLED @ ^3.3.3
28+
;fastled/FastLED @ ^3.3.3
2929

3030
[env:production]
3131
build_flags = -DCORE_DEBUG_LEVEL=1
3232

3333

3434
[env:local-dev]
35+
board_build.flash_size = 8MB
36+
build_flags =
37+
-DCORE_DEBUG_LEVEL=5
38+
39+
[env:local-dev-s3]
3540
build_flags =
3641
-DCORE_DEBUG_LEVEL=5
3742

43+
board_build.flash_size = 4MB
44+
board_build.partitions = no_ota.csv
45+
board = esp32-s3-devkitc-1

src/main.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
#include <esp_wifi.h>
44

55
// REPLACE WITH YOUR RECEIVER MAC Address
6-
uint8_t broadcastAddress[] = {0xC8, 0xF0, 0x9E, 0x19, 0x88, 0x80};
6+
uint8_t broadcastAddress[] = {0xFC, 0xE8, 0xC0, 0x4A, 0x01, 0x64};
7+
//uint8_t broadcastAddress[] = {0xC8, 0xF0, 0x9E, 0x19, 0x88, 0x80};
8+
79

810
// Structure example to send data
911
// Must match the receiver structure
@@ -31,6 +33,9 @@ uint8_t channel = 0;
3133
bool isHubChannelFound = false;
3234
uint8_t failureCount = 0;
3335

36+
uint32_t totalSent = 0;
37+
uint32_t totalFailure = 0;
38+
3439
// callback when data is sent
3540
void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
3641
Serial.print("\r\nLast Packet Send Status:\t");
@@ -47,6 +52,7 @@ void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
4752
esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE);
4853
esp_wifi_set_promiscuous(false);
4954
} else {
55+
totalFailure++;
5056
// If the hub channel has been found before but we have failures now
5157
// we give the hub some time before we start searching the channel again
5258
// This might avoid all nodes starting the channel search immediatelly
@@ -58,8 +64,12 @@ void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
5864

5965
} else {
6066
failureCount = 0;
61-
isHubChannelFound = true;
67+
if (!isHubChannelFound) {
68+
isHubChannelFound = true;
69+
log_i("*** Channel locked at %d ***", channel);
70+
}
6271
}
72+
totalSent++;
6373
}
6474

6575
void setup() {
@@ -124,16 +134,18 @@ void loop() {
124134
// Send message via ESP-NOW
125135
esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &myData, sizeof(myData));
126136

127-
if (result == ESP_OK) {
137+
/*if (result == ESP_OK) {
128138
log_i("Sent with success");
129139
} else {
130140
log_i("Error sending the data");
131-
}
141+
}*/
142+
143+
log_i("Total messages: %d, failures: %d, channel: %d", totalSent, totalFailure, channel);
132144

133145
if (isHubChannelFound) {
134146
delay(2000);
135147
} else {
136-
delay(100);
148+
delay(1000);
137149
}
138150

139151
}

0 commit comments

Comments
 (0)