Skip to content
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

solve several problems #181

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Merge branch 'master' into raul360-usbstick-ok
Signed-off-by: Sabas <[email protected]>
sabas1080 authored Feb 15, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit ffeac1680c3d1ef26a8d48fd0d946b0d91a1964f
74 changes: 55 additions & 19 deletions src/arduino-rfm/LoRaMAC.cpp
Original file line number Diff line number Diff line change
@@ -123,7 +123,6 @@ void LORA_Cycle(sBuffer *Data_Tx, sBuffer *Data_Rx, RFM_command_t *RFM_Command,
#endif
LORA_Receive_Data(Data_Rx, Session_Data, OTAA_Data, Message_Rx, LoRa_Settings); //BUG DETECT SENDED PACKET ALWAYS (IT DOES UPDATE)
}

//Wait rx1 window delay
//Receive on RX2 if countinous mode is available
//check if anything if coming on class C RX2 window in class A no DIO0 flag will be activated
@@ -141,31 +140,68 @@ void LORA_Cycle(sBuffer *Data_Tx, sBuffer *Data_Rx, RFM_command_t *RFM_Command,
LoRa_Settings->Datarate_Rx = rx1_dr; //set RX1 datarate
//Receive Data RX1
LORA_Receive_Data(Data_Rx, Session_Data, OTAA_Data, Message_Rx, LoRa_Settings);
//Wait rx2 window delay
do{
//Poll Rx done for getting message
//DIO0 flag will only be active while class C
if(digitalRead(RFM_pins.DIO0))
LORA_Receive_Data(Data_Rx, Session_Data, OTAA_Data, Message_Rx, LoRa_Settings);
}while(millis() - prevTime < Receive_Delay_2);
//Return if message on RX1
if (Data_Rx->Counter>0)return;
}while(millis() - prevTime < Receive_Delay_1 + RX1_Window);
//Return if message on RX1
if (Data_Rx->Counter>0){
return;
}

//
#ifdef _CLASS_C_
return;
#endif

// Class C open RX2 immediately after first rx window
if(LoRa_Settings->Mote_Class == CLASS_C){
#ifdef US_915
LoRa_Settings->Channel_Rx = 0x08; // set Rx2 channel 923.3 MHZ
LoRa_Settings->Datarate_Rx = SF12BW500; //set RX2 datarate 12
#elif defined(EU_868)
LoRa_Settings->Channel_Rx = CHRX2; // set Rx2 channel 923.3 MHZ
LoRa_Settings->Datarate_Rx = SF12BW125; //set RX2 datarate 12
#elif defined(IN_865)
LoRa_Settings->Channel_Rx = CHRX2; // set Rx2 channel 866.550 MHZ
LoRa_Settings->Datarate_Rx = SF10BW125; //set RX2 datarate 10
#elif defined(AS_923) || defined(AS_923_2)
LoRa_Settings->Channel_Rx = 0x00; // set Rx2 channel 923.2 (AS_923) or 921.4 (AS_923_2)
LoRa_Settings->Datarate_Rx = SF10BW125; //set RX2 datarate 10
/* Added the band AU_915 for use in class C */
#elif defined(AU_915)
LoRa_Settings->Channel_Rx = 0x08; // set Rx2 channel 923.3 MHZ
LoRa_Settings->Datarate_Rx = SF12BW500; //set RX2 datarate 12
#endif
LORA_Receive_Data(Data_Rx, Session_Data, OTAA_Data, Message_Rx, LoRa_Settings); //BUG DETECT SENDED PACKET ALWAYS (IT DOES UPDATE)
}

//LoRaWAN Link Layer Specification v1.0.4 line 375
//Wait rx1 window delay, TO TEST check if class c receives anything
//Wait rx2 window delay, TO TEST check if class c receives anything
do{
yield(); // Do nothing during rx1 window delay
}while(millis() - prevTime < Receive_Delay_1);
yield(); // Do nothing during rx2 window delay
}while(millis() - prevTime < Receive_Delay_2);

//RX2 Window
//Configure datarate and channel for RX2
#ifdef US_915
LoRa_Settings->Channel_Rx = 0x08; // set Rx2 channel 923.3 MHZ
LoRa_Settings->Datarate_Rx = SF12BW500; //set RX2 datarate 12
#elif defined(EU_868)
LoRa_Settings->Channel_Rx = CHRX2; // set Rx2 channel 923.3 MHZ
LoRa_Settings->Datarate_Rx = SF12BW125; //set RX2 datarate 12
#elif defined(IN_865)
LoRa_Settings->Channel_Rx = CHRX2; // set Rx2 channel 866.550 MHZ
LoRa_Settings->Datarate_Rx = SF10BW125; //set RX2 datarate 10
#elif defined(AS_923) || defined(AS_923_2)
LoRa_Settings->Channel_Rx = 0x00; // set Rx2 channel 923.2 (AS_923) or 921.4 (AS_923_2)
LoRa_Settings->Datarate_Rx = SF10BW125; //set RX2 datarate 10
#elif defined(AU_915)
LoRa_Settings->Channel_Rx = 0x08; // set Rx2 channel 923.3 MHZ
LoRa_Settings->Datarate_Rx = SF12BW500; //set RX2 datarate 12
#endif

//RX1 Window
//Return to datarate and channel for RX1
LoRa_Settings->Channel_Rx = rx1_ch; // set RX1 channel
LoRa_Settings->Datarate_Rx = rx1_dr; // set RX1 datarate

//Receive Data RX2
do{
LORA_Receive_Data(Data_Rx, Session_Data, OTAA_Data, Message_Rx, LoRa_Settings);
*RFM_Command = NO_RFM_COMMAND;

}
}

2 changes: 1 addition & 1 deletion src/arduino-rfm/Struct.h
Original file line number Diff line number Diff line change
@@ -178,4 +178,4 @@ typedef enum {NO_RX, NEW_RX} rx_t;

typedef enum {NO_ACK, NEW_ACK} ack_t;

#endif
#endif
2 changes: 1 addition & 1 deletion src/arduino-rfm/lorawan-arduino-rfm.cpp
Original file line number Diff line number Diff line change
@@ -96,7 +96,7 @@ bool LoRaWANClass::init(void)
#elif defined(EU_868)
LoRa_Settings.Datarate_Rx = 0x03; //set to SF9 BW 125 kHz
#elif defined(IN_865)
LoRa_Settings.Datarate_Rx = 0x02;
LoRa_Settings.Datarate_Rx = 0x02; //set to SF10 BW 125 kHz
#else //US_915 or AU_915
LoRa_Settings.Datarate_Rx = 0x0C; //set to SF8 BW 500 kHz
#endif
You are viewing a condensed version of this merge commit. You can view the full changes here.