/*
Programa para trabalhar com struct
*/
typedef struct{
uint8_t *NwkSKey;
uint8_t *AppSKey;
uint8_t *DevAddr;
unsigned int *Frame_Counter;
} sLoRa_Session;
void setup() {
Serial.begin(115200);
uint8_t NwkSKey[16] = {0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C};
uint8_t AppSKey[16] = {0xB2, 0xE7, 0x51, 0x61, 0x82, 0xEA, 0x2D, 0x6A, 0xBA, 0x7F, 0x51, 0x88, 0x90, 0xFC, 0xF4, 0xC3};
uint8_t Address_Tx[4] = {0x00, 0x01, 0x02, 0x03};
unsigned int Frame_Counter_Tx = 1234;
sLoRa_Session Session_Data = {NwkSKey, AppSKey, Address_Tx, &Frame_Counter_Tx};
Serial.print("NwkSKey: ");
print_array(Session_Data.NwkSKey, 16);
Serial.print("AppSKey: ");
print_array(Session_Data.AppSKey, 16);
Serial.print("Address_Tx: ");
print_array(Session_Data.DevAddr, 4);
Serial.print("Frame_Counter_Tx: ");
//char szStr[20];
//sprintf(szStr, "%lu", *Session_Data.Frame_Counter);
//Serial.println(szStr);
Serial.println(*Session_Data.Frame_Counter, DEC);
}
void loop() {
}
//Imprime array
void print_array(uint8_t vetor[], uint8_t n){
for(byte i=0; i<n; i++){
Serial.print(vetor[i] < 16 ? "0" : "");
Serial.print(vetor[i], HEX);
Serial.print(" ");
}
Serial.println("");
}