![]() |
RUI3 (RAK Unified Interface 3) - RAK4631
|
Data Structures | |
class | RAKLorawan::rety |
class | RAKLorawan::cfm |
class | RAKLorawan::cfs |
class | RAKLorawan::njm |
class | RAKLorawan::njs |
Functions | |
bool | join () |
bool | send (uint8_t length, uint8_t *payload, uint8_t fport, bool confirm, uint8_t retry) |
bool | lpsend (uint8_t port, bool ack, uint8_t *payload, int length) |
bool | registerRecvCallback (service_lora_recv_cb callback) |
bool | registerJoinCallback (service_lora_join_cb callback) |
bool | registerSendCallback (service_lora_send_cb callback) |
bool join | ( | ) |
join_start | manually join network: 0 means stop to join network; 1 means start to join network. |
auto_join | automatically join network: 0 means stop automatically joining network; 1 means start automatically joining network. |
auto_join_period | the join attempt period. The acceptance values are 7 to 255 (in seconds). |
auto_join_cnt | the maximum number of join attempts. The acceptance values are 0 to 255 (in seconds). |
TRUE | for success |
FALSE | for join failure |
// OTAA Device EUI MSB uint8_t node_device_eui[8] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}; // OTAA Application EUI MSB uint8_t node_app_eui[8] = {0x0E, 0x0D, 0x0D, 0x01, 0x0E, 0x01, 0x02, 0x03}; // OTAA Application Key MSB uint8_t node_app_key[16] = {0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C}; void setup() { Serial.begin(115200); api.lorawan.appeui.set(node_app_eui, 8); api.lorawan.appkey.set(node_app_key, 16); api.lorawan.deui.set(node_device_eui, 8); api.lorawan.band.set(4); api.lorawan.njm.set(1); api.lorawan.join(); //wait for Join success while (api.lorawan.njs.get() == 0) { Serial.print("Waiting for Lorawan join..."); api.lorawan.join(); delay(10000); } } void loop() { }
bool send | ( | uint8_t | length, |
uint8_t * | payload, | ||
uint8_t | fport, | ||
bool | confirm, | ||
uint8_t | retry | ||
) |
length | the length of the payload |
payload | the date to uplink |
fport | allow 1 ~ 223 |
confirm | Override cfm setting to get confirm message from gateway (just for this time) |
retry | Override rety setting to retry if sending failed (just for this time) |
TRUE | for sending uplink success |
FALSE | for sending uplink |
// OTAA Device EUI MSB uint8_t node_device_eui[8] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}; // OTAA Application EUI MSB uint8_t node_app_eui[8] = {0x0E, 0x0D, 0x0D, 0x01, 0x0E, 0x01, 0x02, 0x03}; // OTAA Application Key MSB uint8_t node_app_key[16] = {0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C}; void setup() { Serial.begin(115200); api.lorawan.appeui.set(node_app_eui, 8); api.lorawan.appkey.set(node_app_key, 16); api.lorawan.deui.set(node_device_eui, 8); api.lorawan.band.set(4); api.lorawan.njm.set(1); api.lorawan.join(); //wait for Join success while (api.lorawan.njs.get() == 0) { Serial.print("Waiting for Lorawan join..."); api.lorawan.join(); delay(10000); } } void loop() { uint8_t payload[] = "example"; if (api.lorawan.send(sizeof(payload), payload, 129, true, 1)) { Serial.println("Send Success"); } else { Serial.println("Send fail"); } delay(5000); }
bool lpsend | ( | uint8_t | port, |
bool | ack, | ||
uint8_t * | payload, | ||
int | length | ||
) |
port | application port to be transmitted |
ack | indicate this is a confirmed message or not |
payload | the date you want to send |
length | the length of the paylaod |
TRUE | for sending data success |
FALSE | for sending data failure |
// OTAA Device EUI MSB uint8_t node_device_eui[8] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}; // OTAA Application EUI MSB uint8_t node_app_eui[8] = {0x0E, 0x0D, 0x0D, 0x01, 0x0E, 0x01, 0x02, 0x03}; // OTAA Application Key MSB uint8_t node_app_key[16] = {0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C}; void setup() { Serial.begin(115200); api.lorawan.appeui.set(node_app_eui, 8); api.lorawan.appkey.set(node_app_key, 16); api.lorawan.deui.set(node_device_eui, 8); api.lorawan.band.set(4); api.lorawan.njm.set(1); api.lorawan.join(); //wait for Join success while (api.lorawan.njs.get() == 0) { Serial.print("Waiting for Lorawan join..."); api.lorawan.join(); delay(10000); } } void loop() { uint8_t payload[] = "12345678901234567890"; if (api.lorawan.lpsend(129, 1, payload, sizeof(payload))) { Serial.println("Send Success"); } else { Serial.println("Send fail"); } delay(5000); }
bool registerRecvCallback | ( | service_lora_recv_cb | callback | ) |
The | callgback function |
TRUE | for setting callback function success |
FALSE | for setting callback function failure |
void recv_cb(SERVICE_LORA_RECEIVE_T *data) { Serial.println("Something received!"); for (int i = 0 ; i < data->BufferSize ; i++) { Serial.printf("%x", data->Buffer[i]); } Serial.print("\r\n"); } void join_cb(int32_t status) { Serial.printf("Join status: %d\r\n", status); } void send_cb(int32_t status) { Serial.printf("Send status: %d\r\n", status); } // OTAA Device EUI MSB uint8_t node_device_eui[8] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}; // OTAA Application EUI MSB uint8_t node_app_eui[8] = {0x0E, 0x0D, 0x0D, 0x01, 0x0E, 0x01, 0x02, 0x03}; // OTAA Application Key MSB uint8_t node_app_key[16] = {0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C}; void setup() { Serial.begin(115200); api.lorawan.appeui.set(node_app_eui, 8); api.lorawan.appkey.set(node_app_key, 16); api.lorawan.deui.set(node_device_eui, 8); api.lorawan.band.set(4); api.lorawan.njm.set(1); api.lorawan.join(); api.lorawan.registerRecvCallback(recv_cb); api.lorawan.registerJoinCallback(join_cb); api.lorawan.registerSendCallback(send_cb); //wait for Join success while (api.lorawan.njs.get() == 0) { Serial.print("Waiting for Lorawan join..."); api.lorawan.join(); delay(10000); } } void loop() { uint8_t payload[] = "example"; if (api.lorawan.send(sizeof(payload), payload, 129, true, 1)) { Serial.println("Send Success"); } else { Serial.println("Send fail"); } delay(5000); }
bool registerJoinCallback | ( | service_lora_join_cb | callback | ) |
The | callgback function |
TRUE | for setting callback function success |
FALSE | for setting callback function failure |
void recv_cb(SERVICE_LORA_RECEIVE_T *data) { Serial.println("Something received!"); for (int i = 0 ; i < data->BufferSize ; i++) { Serial.printf("%x", data->Buffer[i]); } Serial.print("\r\n"); } void join_cb(int32_t status) { Serial.printf("Join status: %d\r\n", status); } void send_cb(int32_t status) { Serial.printf("Send status: %d\r\n", status); } // OTAA Device EUI MSB uint8_t node_device_eui[8] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}; // OTAA Application EUI MSB uint8_t node_app_eui[8] = {0x0E, 0x0D, 0x0D, 0x01, 0x0E, 0x01, 0x02, 0x03}; // OTAA Application Key MSB uint8_t node_app_key[16] = {0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C}; void setup() { Serial.begin(115200); api.lorawan.appeui.set(node_app_eui, 8); api.lorawan.appkey.set(node_app_key, 16); api.lorawan.deui.set(node_device_eui, 8); api.lorawan.band.set(4); api.lorawan.njm.set(1); api.lorawan.join(); api.lorawan.registerRecvCallback(recv_cb); api.lorawan.registerJoinCallback(join_cb); api.lorawan.registerSendCallback(send_cb); //wait for Join success while (api.lorawan.njs.get() == 0) { Serial.print("Waiting for Lorawan join..."); api.lorawan.join(); delay(10000); } } void loop() { uint8_t payload[] = "example"; if (api.lorawan.send(sizeof(payload), payload, 129, true, 1)) { Serial.println("Send Success"); } else { Serial.println("Send fail"); } delay(5000); }
bool registerSendCallback | ( | service_lora_send_cb | callback | ) |
The | callback function |
TRUE | for setting callback function success |
FALSE | for setting callback function failure |
void recv_cb(SERVICE_LORA_RECEIVE_T *data) { Serial.println("Something received!"); for (int i = 0 ; i < data->BufferSize ; i++) { Serial.printf("%x", data->Buffer[i]); } Serial.print("\r\n"); } void join_cb(int32_t status) { Serial.printf("Join status: %d\r\n", status); } void send_cb(int32_t status) { Serial.printf("Send status: %d\r\n", status); } // OTAA Device EUI MSB uint8_t node_device_eui[8] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}; // OTAA Application EUI MSB uint8_t node_app_eui[8] = {0x0E, 0x0D, 0x0D, 0x01, 0x0E, 0x01, 0x02, 0x03}; // OTAA Application Key MSB uint8_t node_app_key[16] = {0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C}; void setup() { Serial.begin(115200); api.lorawan.appeui.set(node_app_eui, 8); api.lorawan.appkey.set(node_app_key, 16); api.lorawan.deui.set(node_device_eui, 8); api.lorawan.band.set(4); api.lorawan.njm.set(1); api.lorawan.join(); api.lorawan.registerRecvCallback(recv_cb); api.lorawan.registerJoinCallback(join_cb); api.lorawan.registerSendCallback(send_cb); //wait for Join success while (api.lorawan.njs.get() == 0) { Serial.print("Waiting for Lorawan join..."); api.lorawan.join(); delay(10000); } } void loop() { uint8_t payload[] = "example"; if (api.lorawan.send(sizeof(payload), payload, 129, true, 1)) { Serial.println("Send Success"); } else { Serial.println("Send fail"); } delay(5000); }