wip
This commit is contained in:
parent
e9a0b1a2fd
commit
2f1219283e
|
@ -602,6 +602,11 @@ static void OnRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params)
|
|||
if (appData->BufferSize != 1)
|
||||
{
|
||||
if (appData->BufferSize < 128) {
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\n OnTxData: Port=%d \n\t", appData->Port);
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\n\t");
|
||||
for (uint8_t x=0; x< appData->BufferSize; x++)
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "%02x\t", appData->Buffer[x]);;
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\n");
|
||||
USER_APP_AUTO_RESPONDER_Parse((uint8_t*)appData->Buffer, appData->BufferSize);
|
||||
}
|
||||
}
|
||||
|
@ -639,13 +644,6 @@ void STS_SENSOR_Upload_Message(uint8_t appDataPort, uint8_t appBufferSize, uint8
|
|||
AppData.Port = appDataPort;
|
||||
AppData.BufferSize = appBufferSize;
|
||||
|
||||
if ((JoinLedTimer.IsRunning) && (LmHandlerJoinStatus() == LORAMAC_HANDLER_SET))
|
||||
{
|
||||
UTIL_TIMER_Stop(&JoinLedTimer);
|
||||
#if defined(STM32WL55xx)
|
||||
HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_RESET); /* LED_RED */
|
||||
#endif
|
||||
}
|
||||
|
||||
status = LmHandlerSend(&AppData, LmHandlerParams.IsTxConfirmed, false);
|
||||
if (LORAMAC_HANDLER_SUCCESS == status)
|
||||
|
@ -663,12 +661,6 @@ void STS_SENSOR_Upload_Message(uint8_t appDataPort, uint8_t appBufferSize, uint8
|
|||
|
||||
}
|
||||
|
||||
if (EventType == TX_ON_TIMER)
|
||||
{
|
||||
UTIL_TIMER_Stop(&TxTimer);
|
||||
UTIL_TIMER_SetPeriod(&TxTimer, MAX(nextTxIn, TxPeriodicity));
|
||||
UTIL_TIMER_Start(&TxTimer);
|
||||
}
|
||||
}
|
||||
|
||||
static void SendTxData(void)
|
||||
|
|
|
@ -68,7 +68,7 @@ extern "C" {
|
|||
/*!
|
||||
* LoRaWAN default class
|
||||
*/
|
||||
#define LORAWAN_DEFAULT_CLASS CLASS_A
|
||||
#define LORAWAN_DEFAULT_CLASS CLASS_C
|
||||
|
||||
/*!
|
||||
* LoRaWAN default confirm state
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-82282070168568324" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1137263677548078264" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
|
@ -16,7 +16,7 @@
|
|||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-82282070168568324" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1137263677548078264" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
|
|
|
@ -820,6 +820,10 @@ void USER_APP_AUTO_RESPONDER_Parse(uint8_t *parse_buffer, uint8_t parse_buffer_s
|
|||
memset((void*)outbuf,0x0, sizeof(outbuf));
|
||||
UTIL_MEM_cpy_8((void*)tlv_buf,(void*)parse_buffer, parse_buffer_size&0x7F); /* 127 BYTES MAX */
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\n Auto_Responder_Parse: \n\t");
|
||||
for (uint8_t x=0; x<parse_buffer_size; x++)
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "%02x\t", tlv_buf[x]);;
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\n");
|
||||
switch ((char)tlv_buf[CFG_CMD1])
|
||||
{ /* Begin of switch tlv_buf[CFG_CMD1] */
|
||||
/* 111111111111111111111111111111111111111111111111111111111111111111111 */
|
||||
|
@ -857,7 +861,8 @@ void USER_APP_AUTO_RESPONDER_Parse(uint8_t *parse_buffer, uint8_t parse_buffer_s
|
|||
break;
|
||||
case 'D': /* "YZD": Distance/Install height Measure */
|
||||
STS_SENSOR_Distance_Test_Process();
|
||||
sts_cfg_nvm.sensor_install_height_in_10cm = sts_sensor_install_height/100; //in 10 cm
|
||||
sts_cfg_nvm.sensor_install_height_in_10cm = sts_sensor_install_height/10; //in 10 cm
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\n STS CFG NVM -> SENSOR INSTALL HEIGHT STORED = %d CM\n", sts_cfg_nvm.sensor_install_height_in_10cm);
|
||||
OnStoreSTSCFGContextRequest();
|
||||
i = 0;
|
||||
outbuf[i++] = (uint8_t)'D';
|
||||
|
@ -870,6 +875,7 @@ void USER_APP_AUTO_RESPONDER_Parse(uint8_t *parse_buffer, uint8_t parse_buffer_s
|
|||
outbuf[i++] = (uint8_t)(sts_sensor_install_height>>8)&0xFF;
|
||||
outbuf[i++] = (uint8_t)(sts_sensor_install_height)&0xFF;
|
||||
#endif
|
||||
|
||||
STS_SENSOR_Upload_Message(YUNHORN_STS_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
|
||||
break;
|
||||
case 'M': /* "YZM": Mask level */
|
||||
|
@ -1268,7 +1274,7 @@ void OnStoreSTSCFGContextRequest(void)
|
|||
/* USER CODE BEGIN OnStoreContextRequest_1 */
|
||||
|
||||
uint8_t nvm_store_value[YUNHORN_STS_MAX_NVM_CFG_SIZE]={0x0};
|
||||
#if 0
|
||||
#if 1
|
||||
sts_cfg_nvm.length = STS_NVM_CFG_SIZE;
|
||||
nvm_store_value[i++] = sts_cfg_nvm.mtmcode1;
|
||||
nvm_store_value[i++] = sts_cfg_nvm.mtmcode2;
|
||||
|
@ -1300,11 +1306,11 @@ void OnStoreSTSCFGContextRequest(void)
|
|||
|
||||
/* USER CODE END OnStoreContextRequest_1 */
|
||||
/* store nvm in flash */
|
||||
UTIL_MEM_cpy_8((void*)nvm_store_value, (void *)&sts_cfg_nvm,YUNHORN_STS_MAX_NVM_CFG_SIZE);
|
||||
//UTIL_MEM_cpy_8((void*)nvm_store_value, (void *)&sts_cfg_nvm,YUNHORN_STS_MAX_NVM_CFG_SIZE);
|
||||
if (FLASH_IF_Erase(STS_CONFIG_NVM_BASE_ADDRESS, FLASH_PAGE_SIZE) == FLASH_IF_OK)
|
||||
{
|
||||
//FLASH_IF_Write(STS_CONFIG_NVM_BASE_ADDRESS, (const void *)nvm_store_value, YUNHORN_STS_MAX_NVM_CFG_SIZE);
|
||||
FLASH_IF_Write(STS_CONFIG_NVM_BASE_ADDRESS, (const void *)&sts_cfg_nvm, YUNHORN_STS_MAX_NVM_CFG_SIZE);
|
||||
FLASH_IF_Write(STS_CONFIG_NVM_BASE_ADDRESS, (const void *)nvm_store_value, YUNHORN_STS_MAX_NVM_CFG_SIZE);
|
||||
//FLASH_IF_Write(STS_CONFIG_NVM_BASE_ADDRESS, (const void *)&sts_cfg_nvm, YUNHORN_STS_MAX_NVM_CFG_SIZE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1465,7 +1471,8 @@ void STS_SENSOR_Distance_Test_Process(void)
|
|||
#if defined(VL53LX)
|
||||
//MX_TOF_Init();
|
||||
//MX_TOF_Process();
|
||||
sts_sensor_install_height = MX_TOF_Ranging_Process();
|
||||
sts_sensor_install_height = (uint16_t)MX_TOF_Ranging_Process();
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\n STS SENSOR INSTALLATION HEIGHT =%d \n\r", (uint16_t)sts_sensor_install_height);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -79,9 +79,10 @@ void MX_TOF_Init(void)
|
|||
*/
|
||||
uint16_t MX_TOF_Ranging_Process(void)
|
||||
{ uint16_t range_distance=0;
|
||||
uint8_t range_mode = STS_TOF_LONG_RANGE;
|
||||
uint8_t range_mode = 2; //STS_TOF_LONG_RANGE;
|
||||
STS_TOF_VL53LX_Range_Process(range_mode, &range_distance);
|
||||
return range_distance;
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\n VL53L1 Range distance =%u mm \n\r", (uint16_t)range_distance);
|
||||
return (uint16_t) range_distance;
|
||||
}
|
||||
void MX_TOF_Process(void)
|
||||
{
|
||||
|
@ -119,7 +120,7 @@ uint8_t IsInterruptDetected(uint16_t dev)
|
|||
void STS_TOF_VL53LX_Range_Process(uint8_t range_mode, uint16_t *range_distance)
|
||||
{
|
||||
//uint8_t vl53lx_model = STS_TOF_VL53L1X;
|
||||
//uint8_t range_mode = STS_TOF_SHORT_RANGE;
|
||||
uint8_t range_mode = STS_TOF_SHORT_RANGE;
|
||||
uint16_t i_distance_measured = 0;
|
||||
uint16_t i_distance_threshold_mm = 800;
|
||||
uint16_t i_inter_measurement_ms=100, i_macro_timing=33;
|
||||
|
@ -174,6 +175,7 @@ void STS_TOF_VL53LX_Range_Process(uint8_t range_mode, uint16_t *range_distance)
|
|||
}
|
||||
|
||||
sts_vl53lx_ranging(&i_distance_measured, range_mode, i_distance_threshold_mm, i_inter_measurement_ms,i_macro_timing, i_roi_width, i_sigma_mm, i_signal_kcps);
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "I_DISTANCE_MEASURED = %d \n", i_distance_measured);
|
||||
*range_distance = i_distance_measured;
|
||||
|
||||
}
|
||||
|
@ -187,6 +189,31 @@ void BSP_PB_Callback(Button_TypeDef Button)
|
|||
uint8_t sts_vl53lx_ranging(uint16_t *ranged_distance, uint8_t range_mode, uint16_t distance_threshold_mm, uint16_t inter_measurement_ms, uint16_t macro_timing,
|
||||
uint16_t roi_width, uint16_t sigma_mm, uint16_t signal_kcps)
|
||||
{
|
||||
uint8_t status=0, dev=0x52;
|
||||
uint16_t estimated_distance_mm=0;
|
||||
status = VL53L1X_SensorInit(dev);
|
||||
status += VL53L1X_SetDistanceMode(dev, 2); /* 1=short, 2=long, DISTANCE_MODE */
|
||||
status += VL53L1X_SetTimingBudgetInMs(dev, 100); /* TIMING_BUDGET, in ms possible values [15, 20, 50, 100, 200, 500] */
|
||||
status += VL53L1X_SetInterMeasurementInMs(dev, 50);
|
||||
status += VL53L1X_SetROI(dev, 8, 8); /* minimum ROI 4,4 */
|
||||
if (status != 0) {
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"Initialization or configuration of the device\n");
|
||||
return (-1);
|
||||
}
|
||||
status = VL53L1X_StartRanging(dev); /* This function has to be called to enable the ranging */
|
||||
if (status != 0) {
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"Start Range failed\n");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
status = VL53L1X_GetDistance(dev, &estimated_distance_mm);
|
||||
APP_LOG(TS_OFF,VLEVEL_M,"Target detected! Distance =%d mm \r\n", estimated_distance_mm );
|
||||
*ranged_distance = estimated_distance_mm;
|
||||
status = VL53L1X_StopRanging(dev);
|
||||
APP_LOG(TS_OFF,VLEVEL_M,"End of VL53L1X Ranging Process\n");
|
||||
return status;
|
||||
|
||||
#if 0
|
||||
/*********************************/
|
||||
/* VL53L1X ranging variables */
|
||||
/*********************************/
|
||||
|
@ -284,6 +311,7 @@ uint16_t roi_width, uint16_t sigma_mm, uint16_t signal_kcps)
|
|||
status = VL53L1X_StopRanging(dev);
|
||||
APP_LOG(TS_OFF,VLEVEL_L,"End of VL53L1X ultra low power demo\n");
|
||||
return status;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue