Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MinimouseSrc/main.cpp
- Committer:
- fholin
- Date:
- 2017-12-18
- Revision:
- 1:eda561b01daf
- Parent:
- 0:2325d1d28df3
File content as of revision 1:eda561b01daf:
#include "mbed.h" #include "ApiFlash.h" #include "LoraMacDataStoreInFlash.h" #include "LoraWanProcess.h" #include "Define.h" #include "rtc_api.h" #include "ApiRtc.h" DigitalOut led( D13 ); struct sBackUpFlash BackUpFlash; static LoraWanObjet Lp( TX_RX_IT ); //@note set to board definition //#define CHECKFCNTDOWN 0 int main( ) { int i; led = 0; my_rtc_init ( ); pcf.baud( 115200 ); int UserPayloadSize = 14; uint8_t UserRxPayloadSize; uint8_t UserRxPayload [255]; uint8_t UserPayload[UserPayloadSize]; uint8_t UserFport = 3; uint8_t UserRxFport ; for ( i = 0; i < UserPayloadSize; i++ ){ UserPayload[i] = i + 20; } uint8_t AvailableRxPacket = NOLORARXPACKETAVAILABLE ; eLoraWan_Process_States LpState = LWPSTATE_IDLE; /************************************************/ /* Configure Adr Mode */ /************************************************/ Lp.SetDataRateStrategy( MOBILELONGRANGEADRMODE ); /************************************************/ /* Restore Context from Flash */ /* fcnt up is incemented by FLASH_UPDATE_PERIOD */ /************************************************/ Lp.RestoreContext ( ); while(1) { pcf.printf("\n\n\n\n "); LpState = Lp.SendPayload( UserFport, UserPayload, UserPayloadSize, UNCONFDATAUP ); led = 1; while ( LpState != LWPSTATE_IDLE ){ LpState = Lp.LoraWanProcess( &AvailableRxPacket ); wait_ms( 100 ); } if ( AvailableRxPacket == LORARXPACKETAVAILABLE ) { Lp.ReceivePayload( &UserRxFport, UserRxPayload, &UserRxPayloadSize ); pcf.printf("Receive an Applicative Downlink \n DATA[%d] = [ ",UserRxPayloadSize); for ( i = 0 ; i < UserRxPayloadSize ; i++){ pcf.printf( "0x%.2x ",UserRxPayload[i]); } pcf.printf("]\n"); } led = 0; wait_s( 5 ); } } /*************************************************if OTA *****************************************/ // if ( Lp.IsJoined( ) == ISJOINED ) { // LpState = Lp.SendPayload( UserFport, UserPayload, UserPayloadSize, UNCONFDATAUP ); // } else { // LpState = Lp.Join( ); // } /**************************************************************************************************/