(1) DON’T do while loops in a callback. You are disturbing the LORaWAN stack handling
while (api.ble.uart.available()) {
receivedChar = api.ble.uart.read();
if (receivedChar == '\n') {
break;
}
receivedData += receivedChar;
}
(2) status can have the following information:
RAK_LORAMAC_STATUS_OK = 0, ///Service performed successfully
RAK_LORAMAC_STATUS_ERROR, ///An error occurred during the execution of the service
RAK_LORAMAC_STATUS_TX_TIMEOUT, ///A Tx timeout occurred
RAK_LORAMAC_STATUS_RX1_TIMEOUT, ///An Rx timeout occurred on receive window 1
RAK_LORAMAC_STATUS_RX2_TIMEOUT, ///An Rx timeout occurred on receive window 2
RAK_LORAMAC_STATUS_RX1_ERROR, ///An Rx error occurred on receive window 1
RAK_LORAMAC_STATUS_RX2_ERROR, ///An Rx error occurred on receive window 2
RAK_LORAMAC_STATUS_JOIN_FAIL, ///An error occurred in the join procedure
RAK_LORAMAC_STATUS_DOWNLINK_REPEATED, ///A frame with an invalid downlink counter was received. The downlink counter of the frame was equal to the local copy of the downlink counter of the node.
RAK_LORAMAC_STATUS_TX_DR_PAYLOAD_SIZE_ERROR, ///The MAC could not retransmit a frame since the MAC decreased the datarate. The payload size is not applicable for the datarate.
RAK_LORAMAC_STATUS_DOWNLINK_TOO_MANY_FRAMES_LOSS, ///The node has lost MAX_FCNT_GAP or more frames.
RAK_LORAMAC_STATUS_ADDRESS_FAIL, ///An address error occurred
RAK_LORAMAC_STATUS_MIC_FAIL, ///Message integrity check failure
RAK_LORAMAC_STATUS_MULTICAST_FAIL, ///Multicast error occurred
RAK_LORAMAC_STATUS_BEACON_LOCKED, ///Beacon locked
RAK_LORAMAC_STATUS_BEACON_LOST, ///Beacon lost
RAK_LORAMAC_STATUS_BEACON_NOT_FOUND, ///Beacon not found
On API level you will get RAK_LORAMAC_STATUS_RX2_TIMEOUT if no ACK was received.
I solved my problem by using this API api.lorawan.cfs.get() . but now I have one more question.
I tried to use interrupt to read the data that is being read serially, but it doesn’t work.
Does RAK11720 support void serialEvent() function? or is there another way?
I want to use interrupt to read the data coming serially from another microcontroller every 5 seconds.
Is it possible to use UART1 and receive data via interrupts?
UART1 without AT Command
api.ble.registerCallback(Event event,BLE_HANDLER callback)
Callback function is type void ble_connect(void)
You need to register callbacks for the two events separate, one with event BLE_CONNECTED and one with event BLE_DISCONNECTED