--- outbuf from char * to uint8_t *

This commit is contained in:
Yunhorn 2024-07-18 10:07:37 +08:00
parent 51db61b31d
commit 95c3694c74
3 changed files with 4766 additions and 4756 deletions
Core/Inc
LoRaWAN/App
STM32CubeIDE/Release

View File

@ -597,7 +597,7 @@ void STS_YunhornAuthenticationCode_Process(void);
void STS_Reed_Hall_Presence_Detection(void);
void STS_SENSOR_Upload_Config_Invalid_Message(void);
void STS_SENSOR_Upload_Message(uint8_t appDataPort, uint8_t appBufferSize, char *appDataBuffer);
void STS_SENSOR_Upload_Message(uint8_t appDataPort, uint8_t appBufferSize, uint8_t *appDataBuffer);
void STS_SENSOR_Auto_Responder_Process(uint8_t tlv_ver,uint8_t tlv_type, uint8_t tlv_length, uint8_t *tlv_content);
uint8_t STS_SENSOR_MEMS_Get_ID(uint8_t *devID);

View File

@ -61,7 +61,7 @@ volatile uint32_t HeartBeatPeriodicity = 120000; //unit ms
volatile uint8_t STS_LoRa_WAN_Joined = 0;
volatile uint8_t heart_beat_timer =0;
char outbuf[128]="";
volatile uint8_t outbuf[128]={0x0};
volatile uint8_t upload_message_timer =0;
volatile sts_cfg_nvm_t sts_cfg_nvm = {
sts_mtmcode1,
@ -732,7 +732,7 @@ static void OnRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params)
outbuf[i++] = (uint8_t) sts_mtmcode2;
outbuf[i++] = (uint8_t) sts_version;
outbuf[i++] = (uint8_t) (0x41+ deviceClass); //translate to 'A','B','C'
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
break;
case LORAWAN_USER_APP_PORT:
@ -808,14 +808,20 @@ static void SendTxData(void)
#if defined(YUNHORN_STS_R0_ENABLED)||defined(YUNHORN_STS_R5_ENABLED)
PME_ON;
LED_ON;
//HAL_Delay(10);
HAL_Delay(500);
MX_TOF_Init();
HAL_Delay(500);
LED_ON;
MX_TOF_Process();
STS_R0_SENSOR_Read(&r0_data);
//HAL_Delay(1000);
PME_OFF;
//LED_OFF;
LED_OFF;
r0_data.battery_Pct = (uint8_t)(99*batteryLevel/254);
#endif
@ -1454,7 +1460,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
case 'Z': //"YZ"
if ((char)tlv_buf[CFG_CMD3] == 'H') { //BOARD SOFT RESET, REVIVE "YZH"
//BOARD REVIVE
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, 20, "!YunHorn STS Revive!");
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, 20, (uint8_t *)"!YunHorn STS Revive!");
HAL_Delay(5000);
APP_LOG(TS_OFF, VLEVEL_H, "\r\n Yunhorn STS Node Revive ... \r\n");
HAL_Delay(3000);
@ -1463,13 +1469,13 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
} else if ((char)tlv_buf[CFG_CMD3] == 'S') { // Self Function Testing "YZS"
i=0;
memset(outbuf,0x0,sizeof(outbuf));
memset((void*)outbuf,0x0,sizeof(outbuf));
STS_SENSOR_Function_Test_Process();
HAL_Delay(5000);
i=21;
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
} else if ((char)tlv_buf[CFG_CMD3] == 'C') { // Lora-WAN Class "YZC" LORAWAN CLASS A/B/C
@ -1481,7 +1487,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
outbuf[i++] = (uint8_t) sts_mtmcode2;
outbuf[i++] = (uint8_t) sts_version;
outbuf[i++] = (uint8_t) (0x41+ deviceClass); //translate to 'A','B','C'
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
} else if ((char)tlv_buf[CFG_CMD3] == 'D') { // Distance Measure "YZD"
i=0;
outbuf[i++] = (uint8_t) 'Y';
@ -1492,7 +1498,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
STS_SENSOR_Distance_Test_Process();
i=0;
memset(outbuf,0x0,sizeof(outbuf));
memset((void*)outbuf,0x0,sizeof(outbuf));
outbuf[i++] = (uint8_t)'D';
outbuf[i++] = (uint8_t)sts_mtmcode1;
outbuf[i++] = (uint8_t)sts_mtmcode2;
@ -1521,7 +1527,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
outbuf[i++] = (uint8_t) (((uint16_t)sts_tof_distance_data[2])%100)&0xff;
#endif
#endif
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
}
@ -1535,7 +1541,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
outbuf[i++] = (uint8_t) 'Y';
outbuf[i++] = (uint8_t) 'M';
outbuf[i++] = (uint8_t) (sts_service_mask+0x30);
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
APP_LOG(TS_OFF, VLEVEL_L, ">>>>>>>>>>>>>>>>>>>>> Mask = [ %02x ] \r\n", sts_service_mask);
OnStoreSTSCFGContextRequest();
#ifdef YUNHORN_STS_O6_ENABLED
@ -1556,7 +1562,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
outbuf[i++] = (uint8_t) MajorVer;
outbuf[i++] = (uint8_t) MinorVer;
outbuf[i++] = (uint8_t) SubMinorVer;
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
//APP_LOG(TS_OFF, VLEVEL_L, "###### YUNHORN Report Version [ %X ] \r\n", outbuf);
}
else
@ -1565,7 +1571,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
uint8_t cfg_in_nvm[YUNHORN_STS_MAX_NVM_CFG_SIZE]="";
OnRestoreSTSCFGContextRequest((uint8_t *)cfg_in_nvm);
i=0;
memset(outbuf,0x0,sizeof(outbuf));
memset((void*)outbuf,0x0,sizeof(outbuf));
outbuf[i++] = (uint8_t) 'C';
outbuf[i++] = (uint8_t) cfg_in_nvm[NVM_MTM1]; //MTM Code
@ -1584,7 +1590,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
for (uint8_t j=0; j < cfg_in_nvm[NVM_LEN]; j++) {
outbuf[i++] = (uint8_t) (cfg_in_nvm[NVM_CFG_START+j]);
}
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
}
break;
@ -1598,7 +1604,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD1];
outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD2];
outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD3];
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
} else {
STS_SENSOR_Upload_Config_Invalid_Message();
}
@ -1612,7 +1618,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD1];
outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD2];
outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD3];
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
} else {
STS_SENSOR_Upload_Config_Invalid_Message();
}
@ -1625,7 +1631,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD1];
outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD2];
outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD3];
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
} else {
STS_SENSOR_Upload_Config_Invalid_Message();
}
@ -1654,7 +1660,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD4];
outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD5];
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
// Save config to NVM
sts_cfg_nvm.mtmcode1 = (uint8_t)sts_mtmcode1;
sts_cfg_nvm.mtmcode2 = (uint8_t)sts_mtmcode2;
@ -1700,7 +1706,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD4];
outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD5];
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
// Save config to NVM
sts_cfg_nvm.mtmcode1 = (uint8_t)sts_mtmcode1;
sts_cfg_nvm.mtmcode2 = (uint8_t)sts_mtmcode2;
@ -1771,7 +1777,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
{
outbuf[i++] = (uint8_t)(sts_cfg_nvm.p[j]+0x30)&0xff;
}
APP_LOG(TS_OFF, VLEVEL_H, "###### RSS Simple CFG=%s\r\n",*outbuf);
//APP_LOG(TS_OFF, VLEVEL_H, "###### RSS Simple CFG=%s\r\n",outbuf);
// Step 2: Save valid config to NVM
sts_cfg_nvm.mtmcode1 = sts_mtmcode1;
@ -1794,7 +1800,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
}
// Step 3: Upload status update message
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
}
@ -1848,7 +1854,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
for (uint8_t j=0; j <(tlv_buf_size) ; j++) {
outbuf[i++] = (uint8_t) tlv_buf[j];
}
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (char*)outbuf);
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
}
@ -1857,7 +1863,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
void STS_SENSOR_Upload_Config_Invalid_Message(void)
{
if (sts_service_mask == STS_SERVICE_MASK_L0)
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, 5, "PVXXX");
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, 5, (uint8_t *)"PVXXX");
}
static void STS_YUNHORN_RFAC_HANDLE_PROCESS(void)
@ -1867,7 +1873,7 @@ static void STS_YUNHORN_RFAC_HANDLE_PROCESS(void)
}
void STS_SENSOR_Upload_Message(uint8_t appDataPort, uint8_t appBufferSize, char *appDataBuffer)
void STS_SENSOR_Upload_Message(uint8_t appDataPort, uint8_t appBufferSize, uint8_t *appDataBuffer)
{
LmHandlerErrorStatus_t status = LORAMAC_HANDLER_ERROR;
UTIL_TIMER_Time_t nextTxIn = 0;
@ -2108,6 +2114,7 @@ void STS_SENSOR_Distance_Test_Process(void)
#endif
#if defined(YUNHORN_STS_R0_ENABLED)||defined(YUNHORN_STS_R5_ENABLED)
MX_TOF_Init();
MX_TOF_Process();
#endif
}
@ -2156,6 +2163,7 @@ void STS_SENSOR_Function_Test_Process(void)
#if (defined(YUNHORN_STS_R0_ENABLED)||defined(YUNHORN_STS_R5_ENABLED)||defined(YUNHORN_STS_R1_ENABLED))
tstbuf[i++] = (uint8_t) (count)&0xff;
//MX_TOF_Process();
MX_TOF_Init();
STS_TOF_VL53L0X_Range_Process();
#ifdef TOF_1
@ -2176,6 +2184,6 @@ void STS_SENSOR_Function_Test_Process(void)
memset((void*)outbuf,0x0,sizeof(outbuf));
memcpy((void*)outbuf, tstbuf, i);
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
}

File diff suppressed because it is too large Load Diff