![]() |
RUI3 (RAK Unified Interface 3) - RAK4631
|
Data Structures | |
class | RAKLorawan::nwm |
class | RAKLorawan::pfreq |
class | RAKLorawan::psf |
class | RAKLorawan::pbw |
class | RAKLorawan::pcr |
class | RAKLorawan::ppl |
class | RAKLorawan::ptp |
class | RAKLorawan::encry |
class | RAKLorawan::enckey |
class | RAKLorawan::pbr |
class | RAKLorawan::pfdev |
Functions | |
bool | registerPRecvCallback (service_lora_p2p_recv_cb_type callback) |
bool | registerPSendCallback (service_lora_p2p_send_cb_type callback) |
bool | registerPSendCADCallback (service_lora_p2p_send_CAD_cb_type callback) |
bool | precv (uint32_t timeout) |
bool | psend (uint8_t length, uint8_t *payload) |
bool registerPRecvCallback | ( | service_lora_p2p_recv_cb_type | callback | ) |
The | callback function |
TRUE | for setting callback function success |
FALSE | for setting callback function failure |
void recv_cb(rui_lora_p2p_recv_t data) { Serial.println("Receive something"); } void send_cb(void) { Serial.println("I send something"); } long startTime; void setup() { Serial.begin(115200); delay(2000); startTime = millis(); Serial.println("P2P Start"); Serial.printf("Set Node device work mode %s\r\n", api.lorawan.nwm.set(0) ? "Success" : "Fail"); Serial.printf("Set P2P mode frequency %s\r\n", api.lorawan.pfreq.set(868000000) ? "Success" : "Fail"); Serial.printf("Set P2P mode spreading factor %s\r\n", api.lorawan.psf.set(12) ? "Success" : "Fail"); Serial.printf("Set P2P mode bandwidth %s\r\n", api.lorawan.pbw.set(125) ? "Success" : "Fail"); Serial.printf("Set P2P mode code rate %s\r\n", api.lorawan.pcr.set(0) ? "Success" : "Fail"); Serial.printf("Set P2P mode preamble length %s\r\n", api.lorawan.ppl.set(8) ? "Success" : "Fail"); Serial.printf("Set P2P mode tx power %s\r\n", api.lorawan.ptp.set(22) ? "Success" : "Fail"); api.lorawan.registerPRecvCallback(recv_cb); api.lorawan.registerPSendCallback(send_cb); randomSeed(millis()); } void loop() { uint8_t payload[] = "payload"; int rxDelay = random(3000, 5000); // Receive P2P data every 10 seconds if(millis() - startTime >= 10*1000) { Serial.printf("P2P Rx start for %d millisSconds\r\n", rxDelay); startTime = millis(); Serial.printf("P2P set Rx mode %s\r\n",api.lorawan.precv(rxDelay) ? "Success" : "Fail"); delay(rxDelay); } else { Serial.printf("P2P send %s\r\n", api.lorawan.psend(sizeof(payload), payload)? "Success" : "Fail"); delay(1000); } }
bool registerPSendCallback | ( | service_lora_p2p_send_cb_type | callback | ) |
The | callback function |
TRUE | for setting callback function success |
FALSE | for setting callback function failure |
void recv_cb(rui_lora_p2p_recv_t data) { Serial.println("Receive something"); } void send_cb(void) { Serial.println("I send something"); } long startTime; void setup() { Serial.begin(115200); delay(2000); startTime = millis(); Serial.println("P2P Start"); Serial.printf("Set Node device work mode %s\r\n", api.lorawan.nwm.set(0) ? "Success" : "Fail"); Serial.printf("Set P2P mode frequency %s\r\n", api.lorawan.pfreq.set(868000000) ? "Success" : "Fail"); Serial.printf("Set P2P mode spreading factor %s\r\n", api.lorawan.psf.set(12) ? "Success" : "Fail"); Serial.printf("Set P2P mode bandwidth %s\r\n", api.lorawan.pbw.set(125) ? "Success" : "Fail"); Serial.printf("Set P2P mode code rate %s\r\n", api.lorawan.pcr.set(0) ? "Success" : "Fail"); Serial.printf("Set P2P mode preamble length %s\r\n", api.lorawan.ppl.set(8) ? "Success" : "Fail"); Serial.printf("Set P2P mode tx power %s\r\n", api.lorawan.ptp.set(22) ? "Success" : "Fail"); api.lorawan.registerPRecvCallback(recv_cb); api.lorawan.registerPSendCallback(send_cb); randomSeed(millis()); } void loop() { uint8_t payload[] = "payload"; int rxDelay = random(3000, 5000); // Receive P2P data every 10 seconds if(millis() - startTime >= 10*1000) { Serial.printf("P2P Rx start for %d millisSconds\r\n", rxDelay); startTime = millis(); Serial.printf("P2P set Rx mode %s\r\n",api.lorawan.precv(rxDelay) ? "Success" : "Fail"); delay(rxDelay); } else { Serial.printf("P2P send %s\r\n", api.lorawan.psend(sizeof(payload), payload)? "Success" : "Fail"); delay(1000); } }
bool registerPSendCADCallback | ( | service_lora_p2p_send_CAD_cb_type | callback | ) |
The | callback function |
TRUE | for setting callback function success |
FALSE | for setting callback function failure |
void recv_cb(rui_lora_p2p_recv_t data) { Serial.println("Receive something"); } void send_cb(void) { Serial.println("I send something"); } void cad_cb(bool detect) { if(detect) Serial.println("detect Activity"); else Serial.println("no Activity"); } long startTime; void setup() { Serial.begin(115200); delay(2000); startTime = millis(); Serial.println("P2P Start"); Serial.printf("Set Node device work mode %s\r\n", api.lorawan.nwm.set(0) ? "Success" : "Fail"); Serial.printf("Set P2P mode frequency %s\r\n", api.lorawan.pfreq.set(868000000) ? "Success" : "Fail"); Serial.printf("Set P2P mode spreading factor %s\r\n", api.lorawan.psf.set(12) ? "Success" : "Fail"); Serial.printf("Set P2P mode bandwidth %s\r\n", api.lorawan.pbw.set(125) ? "Success" : "Fail"); Serial.printf("Set P2P mode code rate %s\r\n", api.lorawan.pcr.set(0) ? "Success" : "Fail"); Serial.printf("Set P2P mode preamble length %s\r\n", api.lorawan.ppl.set(8) ? "Success" : "Fail"); Serial.printf("Set P2P mode tx power %s\r\n", api.lorawan.ptp.set(22) ? "Success" : "Fail"); api.lorawan.registerPRecvCallback(recv_cb); api.lorawan.registerPSendCallback(send_cb); api.lorawan.registerPSendCADCallback(cad_cb); randomSeed(millis()); } void loop() { uint8_t payload[] = "payload"; int rxDelay = random(3000, 5000); // Receive P2P data every 10 seconds if(millis() - startTime >= 10*1000) { Serial.printf("P2P Rx start for %d millisSconds\r\n", rxDelay); startTime = millis(); Serial.printf("P2P set Rx mode %s\r\n",api.lorawan.precv(rxDelay) ? "Success" : "Fail"); delay(rxDelay); } else { Serial.printf("P2P send %s\r\n", api.lorawan.psend(sizeof(payload), payload)? "Success" : "Fail"); delay(1000); } }
bool precv | ( | uint32_t | timeout | ) |
timeout | the duration of P2P Rx mode in milli-seconds, except the following magic input:
|
TRUE | for entering P2P Rx mode success |
FALSE | for entering P2P Rx mode failure |
void setup() { Serial.begin(115200); Serial.println("P2P Start"); Serial.printf("Set Node device work mode %s\r\n", api.lorawan.nwm.set(0) ? "Success" : "Fail"); Serial.printf("Set P2P mode frequency %s\r\n", api.lorawan.pfreq.set(868000000) ? "Success" : "Fail"); Serial.printf("Set P2P mode spreading factor %s\r\n", api.lorawan.psf.set(12) ? "Success" : "Fail"); Serial.printf("Set P2P mode bandwidth %s\r\n", api.lorawan.pbw.set(125) ? "Success" : "Fail"); Serial.printf("Set P2P mode code rate %s\r\n", api.lorawan.pcr.set(0) ? "Success" : "Fail"); Serial.printf("Set P2P mode preamble length %s\r\n", api.lorawan.ppl.set(8) ? "Success" : "Fail"); Serial.printf("Set P2P mode tx power %s\r\n", api.lorawan.ptp.set(22) ? "Success" : "Fail"); } void loop() { Serial.printf("P2P set Rx mode %s\r\n",api.lorawan.precv(5000) ? "Success" : "Fail"); delay(6000); }
bool psend | ( | uint8_t | length, |
uint8_t * | payload | ||
) |
length | the length of the payload |
payload | the data send to the other device |
bool | Channel Activity Detection enable |
TRUE | for sending data success |
FALSE | for sending data failure |
void setup() { Serial.begin(115200); Serial.println("P2P Start"); Serial.printf("Set Node device work mode %s\r\n", api.lorawan.nwm.set(0) ? "Success" : "Fail"); Serial.printf("Set P2P mode frequency %s\r\n", api.lorawan.pfreq.set(868000000) ? "Success" : "Fail"); Serial.printf("Set P2P mode spreading factor %s\r\n", api.lorawan.psf.set(12) ? "Success" : "Fail"); Serial.printf("Set P2P mode bandwidth %s\r\n", api.lorawan.pbw.set(125) ? "Success" : "Fail"); Serial.printf("Set P2P mode code rate %s\r\n", api.lorawan.pcr.set(0) ? "Success" : "Fail"); Serial.printf("Set P2P mode preamble length %s\r\n", api.lorawan.ppl.set(8) ? "Success" : "Fail"); Serial.printf("Set P2P mode tx power %s\r\n", api.lorawan.ptp.set(22) ? "Success" : "Fail"); } void loop() { uint8_t payload[] = "payload"; Serial.printf("P2P send %s\r\n", api.lorawan.psend(sizeof(payload), payload)? "Success" : "Fail"); Serial.printf("P2P send %s\r\n", api.lorawan.psend(sizeof(payload), payload,true)? "Success" : "Fail"); delay(5000); }