fix HMAC issue

This commit is contained in:
Yunhorn 2023-10-15 23:51:58 +08:00
parent 32fc9f0fed
commit dc4092020b
3 changed files with 42 additions and 10 deletions

View File

@ -47,12 +47,12 @@ extern "C" {
/**
* @brief Verbose level for all trace logs
*/
#define VERBOSE_LEVEL VLEVEL_M
#define VERBOSE_LEVEL VLEVEL_H
/**
* @brief Enable trace logs
*/
#define APP_LOG_ENABLED 1
#define APP_LOG_ENABLED 0
/**
* @brief Activate monitoring (probes) of some internal RF signals for debug purpose

View File

@ -60,7 +60,7 @@
#ifdef YUNHORN_STS_M7_ENABLED
#define MajorVer 23U
#define MinorVer 10U
#define SubMinorVer 15U
#define SubMinorVer 16U
#define FirmwareVersion 3U
/*
#define YUNHORN_STS_M7_NVM_CFG_SIZE 3U

View File

@ -53,7 +53,7 @@ volatile uint8_t sts_work_mode =0;
volatile uint8_t sts_ac_code[YUNHORN_STS_AC_CODE_SIZE]={0x0};
volatile uint8_t heart_beat_timer=0, sts_lorawan_joined=0;
volatile sts_cfg_nvm_t sts_cfg_nvm={sts_mtmcode1,sts_mtmcode2, sts_version, sts_hardware_ver,
0x00,'M', 0x05,'M', 0x04,0x00,0x00,0x20,
0x01,'M', 0x05,'M', 0x04,0x00,0x00,0x20,
{0x0,0x0,0x0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
0x01,0x03,0x00,0x02,
{0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF}
@ -403,7 +403,7 @@ void LoRaWAN_Init(void)
/* USER CODE BEGIN LoRaWAN_Init_1 */
APP_LOG(TS_OFF, VLEVEL_M, "\r\n\n\n##### YUNHORN_STS_FW:%d SWV%d HWV:%d MTM:%d.%d R:%d.%d.%d####\r\n\n\n",
FirmwareVersion, sts_version, sts_hardware_ver, sts_mtmcode1,sts_mtmcode2, MajorVer, MinorVer, SubMinorVer);
APP_LOG(TS_OFF, VLEVEL_M,"\r\n\n ========================== V12 =======================\r\n");
/* Get LoRaWAN APP version*/
APP_LOG(TS_OFF, VLEVEL_M, "APPLICATION_VERSION: V%X.%X.%X\r\n",
(uint8_t)(APP_VERSION_MAIN),
@ -1082,7 +1082,9 @@ static void SendTxData(void)
// sensor_t sensor_data;
STS_M7_SensorDataTypeDef m7_data;
UTIL_TIMER_Time_t nextTxIn = 0;
// APP_LOG(TS_ON, VLEVEL_H, "\r\n Flag: Heart-beat-timer = %u \r\n sensor_data_ready = %u \r\n",
// heart_beat_timer, sensor_data_ready);
uint32_t i = 0;
//EnvSensors_Read(&sensor_data);
@ -1129,7 +1131,7 @@ static void SendTxData(void)
APP_LOG(TS_OFF, VLEVEL_M, "###### Duration: %02d seconds | FREQ_X:%d Hz | FREQ_Y:%d Hz | FREQ_Z:%d Hz |\r\n###### | RMS_X:%d | RMS_Y:%d | RMS_Z:%d | BATTERY_B:%02d%% |\r\n",
APP_LOG(TS_OFF, VLEVEL_H, "###### Duration: %02d seconds | FREQ_X:%d Hz | FREQ_Y:%d Hz | FREQ_Z:%d Hz |\r\n###### | RMS_X:%d | RMS_Y:%d | RMS_Z:%d | BATTERY_B:%02d%% |\r\n",
AppData.Buffer[6], (AppData.Buffer[7]*255+AppData.Buffer[8]), (AppData.Buffer[9]*255+AppData.Buffer[10]), (AppData.Buffer[11]*255+AppData.Buffer[12]),
(AppData.Buffer[13]*255+AppData.Buffer[14]),(AppData.Buffer[15]*255+AppData.Buffer[16]),(AppData.Buffer[17]*255+AppData.Buffer[18]),AppData.Buffer[04]);
}
@ -1143,7 +1145,7 @@ static void SendTxData(void)
*/
AppData.BufferSize = i;
AppData.BufferSize = (sts_service_mask >1?0:i);
if ((JoinLedTimer.IsRunning) && (LmHandlerJoinStatus() == LORAMAC_HANDLER_SET))
{
@ -1261,7 +1263,7 @@ static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
sts_lorawan_joined = (uint8_t) joinParams->Mode;
OnTxPeriodicityChanged(periodicity_length*1000);
APP_LOG(TS_OFF, VLEVEL_L, "\r\n==================== Tx Periodicity changed to = %d second(s) \r\n", (int)periodicity_length);
APP_LOG(TS_OFF, VLEVEL_H, "\r\n==================== Tx Periodicity changed to = %d second(s) \r\n", (int)periodicity_length);
}
else
{
@ -1344,7 +1346,7 @@ static void OnTxPeriodicityChanged(uint32_t periodicity)
UTIL_TIMER_Start(&TxTimer);
/* USER CODE BEGIN OnTxPeriodicityChanged_2 */
APP_LOG(TS_OFF, VLEVEL_H,"\r\n TxPeriodicity changed to %u (msec) \r\n", TxPeriodicity);
/* USER CODE END OnTxPeriodicityChanged_2 */
}
@ -1503,6 +1505,36 @@ static void OnRestoreContextRequest(void *nvm, uint32_t nvm_size)
/* USER CODE END OnRestoreContextRequest_Last */
}
/**
* @brief Yunhorn STS Sensor Live Heart Beat Periodicity/interval Change callback function
* @param context ptr of STS Live Heart Beat context
* YL x x x
* */
static void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity)
{
/* USER CODE BEGIN OnTxPeriodicityChanged_1 */
/* USER CODE END OnTxPeriodicityChanged_1 */
HeartBeatPeriodicity = periodicity;
if (HeartBeatPeriodicity == 0)
{
/* Revert to application default periodicity */
HeartBeatPeriodicity = 10*APP_TX_DUTYCYCLE;
}
/* Update timer periodicity */
UTIL_TIMER_Stop(&YunhornSTSHeartBeatTimer);
UTIL_TIMER_SetPeriod(&YunhornSTSHeartBeatTimer, HeartBeatPeriodicity);
UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
/* USER CODE BEGIN OnTxPeriodicityChanged_2 */
APP_LOG(TS_OFF, VLEVEL_L,"**************** HeartBeatPeriodicity Changed to: %u (ms)\r\n", HeartBeatPeriodicity );
/* USER CODE END OnTxPeriodicityChanged_2 */
}
void OnStoreSTSCFGContextRequest(void)
{
/* USER CODE BEGIN OnStoreContextRequest_1 */