Please include the following information, in order for us to help you as effectively as possible.
-
What product do you wish to discuss? RAK4631, RAK3372, RAK11200, RAK11310, RAK11722?
AT+VER=RUI_4.0.6_RAK3272-SiP -
What firmware are you using? (RUI3 or Arduino BSP or other IDE (e.g. STM32CubeIDE)?
Arduino BSP -
What firmware version? Can it be obtained with AT+VER=?
AT+VER=RUI_4.0.6_RAK3272-SiP
- Computer OS? (MacOS, Linux, Windows)
Linux
I am trying to create a custom wake up from radio. The aim is to sleep for approximately 10 seconds and then check for the RX messages, if the RX have messages, do the operation and sleep again. If not, sleep for 10 seconds and repeat the cycle. The problem that I faced is that I can able to put on to the sleep, and wake up after 10 seconds. If the message is received within the RX listen period, it does the operation and re-enters the sleep very well and its approximately 10uA which is awesome. However, If there are no messages in the RX listen period, callback returns +EVT:RXP2P RECEIVE TIMEOUT and after that I cannot put it to the sleep, the current is approximately 9 mA. The code block given below.
uint16_t spreading_factor = 9, bw = 2, cr = 0, tx_power = 22, preamble = 8;
double freq = 868000000;
uint8_t *payload;
bool is_finished = false;
unsigned long curr;
void recv_cb(rui_lora_p2p_recv_t data)
{
Serial.printf("Incoming packet %d , length: %d, RSSI %d, SNR %d\n",data.Buffer[data.BufferSize-1],data.BufferSize,data.Rssi,data.Snr);
//Do Something after receving data
}
void setup()
{
Serial.begin(115200);
if(api.lorawan.nwm.get() != 0)
{
Serial.printf("Set Node deice work to P2P %s\r\n",api.lorawan.nwm.set(0) ? "Succcess":"Fail");
api.system.reboot();
}
Serial.printf("Set P2P mode frequency %3.3f: %s\r\n", (freq / 1e6),api.lorawan.pfreq.set(freq) ? "Success" : "Fail");
Serial.printf("Set P2P mode spreading factor %d: %s\r\n", spreading_factor, api.lorawan.psf.set(spreading_factor) ? "Success" : "Fail");
Serial.printf("Set P2P mode bandwidth %d: %s\r\n", bw, api.lorawan.pbw.set(bw) ? "Success" : "Fail");
Serial.printf("Set P2P mode code rate 4/%d: %s\r\n", (cr + 5), api.lorawan.pcr.set(cr) ? "Success" : "Fail");
Serial.printf("Set P2P mode preamble length %d: %s\r\n", preamble, api.lorawan.ppl.set(preamble) ? "Success" : "Fail");
Serial.printf("Set P2P mode tx power %d: %s\r\n", tx_power, api.lorawan.ptp.set(tx_power) ? "Success" : "Fail");
//Serial.printf("P2P set Rx mode %s\r\n", api.lorawan.precv(3000) ? "Success" : "Fail");
Serial.printf("P2P set Rx Callback Setted %s\r\n", api.lorawan.registerPRecvCallback(recv_cb) ? "Success" : "Fail");
curr = millis();
}
void loop()
{
if(is_finished)
{
Serial.printf("Sleep Ended\n");
Serial.printf("P2P set Rx mode %s\r\n", api.lorawan.precv(2000) ? "Success" : "Fail");
delay(3000);
is_finished = false;
curr = millis();
}
else
{
api.system.sleep.all(10000);
}
if(millis()-curr >10000)
{
is_finished = true;
}
}
Thank you in advence