Update LoRaMac-node to Version 4.4.4,fix Security breach found by Tencent Blade Team please refer to security advisory - CVE-2020-11068

fix Security breach found by Tencent Blade Team please refer to security advisory - CVE-2020-11068
This commit is contained in:
supowang
2020-05-29 11:59:05 +08:00
parent 5d9895cecc
commit f9bd2588a2
137 changed files with 10401 additions and 4328 deletions

View File

@@ -23,6 +23,11 @@
#ifndef __ADC_H__
#define __ADC_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.h>
#include "gpio.h"
@@ -58,4 +63,8 @@ void AdcDeInit( Adc_t *obj );
*/
uint16_t AdcReadChannel( Adc_t *obj, uint32_t channel );
#ifdef __cplusplus
}
#endif
#endif // __ADC_H__

View File

@@ -23,6 +23,11 @@
#ifndef __DELAY_H__
#define __DELAY_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.h>
/*!
@@ -35,5 +40,9 @@ void Delay( float s );
*/
void DelayMs( uint32_t ms );
#ifdef __cplusplus
}
#endif
#endif // __DELAY_H__

View File

@@ -23,6 +23,11 @@
#ifndef __EEPROM_H__
#define __EEPROM_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.h>
/*!
@@ -31,7 +36,7 @@
* \param[IN] addr EEPROM address to write to
* \param[IN] buffer Pointer to the buffer to be written.
* \param[IN] size Size of the buffer to be written.
* \retval status [LORA_SUCCESS, LORA_FAIL]
* \retval status [SUCCESS, FAIL]
*/
uint8_t EepromWriteBuffer( uint16_t addr, uint8_t *buffer, uint16_t size );
@@ -41,7 +46,7 @@ uint8_t EepromWriteBuffer( uint16_t addr, uint8_t *buffer, uint16_t size );
* \param[IN] addr EEPROM address to read from
* \param[OUT] buffer Pointer to the buffer to be written with read data.
* \param[IN] size Size of the buffer to be read.
* \retval status [LORA_SUCCESS, LORA_FAIL]
* \retval status [SUCCESS, FAIL]
*/
uint8_t EepromReadBuffer( uint16_t addr, uint8_t *buffer, uint16_t size );
@@ -63,4 +68,8 @@ void EepromSetDeviceAddr( uint8_t addr );
*/
uint8_t EepromGetDeviceAddr( void );
#ifdef __cplusplus
}
#endif
#endif // __EEPROM_H__

View File

@@ -23,6 +23,11 @@
#ifndef __FIFO_H__
#define __FIFO_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdbool.h>
#include <stdint.h>
@@ -85,4 +90,8 @@ bool IsFifoEmpty( Fifo_t *fifo );
*/
bool IsFifoFull( Fifo_t *fifo );
#ifdef __cplusplus
}
#endif
#endif // __FIFO_H__

View File

@@ -27,6 +27,11 @@
#ifndef __GPIO_H__
#define __GPIO_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.h>
#include "pinName-board.h"
#include "pinName-ioe.h"
@@ -179,4 +184,8 @@ void GpioToggle( Gpio_t *obj );
*/
uint32_t GpioRead( Gpio_t *obj );
#ifdef __cplusplus
}
#endif
#endif // __GPIO_H__

View File

@@ -186,10 +186,10 @@ void GpsConvertPositionFromStringToNumerical( void )
uint8_t GpsGetLatestGpsPositionDouble( double *lati, double *longi )
{
uint8_t status = LORA_FAIL;
uint8_t status = FAIL;
if( HasFix == true )
{
status = LORA_SUCCESS;
status = SUCCESS;
}
else
{
@@ -202,12 +202,12 @@ uint8_t GpsGetLatestGpsPositionDouble( double *lati, double *longi )
uint8_t GpsGetLatestGpsPositionBinary( int32_t *latiBin, int32_t *longiBin )
{
uint8_t status = LORA_FAIL;
uint8_t status = FAIL;
CRITICAL_SECTION_BEGIN( );
if( HasFix == true )
{
status = LORA_SUCCESS;
status = SUCCESS;
}
else
{
@@ -322,12 +322,12 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
if( rxBuffer[0] != '$' )
{
GpsMcuInvertPpsTrigger( );
return LORA_FAIL;
return FAIL;
}
if( GpsNmeaValidateChecksum( rxBuffer, rxBufferSize ) == false )
{
return LORA_FAIL;
return FAIL;
}
fieldSize = 0;
@@ -335,7 +335,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 6 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -351,7 +351,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 11 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -364,7 +364,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 10 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -377,7 +377,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 2 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -390,7 +390,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 11 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -403,7 +403,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 2 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -416,7 +416,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 2 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -429,7 +429,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 3 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -442,7 +442,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 6 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -455,7 +455,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 8 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -468,7 +468,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 2 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -481,7 +481,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 8 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -494,7 +494,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 2 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -503,7 +503,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
}
GpsFormatGpsData( );
return LORA_SUCCESS;
return SUCCESS;
}
else if ( strncmp( ( const char* )NmeaGpsData.NmeaDataType, ( const char* )NmeaDataTypeGPRMC, 5 ) == 0 )
{
@@ -513,7 +513,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 11 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -526,7 +526,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 2 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -539,7 +539,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 10 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -552,7 +552,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 2 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -565,7 +565,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 11 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -578,7 +578,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 2 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -591,7 +591,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 8 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -604,7 +604,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 8 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -617,7 +617,7 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
{
if( fieldSize > 8 )
{
return LORA_FAIL;
return FAIL;
}
}
for( j = 0; j < fieldSize; j++, i++ )
@@ -626,11 +626,11 @@ uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize )
}
GpsFormatGpsData( );
return LORA_SUCCESS;
return SUCCESS;
}
else
{
return LORA_FAIL;
return FAIL;
}
}

View File

@@ -23,6 +23,11 @@
#ifndef __GPS_H__
#define __GPS_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.h>
#include <stdbool.h>
@@ -106,7 +111,7 @@ void GpsConvertPositionFromStringToNumerical( void );
* \param [OUT] lati Latitude value
* \param [OUT] longi Longitude value
*
* \retval status [LORA_SUCCESS, LORA_FAIL]
* \retval status [SUCCESS, FAIL]
*/
uint8_t GpsGetLatestGpsPositionDouble ( double *lati, double *longi );
@@ -117,7 +122,7 @@ uint8_t GpsGetLatestGpsPositionDouble ( double *lati, double *longi );
* \param [OUT] latiBin Latitude value
* \param [OUT] longiBin Longitude value
*
* \retval status [LORA_SUCCESS, LORA_FAIL]
* \retval status [SUCCESS, FAIL]
*/
uint8_t GpsGetLatestGpsPositionBinary ( int32_t *latiBin, int32_t *longiBin );
@@ -129,7 +134,7 @@ uint8_t GpsGetLatestGpsPositionBinary ( int32_t *latiBin, int32_t *longiBin );
* \param [IN] rxBuffer Data buffer to be parsed
* \param [IN] rxBufferSize Size of data buffer
*
* \retval status [LORA_SUCCESS, LORA_FAIL]
* \retval status [SUCCESS, FAIL]
*/
uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize );
@@ -150,4 +155,8 @@ void GpsFormatGpsData( void );
*/
void GpsResetPosition( void );
#ifdef __cplusplus
}
#endif
#endif // __GPS_H__

View File

@@ -23,6 +23,11 @@
#ifndef __I2C_H__
#define __I2C_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include "gpio.h"
/*!
@@ -109,4 +114,8 @@ uint8_t I2cRead( I2c_t *obj, uint8_t deviceAddr, uint16_t addr, uint8_t *data );
*/
uint8_t I2cReadBuffer( I2c_t *obj, uint8_t deviceAddr, uint16_t addr, uint8_t *buffer, uint16_t size );
#ifdef __cplusplus
}
#endif
#endif // __I2C_H__

View File

@@ -33,6 +33,11 @@
#ifndef __NVMM_H__
#define __NVMM_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdlib.h>
#include <stdint.h>
@@ -112,4 +117,8 @@ NvmmStatus_t NvmmWrite( NvmmDataBlock_t* dataB, void* src, size_t num );
*/
NvmmStatus_t NvmmRead( NvmmDataBlock_t* dataB, void* dst, size_t num );
#ifdef __cplusplus
}
#endif
#endif // __NVMM_H__

View File

@@ -23,4 +23,13 @@
#ifndef __SERIAL_H__
#define __SERIAL_H__
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif // __SERIAL_H__

View File

@@ -23,6 +23,11 @@
#ifndef __SPI_H__
#define __SPI_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include "gpio.h"
/*!
@@ -97,4 +102,8 @@ void SpiFrequency( Spi_t *obj, uint32_t hz );
*/
uint16_t SpiInOut( Spi_t *obj, uint16_t outData );
#ifdef __cplusplus
}
#endif
#endif // __SPI_H__

View File

@@ -139,7 +139,7 @@ SysTime_t SysTimeGetMcuTime( void )
return calendarTime;
}
uint32_t SysTime2Ms( SysTime_t sysTime )
uint32_t SysTimeToMs( SysTime_t sysTime )
{
SysTime_t deltaTime;
RtcBkupRead( &deltaTime.Seconds, ( uint32_t* )&deltaTime.SubSeconds );
@@ -147,6 +147,16 @@ uint32_t SysTime2Ms( SysTime_t sysTime )
return calendarTime.Seconds * 1000 + calendarTime.SubSeconds;
}
SysTime_t SysTimeFromMs( uint32_t timeMs )
{
uint32_t seconds = timeMs / 1000;
SysTime_t sysTime = { .Seconds = seconds, .SubSeconds = timeMs - seconds * 1000 };
SysTime_t deltaTime = { 0 };
RtcBkupRead( &deltaTime.Seconds, ( uint32_t* )&deltaTime.SubSeconds );
return SysTimeAdd( sysTime, deltaTime );
}
uint32_t SysTimeMkTime( const struct tm* localtime )
{
uint32_t nbdays;

View File

@@ -29,6 +29,7 @@
extern "C"
{
#endif
#include <stdint.h>
#include "time.h"
@@ -133,7 +134,16 @@ SysTime_t SysTimeGetMcuTime( void );
*
* \retval timeMs The RTC converted time value in ms
*/
uint32_t SysTime2Ms( SysTime_t sysTime );
uint32_t SysTimeToMs( SysTime_t sysTime );
/*!
* Converts the given RTC value in milliseconds to the equivalent SysTime
*
* \param [IN] timeMs The RTC time value in ms to be converted
*
* \retval sysTime Converted system time
*/
SysTime_t SysTimeFromMs( uint32_t timeMs );
/*!
* \brief Convert a calendar time into time since UNIX epoch as a uint32_t.

View File

@@ -351,6 +351,10 @@ TimerTime_t TimerGetCurrentTime( void )
TimerTime_t TimerGetElapsedTime( TimerTime_t past )
{
if ( past == 0 )
{
return 0;
}
uint32_t nowInTicks = RtcGetTimerValue( );
uint32_t pastInTicks = RtcMs2Tick( past );

View File

@@ -23,6 +23,11 @@
#ifndef __TIMER_H__
#define __TIMER_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
@@ -46,6 +51,7 @@ typedef struct TimerEvent_s
*/
#ifndef TimerTime_t
typedef uint32_t TimerTime_t;
#define TIMERTIME_T_MAX ( ( uint32_t )~0 )
#endif
/*!
@@ -121,6 +127,8 @@ TimerTime_t TimerGetCurrentTime( void );
/*!
* \brief Return the Time elapsed since a fix moment in Time
*
* \remark TimerGetElapsedTime will return 0 for argument 0.
*
* \param [IN] past fix moment in Time
* \retval time returns elapsed time
*/
@@ -142,4 +150,8 @@ TimerTime_t TimerTempCompensation( TimerTime_t period, float temperature );
*/
void TimerProcess( void );
#ifdef __cplusplus
}
#endif
#endif // __TIMER_H__

View File

@@ -23,9 +23,14 @@
#ifndef __UART_H__
#define __UART_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include "fifo.h"
#include "gpio.h"
#include "stdio.h"
/*!
* UART peripheral ID
*/
@@ -183,4 +188,8 @@ uint8_t UartGetChar( Uart_t *obj, uint8_t *data );
*/
uint8_t UartGetBuffer( Uart_t *obj, uint8_t *buffer, uint16_t size, uint16_t *nbReadBytes );
#ifdef __cplusplus
}
#endif
#endif // __UART_H__