Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions examples/simple_repeater/MyMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,10 @@ const char *MyMesh::getLogDateTime() {

void MyMesh::logRxRaw(float snr, float rssi, const uint8_t raw[], int len) {
#if MESH_PACKET_LOGGING
Serial.print(getLogDateTime());
Serial.print(" RAW: ");
mesh::Utils::printHex(Serial, raw, len);
Serial.println();
MESH_CONSOLE_SERIAL.print(getLogDateTime());
MESH_CONSOLE_SERIAL.print(" RAW: ");
mesh::Utils::printHex(MESH_CONSOLE_SERIAL, raw, len);
MESH_CONSOLE_SERIAL.println();
#endif
}

Expand Down Expand Up @@ -1043,7 +1043,7 @@ void MyMesh::dumpLogFile() {
while (f.available()) {
int c = f.read();
if (c < 0) break;
Serial.print((char)c);
MESH_CONSOLE_SERIAL.print((char)c);
}
f.close();
}
Expand Down Expand Up @@ -1232,14 +1232,14 @@ void MyMesh::handleCommand(uint32_t sender_timestamp, char *command, char *reply
}
}
} else if (sender_timestamp == 0 && strcmp(command, "get acl") == 0) {
Serial.println("ACL:");
MESH_CONSOLE_SERIAL.println("ACL:");
for (int i = 0; i < acl.getNumClients(); i++) {
auto c = acl.getClientByIdx(i);
if (c->permissions == 0) continue; // skip deleted (or guest) entries

Serial.printf("%02X ", c->permissions);
mesh::Utils::printHex(Serial, c->id.pub_key, PUB_KEY_SIZE);
Serial.printf("\n");
MESH_CONSOLE_SERIAL.printf("%02X ", c->permissions);
mesh::Utils::printHex(MESH_CONSOLE_SERIAL, c->id.pub_key, PUB_KEY_SIZE);
MESH_CONSOLE_SERIAL.printf("\n");
}
reply[0] = 0;
} else if (memcmp(command, "discover.neighbors", 18) == 0) {
Expand Down
18 changes: 9 additions & 9 deletions examples/simple_repeater/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static unsigned long userBtnDownAt = 0;
#endif

void setup() {
Serial.begin(115200);
MESH_CONSOLE_SERIAL.begin(115200);
delay(1000);

board.begin();
Expand Down Expand Up @@ -86,8 +86,8 @@ void setup() {
store.save("_main", the_mesh.self_id);
}

Serial.print("Repeater ID: ");
mesh::Utils::printHex(Serial, the_mesh.self_id.pub_key, PUB_KEY_SIZE); Serial.println();
MESH_CONSOLE_SERIAL.print("Repeater ID: ");
mesh::Utils::printHex(MESH_CONSOLE_SERIAL, the_mesh.self_id.pub_key, PUB_KEY_SIZE); MESH_CONSOLE_SERIAL.println();

command[0] = 0;

Expand All @@ -109,12 +109,12 @@ void setup() {

void loop() {
int len = strlen(command);
while (Serial.available() && len < sizeof(command)-1) {
char c = Serial.read();
while (MESH_CONSOLE_SERIAL.available() && len < sizeof(command)-1) {
char c = MESH_CONSOLE_SERIAL.read();
if (c != '\n') {
command[len++] = c;
command[len] = 0;
Serial.print(c);
MESH_CONSOLE_SERIAL.print(c);
}
if (c == '\r') break;
}
Expand All @@ -123,12 +123,12 @@ void loop() {
}

if (len > 0 && command[len - 1] == '\r') { // received complete line
Serial.print('\n');
MESH_CONSOLE_SERIAL.print('\n');
command[len - 1] = 0; // replace newline with C string null terminator
char reply[160];
the_mesh.handleCommand(0, command, reply); // NOTE: there is no sender_timestamp via serial!
if (reply[0]) {
Serial.print(" -> "); Serial.println(reply);
MESH_CONSOLE_SERIAL.print(" -> "); MESH_CONSOLE_SERIAL.println(reply);
}

command[0] = 0; // reset command buffer
Expand All @@ -141,7 +141,7 @@ void loop() {
if (userBtnDownAt == 0) {
userBtnDownAt = millis();
} else if ((unsigned long)(millis() - userBtnDownAt) >= USER_BTN_HOLD_OFF_MILLIS) {
Serial.println("Powering off...");
MESH_CONSOLE_SERIAL.println("Powering off...");
board.powerOff(); // does not return
}
} else {
Expand Down
10 changes: 7 additions & 3 deletions src/MeshCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,21 @@
#define MAX_PATH_SIZE 64
#define MAX_TRANS_UNIT 255

#ifndef MESH_CONSOLE_SERIAL
#define MESH_CONSOLE_SERIAL Serial
#endif

#if MESH_DEBUG && ARDUINO
#include <Arduino.h>
#define MESH_DEBUG_PRINT(F, ...) Serial.printf("DEBUG: " F, ##__VA_ARGS__)
#define MESH_DEBUG_PRINTLN(F, ...) Serial.printf("DEBUG: " F "\n", ##__VA_ARGS__)
#define MESH_DEBUG_PRINT(F, ...) MESH_CONSOLE_SERIAL.printf("DEBUG: " F, ##__VA_ARGS__)
#define MESH_DEBUG_PRINTLN(F, ...) MESH_CONSOLE_SERIAL.printf("DEBUG: " F "\n", ##__VA_ARGS__)
#else
#define MESH_DEBUG_PRINT(...) {}
#define MESH_DEBUG_PRINTLN(...) {}
#endif

#if BRIDGE_DEBUG && ARDUINO
#define BRIDGE_DEBUG_PRINTLN(F, ...) Serial.printf("%s BRIDGE: " F, getLogDateTime(), ##__VA_ARGS__)
#define BRIDGE_DEBUG_PRINTLN(F, ...) MESH_CONSOLE_SERIAL.printf("%s BRIDGE: " F, getLogDateTime(), ##__VA_ARGS__)
#else
#define BRIDGE_DEBUG_PRINTLN(...) {}
#endif
Expand Down
2 changes: 2 additions & 0 deletions variants/rak3401/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ build_flags =
-D MAX_NEIGHBOURS=50
;-D MESH_PACKET_LOGGING=1
;-D MESH_DEBUG=1
;-D MESH_CONSOLE_SERIAL=Serial1
;-UENV_INCLUDE_GPS ; GPS is on Serial1, enabling this line disables it
build_src_filter = ${rak3401.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_repeater>
Expand Down