Skip to content

Commit 4853909

Browse files
committed
testing sending msg OK
1 parent 9a9de66 commit 4853909

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

.vscode/extensions.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
{
2-
// See http://go.microsoft.com/fwlink/?LinkId=827846
3-
// for the documentation about the extensions.json format
4-
"recommendations": [
5-
"platformio.platformio-ide"
6-
]
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": [
5+
"platformio.platformio-ide"
6+
]
77
}

.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"terminal.integrated.env.linux": {
3-
"PATH": "/home/bois/.platformio/penv/bin:/home/bois/.platformio/penv:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl",
3+
"PATH": "/home/bois/.platformio/penv/bin:/home/bois/.platformio/penv:/home/bois/esp/xtensa-esp32-elf/bin:/home/bois/bin:/home/bois/.local/bin:/home/bois/esp/xtensa-esp32-elf/bin:/home/bois/bin:/home/bois/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/diogo/android-studio/bin:/snap/bin:/usr/intelFPGA_lite/17.0/quartus/bin:/usr/intelFPGA_lite/17.0/quartus/bin",
44
"PLATFORMIO_CALLER": "vscode"
55
}
66
}

src/main.cpp

+16-10
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ uint32_t local_UniqueId;
2525

2626
// Remote LoRa INFO
2727
uint16_t remote_Id;
28-
uint8_t buffer[10] = {0};
29-
uint8_t buffer_size;
28+
uint8_t bufferPayload[MAX_PAYLOAD_SIZE] = {0};
29+
uint8_t buffer_size = 0;
3030

3131
// payload
32+
uint16_t funciona = 2;
3233
uint8_t payload = 1;
3334

3435
// Functions
@@ -53,37 +54,42 @@ void setup() {
5354
Serial.println(local_Net);
5455
Serial.print("Local Unique ID: ");
5556
Serial.println(local_UniqueId, HEX);
56-
if(local_Id == 0) isMaster = true;
57+
if(local_Id == 0) {
58+
isMaster = true;
59+
Serial.println("Set as a master");
60+
}
5761
}
5862
}
5963

6064
void loop() {
6165
if(isMaster){
6266
if(posedge(PB, &prev_state)){
6367
Serial.println("PB detected...");
64-
if(PrepareFrameTransp(254, &payload, sizeof(payload)) != MESH_OK){
68+
if(PrepareFrameTransp(funciona, &payload, sizeof(payload)) != MESH_OK){
6569
Serial.println("Error building msg frame");
6670
}
6771
else {
68-
Serial.print("Sending frame");
72+
Serial.print("Sending frame to ID: ");
73+
Serial.println(funciona);
6974
SendPacket();
7075
}
7176
}
72-
delay(10);
77+
delay(1);
7378
}
7479
else {
75-
if(ReceivePacketTransp(&remote_Id, buffer, &buffer_size, 5000) == MESH_OK){
80+
Serial.println("waiting for data...");
81+
if(ReceivePacketTransp(&remote_Id, bufferPayload, &buffer_size, 5000) == MESH_OK){
7682
Serial.print("FRAME: ");
7783
for(int i = 0; i < buffer_size; i++){
78-
Serial.print(buffer[i]);
84+
Serial.print(bufferPayload[i]);
7985
}
8086
Serial.print(" SIZE: ");
8187
Serial.println(buffer_size);
82-
if(buffer[0] == 1){
88+
if(bufferPayload[0] == 1){
8389
digitalWrite(LED, !digitalRead(LED));
8490
}
8591
}
86-
delay(10);
92+
delay(1);
8793
}
8894
}
8995

0 commit comments

Comments
 (0)