Skip to content

Commit 68c0714

Browse files
Optimized code structure, naming in Arduino style.
1 parent 2d4e2d8 commit 68c0714

File tree

94 files changed

+1585
-1603
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1585
-1603
lines changed

cores/asr650x/board/src/asr_board.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ static const double TWO52[2]={
458458

459459

460460

461-
void BoardInitMcu( void )
461+
void boardInitMcu( void )
462462
{
463463
SpiInit();
464464
Asr_Timer_Init();

cores/asr650x/cores/AT_Command.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ enum eDeviceState_Lora
3030
};
3131

3232

33-
void Enable_AT(void);
33+
void enableAt(void);
3434
void getDevParam(void);
3535
void printDevParam(void);
36-
void SaveNetInfo(uint8_t *joinpayload, uint16_t size);
37-
void SaveUpCnt(void);
38-
void SaveDownCnt(void);
39-
void GetNetInfo(void);
40-
void SaveDr(void);
41-
bool CheckNetInfo(void);
42-
void NetInfoDisable(void);
43-
extern bool AT_user_check(char * cmd, char * content);
36+
void saveNetInfo(uint8_t *joinpayload, uint16_t size);
37+
void saveUpCnt(void);
38+
void saveDownCnt(void);
39+
void getNetInfo(void);
40+
void saveDr(void);
41+
bool checkNetInfo(void);
42+
void netInfoDisable(void);
43+
extern bool checkUserAt(char * cmd, char * content);
4444

4545

4646

cores/asr650x/kernel/protocols/lorawan/README.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

cores/asr650x/kernel/protocols/lorawan/lorawan.mk

Lines changed: 0 additions & 54 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*!
2+
* \file Commissioning.h
3+
*
4+
* \brief End device commissioning parameters
5+
*
6+
* \copyright Revised BSD License, see section \ref LICENSE.
7+
*
8+
* \code
9+
* ______ _
10+
* / _____) _ | |
11+
* ( (____ _____ ____ _| |_ _____ ____| |__
12+
* \____ \| ___ | (_ _) ___ |/ ___) _ \
13+
* _____) ) ____| | | || |_| ____( (___| | | |
14+
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
15+
* (C)2013-2017 Semtech
16+
*
17+
* \endcode
18+
*
19+
* \author Miguel Luis ( Semtech )
20+
*
21+
* \author Gregory Cristian ( Semtech )
22+
*/
23+
#ifndef __LORA_COMMISSIONING_H__
24+
#define __LORA_COMMISSIONING_H__
25+
26+
#include "LoRaMac.h"
27+
28+
/*!
29+
* User application data buffer size
30+
*/
31+
#define LORAWAN_APP_DATA_MAX_SIZE 128 //if use AT mode, don't modify this value or may run dead
32+
33+
/*!
34+
* Indicates if the end-device is to be connected to a private or public network
35+
*/
36+
#define LORAWAN_PUBLIC_NETWORK true
37+
38+
/*!
39+
* Current network ID
40+
*/
41+
#define LORAWAN_NETWORK_ID ( uint32_t )0
42+
43+
44+
#endif // __LORA_COMMISSIONING_H__

cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMac.c renamed to cores/asr650x/loramac/mac/LoRaMac.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,7 @@ static void OpenContinuousRx2Window( void );
699699

700700
static void OnRadioTxDone( void )
701701
{
702+
DIO_PRINTF("Event : Tx Done\r\n");
702703
GetPhyParams_t getPhy;
703704
PhyParam_t phyParam;
704705
SetBandTxDoneParams_t txDone;
@@ -772,7 +773,7 @@ static void OnRadioTxDone( void )
772773
#endif
773774

774775
#if (LoraWan_RGB==1)
775-
RGB_OFF();
776+
turnOffRGB();
776777
#endif
777778

778779
}
@@ -795,6 +796,7 @@ static void PrepareRxDoneAbort( void )
795796

796797
void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr )
797798
{
799+
DIO_PRINTF("Event : Rx Done\r\n");
798800
uint8_t * temp = payload;
799801
LoRaMacHeader_t macHdr;
800802
LoRaMacFrameCtrl_t fCtrl;
@@ -932,7 +934,7 @@ void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr )
932934

933935
LoRaMacConfirmQueueSetStatus( LORAMAC_EVENT_INFO_STATUS_OK, MLME_JOIN );
934936
IsLoRaMacNetworkJoined = true;
935-
SaveNetInfo(temp, size);
937+
saveNetInfo(temp, size);
936938
//Joined save its DR using LoRaMacParams.ChannelsDatarate, if set it will be default
937939
// LoRaMacParams.ChannelsDatarate = LoRaMacParamsDefaults.ChannelsDatarate;
938940
} else {
@@ -1088,7 +1090,7 @@ void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr )
10881090
}
10891091
DownLinkCounter = downLinkCounter;
10901092
if(DownLinkCounter%15000==0){
1091-
SaveDownCnt();
1093+
saveDownCnt();
10921094
}
10931095
}
10941096

@@ -1213,8 +1215,9 @@ void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr )
12131215
static void OnRadioTxTimeout( void )
12141216
{
12151217
#if (LoraWan_RGB==1)
1216-
RGB_OFF();
1218+
turnOffRGB();
12171219
#endif
1220+
DIO_PRINTF("Event : Tx Timeout\r\n");
12181221

12191222
if( LoRaMacDeviceClass != CLASS_C )
12201223
{
@@ -1235,6 +1238,7 @@ static void OnRadioTxTimeout( void )
12351238

12361239
static void OnRadioRxError( void )
12371240
{
1241+
DIO_PRINTF("Event : Rx Error\r\n");
12381242
bool classBRx = false;
12391243

12401244
if( LoRaMacDeviceClass != CLASS_C )
@@ -1307,8 +1311,10 @@ static void OnRadioRxError( void )
13071311
static void OnRadioRxTimeout( void )
13081312
{
13091313
#if (LoraWan_RGB==1)
1310-
RGB_OFF();
1314+
turnOffRGB();
13111315
#endif
1316+
DIO_PRINTF("Event : Rx Timeout\r\n");
1317+
13121318
bool classBRx = false;
13131319

13141320
if( LoRaMacDeviceClass != CLASS_C )
@@ -1707,7 +1713,7 @@ static void OnRxWindow1TimerEvent( void )
17071713
//printf("w1 dr:%d\r\n",McpsIndication.RxDatarate);
17081714
RxWindowSetup( RxWindow1Config.RxContinuous, LoRaMacParams.MaxRxWindow );
17091715
#if(LoraWan_RGB==1)
1710-
RGB_ON(COLOR_RXWINDOW1,0);
1716+
turnOnRGB(COLOR_RXWINDOW1,0);
17111717
#endif
17121718
}
17131719

@@ -1733,7 +1739,7 @@ static void OnRxWindow2TimerEvent( void )
17331739
RxSlot = RX_SLOT_WIN_2;
17341740
}
17351741
#if(LoraWan_RGB==1)
1736-
RGB_ON(COLOR_RXWINDOW2,0);
1742+
turnOnRGB(COLOR_RXWINDOW2,0);
17371743
#endif
17381744

17391745
}
@@ -2843,7 +2849,7 @@ LoRaMacStatus_t SendFrameOnChannel( uint8_t channel )
28432849
}
28442850
// Send now
28452851
#if (LoraWan_RGB==1)
2846-
RGB_ON(COLOR_SEND,0);
2852+
turnOnRGB(COLOR_SEND,0);
28472853
#endif
28482854
Radio.Send( LoRaMacBuffer, LoRaMacBufferPktLen );
28492855

@@ -3672,8 +3678,7 @@ LoRaMacStatus_t LoRaMacMlmeRequest( MlmeReq_t *mlmeRequest )
36723678
case MLME_JOIN: {
36733679
if ( ( mlmeRequest->Req.Join.DevEui == NULL ) ||
36743680
( mlmeRequest->Req.Join.AppEui == NULL ) ||
3675-
( mlmeRequest->Req.Join.AppKey == NULL ) ||
3676-
( mlmeRequest->Req.Join.NbTrials == 0 ) ) {
3681+
( mlmeRequest->Req.Join.AppKey == NULL )) {
36773682
return LORAMAC_STATUS_PARAMETER_INVALID;
36783683
}
36793684

cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMac.h renamed to cores/asr650x/loramac/mac/LoRaMac.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2449,8 +2449,8 @@ LoRaMacStatus_t LoRaMacMlmeRequest( MlmeReq_t *mlmeRequest );
24492449
*/
24502450
LoRaMacStatus_t LoRaMacMcpsRequest( McpsReq_t *mcpsRequest );
24512451

2452-
extern void RGB_ON(uint32_t color,uint32_t time);
2453-
extern void RGB_OFF(void);
2452+
extern void turnOnRGB(uint32_t color,uint32_t time);
2453+
extern void turnOffRGB(void);
24542454

24552455

24562456
#ifdef __cplusplus

cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionAS923.c renamed to cores/asr650x/loramac/mac/region/RegionAS923.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ bool RegionAS923RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate )
663663
}
664664

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

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

cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionAU915.c renamed to cores/asr650x/loramac/mac/region/RegionAU915.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ bool RegionAU915RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate )
572572
maxPayload = MaxPayloadOfDatarateAU915[dr];
573573
}
574574
Radio.SetMaxPayloadLength( MODEM_LORA, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD );
575-
// printf("RX on freq %u Hz at DR %d\n\r", (unsigned int)frequency, dr);
575+
FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr);
576576

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

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

597597
*txTimeOnAir = Radio.TimeOnAir( MODEM_LORA, txConfig->PktLen );
598598
*txPower = txPowerLimited;

cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionCN470.c renamed to cores/asr650x/loramac/mac/region/RegionCN470.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static uint8_t CountNbOfEnabledChannels( uint8_t datarate, uint16_t* channelsMas
134134
}
135135
}
136136
}
137-
//printf("nbEnabledChannels: %d ",nbEnabledChannels);
137+
138138
*delayTx = delayTransmission;
139139
return nbEnabledChannels;
140140
}
@@ -529,6 +529,7 @@ bool RegionCN470RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate )
529529
maxPayload = MaxPayloadOfDatarateCN470[dr];
530530
}
531531
Radio.SetMaxPayloadLength( MODEM_LORA, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD );
532+
FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr);
532533

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

549550
Radio.SetTxConfig( MODEM_LORA, phyTxPower, 0, 0, phyDr, 1, 8, false, true, 0, 0, false, 3000 );
551+
FREQ_PRINTF("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate);
552+
550553
// Setup maximum payload lenght of the radio driver
551554
Radio.SetMaxPayloadLength( MODEM_LORA, txConfig->PktLen );
552555
// Get the time-on-air of the next tx frame

cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionCN779.c renamed to cores/asr650x/loramac/mac/region/RegionCN779.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ bool RegionCN779RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate )
604604
maxPayload = MaxPayloadOfDatarateCN779[dr];
605605
}
606606
Radio.SetMaxPayloadLength( modem, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD );
607-
DBG_PRINTF("RX on freq %u Hz at DR %d\n\r", (unsigned int)frequency, dr);
607+
FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr);
608608

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

cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionEU433.c renamed to cores/asr650x/loramac/mac/region/RegionEU433.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ bool RegionEU433RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate )
604604
maxPayload = MaxPayloadOfDatarateEU433[dr];
605605
}
606606
Radio.SetMaxPayloadLength( modem, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD );
607-
DBG_PRINTF("RX on freq %u Hz at DR %d\n\r", (unsigned int)frequency, dr);
607+
FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr);
608608

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

cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionEU868.c renamed to cores/asr650x/loramac/mac/region/RegionEU868.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ bool RegionEU868RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate )
634634
}
635635

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

639639
*datarate = (uint8_t) dr;
640640
return true;
@@ -664,7 +664,7 @@ bool RegionEU868TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
664664
modem = MODEM_LORA;
665665
Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 3000 );
666666
}
667-
// printf("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate);
667+
FREQ_PRINTF("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate);
668668
// Setup maximum payload lenght of the radio driver
669669
Radio.SetMaxPayloadLength( modem, txConfig->PktLen );
670670
// Get the time-on-air of the next tx frame

cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionIN865.c renamed to cores/asr650x/loramac/mac/region/RegionIN865.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ bool RegionIN865RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate )
608608
maxPayload = MaxPayloadOfDatarateIN865[dr];
609609
}
610610
Radio.SetMaxPayloadLength( modem, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD );
611-
DBG_PRINTF("RX on freq %u Hz at DR %d\n\r", (unsigned int)frequency, dr);
611+
FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr);
612612

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

0 commit comments

Comments
 (0)