Skip to content

Commit

Permalink
Optimized code structure, naming in Arduino style.
Browse files Browse the repository at this point in the history
  • Loading branch information
Heltec-Aaron-Lee committed Feb 11, 2020
1 parent 2d4e2d8 commit 68c0714
Show file tree
Hide file tree
Showing 94 changed files with 1,585 additions and 1,603 deletions.
2 changes: 1 addition & 1 deletion cores/asr650x/board/src/asr_board.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ static const double TWO52[2]={



void BoardInitMcu( void )
void boardInitMcu( void )
{
SpiInit();
Asr_Timer_Init();
Expand Down
18 changes: 9 additions & 9 deletions cores/asr650x/cores/AT_Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ enum eDeviceState_Lora
};


void Enable_AT(void);
void enableAt(void);
void getDevParam(void);
void printDevParam(void);
void SaveNetInfo(uint8_t *joinpayload, uint16_t size);
void SaveUpCnt(void);
void SaveDownCnt(void);
void GetNetInfo(void);
void SaveDr(void);
bool CheckNetInfo(void);
void NetInfoDisable(void);
extern bool AT_user_check(char * cmd, char * content);
void saveNetInfo(uint8_t *joinpayload, uint16_t size);
void saveUpCnt(void);
void saveDownCnt(void);
void getNetInfo(void);
void saveDr(void);
bool checkNetInfo(void);
void netInfoDisable(void);
extern bool checkUserAt(char * cmd, char * content);



Expand Down
2 changes: 0 additions & 2 deletions cores/asr650x/kernel/protocols/lorawan/README.md

This file was deleted.

54 changes: 0 additions & 54 deletions cores/asr650x/kernel/protocols/lorawan/lorawan.mk

This file was deleted.

File renamed without changes.
44 changes: 44 additions & 0 deletions cores/asr650x/loramac/mac/Commissioning.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*!
* \file Commissioning.h
*
* \brief End device commissioning parameters
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2017 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*
* \author Gregory Cristian ( Semtech )
*/
#ifndef __LORA_COMMISSIONING_H__
#define __LORA_COMMISSIONING_H__

#include "LoRaMac.h"

/*!
* User application data buffer size
*/
#define LORAWAN_APP_DATA_MAX_SIZE 128 //if use AT mode, don't modify this value or may run dead

/*!
* Indicates if the end-device is to be connected to a private or public network
*/
#define LORAWAN_PUBLIC_NETWORK true

/*!
* Current network ID
*/
#define LORAWAN_NETWORK_ID ( uint32_t )0


#endif // __LORA_COMMISSIONING_H__
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ static void OpenContinuousRx2Window( void );

static void OnRadioTxDone( void )
{
DIO_PRINTF("Event : Tx Done\r\n");
GetPhyParams_t getPhy;
PhyParam_t phyParam;
SetBandTxDoneParams_t txDone;
Expand Down Expand Up @@ -772,7 +773,7 @@ static void OnRadioTxDone( void )
#endif

#if (LoraWan_RGB==1)
RGB_OFF();
turnOffRGB();
#endif

}
Expand All @@ -795,6 +796,7 @@ static void PrepareRxDoneAbort( void )

void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr )
{
DIO_PRINTF("Event : Rx Done\r\n");
uint8_t * temp = payload;
LoRaMacHeader_t macHdr;
LoRaMacFrameCtrl_t fCtrl;
Expand Down Expand Up @@ -932,7 +934,7 @@ void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr )

LoRaMacConfirmQueueSetStatus( LORAMAC_EVENT_INFO_STATUS_OK, MLME_JOIN );
IsLoRaMacNetworkJoined = true;
SaveNetInfo(temp, size);
saveNetInfo(temp, size);
//Joined save its DR using LoRaMacParams.ChannelsDatarate, if set it will be default
// LoRaMacParams.ChannelsDatarate = LoRaMacParamsDefaults.ChannelsDatarate;
} else {
Expand Down Expand Up @@ -1088,7 +1090,7 @@ void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr )
}
DownLinkCounter = downLinkCounter;
if(DownLinkCounter%15000==0){
SaveDownCnt();
saveDownCnt();
}
}

Expand Down Expand Up @@ -1213,8 +1215,9 @@ void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr )
static void OnRadioTxTimeout( void )
{
#if (LoraWan_RGB==1)
RGB_OFF();
turnOffRGB();
#endif
DIO_PRINTF("Event : Tx Timeout\r\n");

if( LoRaMacDeviceClass != CLASS_C )
{
Expand All @@ -1235,6 +1238,7 @@ static void OnRadioTxTimeout( void )

static void OnRadioRxError( void )
{
DIO_PRINTF("Event : Rx Error\r\n");
bool classBRx = false;

if( LoRaMacDeviceClass != CLASS_C )
Expand Down Expand Up @@ -1307,8 +1311,10 @@ static void OnRadioRxError( void )
static void OnRadioRxTimeout( void )
{
#if (LoraWan_RGB==1)
RGB_OFF();
turnOffRGB();
#endif
DIO_PRINTF("Event : Rx Timeout\r\n");

bool classBRx = false;

if( LoRaMacDeviceClass != CLASS_C )
Expand Down Expand Up @@ -1707,7 +1713,7 @@ static void OnRxWindow1TimerEvent( void )
//printf("w1 dr:%d\r\n",McpsIndication.RxDatarate);
RxWindowSetup( RxWindow1Config.RxContinuous, LoRaMacParams.MaxRxWindow );
#if(LoraWan_RGB==1)
RGB_ON(COLOR_RXWINDOW1,0);
turnOnRGB(COLOR_RXWINDOW1,0);
#endif
}

Expand All @@ -1733,7 +1739,7 @@ static void OnRxWindow2TimerEvent( void )
RxSlot = RX_SLOT_WIN_2;
}
#if(LoraWan_RGB==1)
RGB_ON(COLOR_RXWINDOW2,0);
turnOnRGB(COLOR_RXWINDOW2,0);
#endif

}
Expand Down Expand Up @@ -2843,7 +2849,7 @@ LoRaMacStatus_t SendFrameOnChannel( uint8_t channel )
}
// Send now
#if (LoraWan_RGB==1)
RGB_ON(COLOR_SEND,0);
turnOnRGB(COLOR_SEND,0);
#endif
Radio.Send( LoRaMacBuffer, LoRaMacBufferPktLen );

Expand Down Expand Up @@ -3672,8 +3678,7 @@ LoRaMacStatus_t LoRaMacMlmeRequest( MlmeReq_t *mlmeRequest )
case MLME_JOIN: {
if ( ( mlmeRequest->Req.Join.DevEui == NULL ) ||
( mlmeRequest->Req.Join.AppEui == NULL ) ||
( mlmeRequest->Req.Join.AppKey == NULL ) ||
( mlmeRequest->Req.Join.NbTrials == 0 ) ) {
( mlmeRequest->Req.Join.AppKey == NULL )) {
return LORAMAC_STATUS_PARAMETER_INVALID;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2449,8 +2449,8 @@ LoRaMacStatus_t LoRaMacMlmeRequest( MlmeReq_t *mlmeRequest );
*/
LoRaMacStatus_t LoRaMacMcpsRequest( McpsReq_t *mcpsRequest );

extern void RGB_ON(uint32_t color,uint32_t time);
extern void RGB_OFF(void);
extern void turnOnRGB(uint32_t color,uint32_t time);
extern void turnOffRGB(void);


#ifdef __cplusplus
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ bool RegionAS923RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate )
}

Radio.SetMaxPayloadLength( modem, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD );
DBG_PRINTF("RX on freq %u Hz at DR %d\n\r", (unsigned int)frequency, dr);
FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr);

*datarate = (uint8_t) dr;
return true;
Expand Down Expand Up @@ -693,7 +693,7 @@ bool RegionAS923TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
modem = MODEM_LORA;
Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 3e3 );
}
DBG_PRINTF("TX on freq %u Hz at DR %d\n\r", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate);
FREQ_PRINTF("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate);
// Setup maximum payload lenght of the radio driver
Radio.SetMaxPayloadLength( modem, txConfig->PktLen );
// Get the time-on-air of the next tx frame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ bool RegionAU915RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate )
maxPayload = MaxPayloadOfDatarateAU915[dr];
}
Radio.SetMaxPayloadLength( MODEM_LORA, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD );
// printf("RX on freq %u Hz at DR %d\n\r", (unsigned int)frequency, dr);
FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr);

*datarate = (uint8_t) dr;
return true;
Expand All @@ -592,7 +592,7 @@ bool RegionAU915TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime

Radio.SetMaxPayloadLength( MODEM_LORA, txConfig->PktLen );
Radio.SetTxConfig( MODEM_LORA, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 3e3 );
// printf("TX on freq %u Hz at DR %d\n\r", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate);
FREQ_PRINTF("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate);

*txTimeOnAir = Radio.TimeOnAir( MODEM_LORA, txConfig->PktLen );
*txPower = txPowerLimited;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static uint8_t CountNbOfEnabledChannels( uint8_t datarate, uint16_t* channelsMas
}
}
}
//printf("nbEnabledChannels: %d ",nbEnabledChannels);

*delayTx = delayTransmission;
return nbEnabledChannels;
}
Expand Down Expand Up @@ -529,6 +529,7 @@ bool RegionCN470RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate )
maxPayload = MaxPayloadOfDatarateCN470[dr];
}
Radio.SetMaxPayloadLength( MODEM_LORA, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD );
FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr);

*datarate = (uint8_t) dr;
return true;
Expand All @@ -547,6 +548,8 @@ bool RegionCN470TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
Radio.SetChannel( Channels[txConfig->Channel].Frequency );

Radio.SetTxConfig( MODEM_LORA, phyTxPower, 0, 0, phyDr, 1, 8, false, true, 0, 0, false, 3000 );
FREQ_PRINTF("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate);

// Setup maximum payload lenght of the radio driver
Radio.SetMaxPayloadLength( MODEM_LORA, txConfig->PktLen );
// Get the time-on-air of the next tx frame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ bool RegionCN779RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate )
maxPayload = MaxPayloadOfDatarateCN779[dr];
}
Radio.SetMaxPayloadLength( modem, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD );
DBG_PRINTF("RX on freq %u Hz at DR %d\n\r", (unsigned int)frequency, dr);
FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr);

*datarate = (uint8_t) dr;
return true;
Expand Down Expand Up @@ -634,7 +634,7 @@ bool RegionCN779TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
modem = MODEM_LORA;
Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 3e3 );
}
DBG_PRINTF("TX on freq %u Hz at DR %d\n\r", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate);
FREQ_PRINTF("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate);
// Setup maximum payload lenght of the radio driver
Radio.SetMaxPayloadLength( modem, txConfig->PktLen );
// Get the time-on-air of the next tx frame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ bool RegionEU433RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate )
maxPayload = MaxPayloadOfDatarateEU433[dr];
}
Radio.SetMaxPayloadLength( modem, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD );
DBG_PRINTF("RX on freq %u Hz at DR %d\n\r", (unsigned int)frequency, dr);
FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr);

*datarate = (uint8_t) dr;
return true;
Expand Down Expand Up @@ -634,7 +634,7 @@ bool RegionEU433TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
modem = MODEM_LORA;
Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 3e3 );
}
DBG_PRINTF("TX on freq %u Hz at DR %d\n\r", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate);
FREQ_PRINTF("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate);
// Setup maximum payload lenght of the radio driver
Radio.SetMaxPayloadLength( modem, txConfig->PktLen );
// Get the time-on-air of the next tx frame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ bool RegionEU868RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate )
}

Radio.SetMaxPayloadLength( modem, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD );
// printf("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr);
FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr);

*datarate = (uint8_t) dr;
return true;
Expand Down Expand Up @@ -664,7 +664,7 @@ bool RegionEU868TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
modem = MODEM_LORA;
Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 3000 );
}
// printf("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate);
FREQ_PRINTF("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate);
// Setup maximum payload lenght of the radio driver
Radio.SetMaxPayloadLength( modem, txConfig->PktLen );
// Get the time-on-air of the next tx frame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ bool RegionIN865RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate )
maxPayload = MaxPayloadOfDatarateIN865[dr];
}
Radio.SetMaxPayloadLength( modem, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD );
DBG_PRINTF("RX on freq %u Hz at DR %d\n\r", (unsigned int)frequency, dr);
FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr);

*datarate = (uint8_t) dr;
return true;
Expand Down Expand Up @@ -638,7 +638,7 @@ bool RegionIN865TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
modem = MODEM_LORA;
Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 3e3 );
}
DBG_PRINTF("TX on freq %u Hz at DR %d\n\r", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate);
FREQ_PRINTF("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate);
// Setup maximum payload lenght of the radio driver
Radio.SetMaxPayloadLength( modem, txConfig->PktLen );
// Get the time-on-air of the next tx frame
Expand Down
Loading

0 comments on commit 68c0714

Please sign in to comment.