- I use the node B-L072Z-LRWAN1 with " I-CUBE-LRWAN" software.
I created my own lorawan network thanks to the project loraserver.io, all of lora server and lora app server are coded by go language, so Go by default encodes a byte array to base64 when encoding an object to JSON.
-
when i use the "AT slave exemple", i can receive the right data from my nod to my php page that decode the JSON array and then i use this function to decode the base64 :
$payload = file_get_contents('php://input'); $var = json_decode($payload,true); . . . $data64 = $var['data']; $data = base64_decode($data64); // decode function
But when i use the " End_Node exemple " , i can't decode the data with my php function that i had present, i have this result :
I noticed that in the" end-node program" there is a function that does this before sending the data :
#define LORAWAN_APP_DATA_BUFF_SIZE 64
static uint8_t AppDataBuff[LORAWAN_APP_DATA_BUFF_SIZE];
lora_AppData_t AppData={ AppDataBuff, 0 ,0 };
temperature = 20; /* in °C * 100 */
pressure = 30; /* in hPa / 10 */
humidity = 40; /* in %*10 */
uint32_t i = 0;
AppData.Buff[i++] = AppLedStateOn;
AppData.Buff[i++] = ( pressure >> 8 ) & 0xFF;
AppData.Buff[i++] = pressure & 0xFF;
AppData.Buff[i++] = ( temperature >> 8 ) & 0xFF;
AppData.Buff[i++] = temperature & 0xFF;
AppData.Buff[i++] = ( humidity >> 8 ) & 0xFF;
AppData.Buff[i++] = humidity & 0xFF;
AppData.BuffSize = i;
LORA_send( &AppData, LORAWAN_DEFAULT_CONFIRM_MSG_STATE);
this topic isfor those who know how data is encoded in both version of " I-CUBE-LRWAN"
Thanks for your help :).