Skip to content

Instantly share code, notes, and snippets.

@sabas1080
Last active November 2, 2017 01:58
Show Gist options
  • Save sabas1080/e186f183822b2abb8465d11972c6e838 to your computer and use it in GitHub Desktop.
Save sabas1080/e186f183822b2abb8465d11972c6e838 to your computer and use it in GitHub Desktop.
// http://ww1.microchip.com/downloads/en/DeviceDoc/40001864B.pdf
int8_t nwkSKey[16] = {0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB,
0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C};
uint8_t appSKey[16] = {0x3C, 0x8F, 0x26, 0x27, 0x39, 0xBF, 0xE3, 0xB7, 0xBC,
0x08, 0x26, 0x99, 0x1A, 0xD0, 0x50, 0x4D};
uint32_t devAddr = 0x1100000F;
uint8_t endDeviceJoinedFlag = false;
void RxData(uint8_t* pData, uint8_t dataLength, OpStatus_t status)
{
printf("El valor de *puntero es: %d. \n",*pData);
printf("La direccion de memoria de *puntero es: %p",pData);
}
void RxJoinResponse(bool status)
{
endDeviceJoinedFlag = true;
}
void main(void)
{
// Initialize the device
SYSTEM_Initialize();
EUSART1_Initialize();
// If using interrupts in PIC18 High/Low Priority Mode you need to enable the Global High and Low Interrupts
// If using interrupts in PIC Mid-Range Compatibility Mode you need to enable the Global and Peripheral Interrupts
// Use the following macros to:
// Enable high priority global interrupts
//INTERRUPT_GlobalInterruptHighEnable();
// Enable low priority global interrupts.
//INTERRUPT_GlobalInterruptLowEnable();
// Disable high priority global interrupts
//INTERRUPT_GlobalInterruptHighDisable();
// Disable low priority global interrupts.
//INTERRUPT_GlobalInterruptLowDisable();
// Enable the Global Interrupts
INTERRUPT_GlobalInterruptEnable();
// Disable the Global Interrupts
//INTERRUPT_GlobalInterruptDisable();
// Enable the Peripheral Interrupts
INTERRUPT_PeripheralInterruptEnable();
// Disable the Peripheral Interrupts
//INTERRUPT_PeripheralInterruptDisable();
LORAWAN_Init(RxData, RxJoinResponse);
LORAWAN_SetNetworkSessionKey(nwkSKey);
LORAWAN_SetApplicationSessionKey(appSKey);
LORAWAN_SetDeviceAddress(devAddr);
LORAWAN_Join(ABP);
while(endDeviceJoinedFlag == false)
{
LORAWAN_Mainloop();
}
while (1)
{
// Stack management
LORAWAN_Mainloop();
// All other function calls of the user-defined
// application must be made here
LORAWAN_Send(UNCNF, 2, "LoRa", 4);
}
}
/**
End of File
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment