diff --git a/Core/Inc/sys_conf.h b/Core/Inc/sys_conf.h index ea70373..de3a94d 100644 --- a/Core/Inc/sys_conf.h +++ b/Core/Inc/sys_conf.h @@ -47,12 +47,12 @@ extern "C" { /** * @brief Verbose level for all trace logs */ -#define VERBOSE_LEVEL VLEVEL_L +#define VERBOSE_LEVEL VLEVEL_H /** * @brief Enable trace logs */ -#define APP_LOG_ENABLED 0 +#define APP_LOG_ENABLED 1 /** * @brief Activate monitoring (probes) of some internal RF signals for debug purpose diff --git a/Core/Inc/yunhorn_sts_prd_conf.h b/Core/Inc/yunhorn_sts_prd_conf.h index 19ec9c4..10cc030 100644 --- a/Core/Inc/yunhorn_sts_prd_conf.h +++ b/Core/Inc/yunhorn_sts_prd_conf.h @@ -34,16 +34,14 @@ */ #define STS_USE_STM32WLE5 1U //STM32WLE5CCUX //#define USE_STM32WL55 1U //STM32WL55JC1X -//#ifndef STM32WL55xx -//#define STM32WL55xx -//#endif + /* * MODULE SELECTION */ //#define USE_OLED_SSD1306 //#define USE_TOF_VL53L1X -#define STS_USE_TOF_VL53L0X 1U -//#define YUNHORN_STS_R5_ENABLED +#define STS_USE_TOF_VL53L0X 1U +#define YUNHORN_STS_R1_ENABLED // TOF VL53LX number @@ -87,7 +85,7 @@ /** YUNHORN SMARTOILETS CLEANSING RESOUCES LEVEL PRODUCTS **/ //#define YUNHORN_STS_R0_ENABLED -//#define YUNHORN_STS_R1_ENABLED +#define YUNHORN_STS_R0_ENABLED //#define YUNHORN_STS_R2_ENABLED /*#define YUNHORN_STS_R3_ENABLED */ /*#define YUNHORN_STS_R4_ENABLED */ @@ -183,6 +181,7 @@ #define YUNHORN_STS_USER_APP_CTRL_PORT 2U #define YUNHORN_STS_USER_APP_CTRL_REPLY_PORT 1U + #ifdef YUNHORN_STS_R1_ENABLED #define YUNHORN_STS_R1_LORA_APP_DATA_PORT 57U #define YUNHORN_STS_R1_LORA_APP_HTBT_PORT 58U @@ -250,6 +249,15 @@ #define STS_R0_CFG_CMD_SIZE 12U #define CFG_CMD_TOF_SIMPLE_SIZE (STS_R0_CFG_CMD_SIZE) +#ifdef YUNHORN_STS_R1_ENABLED +#define sts_mtmcode1 0U +#define sts_mtmcode2 57U +#define sts_hardware_ver 1U +#define sts_version 1U +#define sts_senddataport (YUNHORN_STS_R1_LORA_APP_DATA_PORT) +#define sts_sendhtbtport (YUNHORN_STS_R1_LORA_APP_HTBT_PORT) +#endif + #ifdef YUNHORN_STS_R5_ENABLED #define sts_mtmcode1 0U #define sts_mtmcode2 16U @@ -357,11 +365,6 @@ enum sts_lamp_color { #define sendhtbtport YUNHORN_STS_E4_LORA_APP_HTBT_PORT #endif /* YUNHORN_STS_E4_ENABLED */ -#ifdef YUNHORN_STS_R0_ENABLED -//#include "yunhorn_sts_e4_conf.h" -#define senddataport YUNHORN_STS_R0_LORA_APP_DATA_PORT -#define sendhtbtport YUNHORN_STS_R0_LORA_APP_HTBT_PORT -#endif /* YUNHORN_STS_R0_ENABLED */ #ifdef YUNHORN_STS_M7_ENABLED #define YUNHORN_STS_M7_NVM_CFG_SIZE 3U diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 6589da3..da2f23e 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -40,6 +40,7 @@ #include "app_tof_pin_conf.h" #include "app_tof.h" #include "yunhorn_sts_sensors.h" +#include "yunhorn_sts_prd_conf.h" #include "sts_cmox_hmac_sha.h" #include "X-WL55_WLE5_53L0X.h" /* USER CODE END Includes */ @@ -636,7 +637,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) #ifdef YUNHORN_STS_O5_ENABLED UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP1), CFG_SEQ_Prio_0); UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0); -#elif +#else uint8_t pinstate = HAL_GPIO_ReadPin(BUT1_GPIO_Port,BUT1_Pin); APP_LOG(TS_OFF, VLEVEL_H, "## BUTTON-1 DETECTED: %2d \r\n", pinstate); @@ -797,7 +798,7 @@ static void SendTxData(void) APP_LOG(TS_ON, VLEVEL_H, "\r\n Flag: Heart-beat-timer = %u \r\n upload_message_timer %u \r\n sensor_data_ready = %u \r\n", heart_beat_timer, upload_message_timer, sensor_data_ready); - APP_LOG(TS_ON, VLEVEL_H, "\r\nVDDA: %4d (mV)\r\n", batteryLevelmV); + //APP_LOG(TS_ON, VLEVEL_H, "\r\nVDDA: %4d (mV)\r\n", batteryLevelmV); //if (LmHandlerIsBusy() == false) { uint8_t i = 0; @@ -814,7 +815,7 @@ static void SendTxData(void) UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP4), CFG_SEQ_Prio_0); STS_R0_SENSOR_Read(&r0_data); - r0_data.battery_mV = batteryLevelmV; + //r0_data.battery_mV = batteryLevelmV; r0_data.battery_Pct = (uint8_t)(99*batteryLevel/254); #endif //r0_data.battery_Pct = batteryLevel; //(uint8_t)(99*batteryLevel/254); @@ -859,17 +860,20 @@ static void SendTxData(void) AppData.Buffer[i++] = (uint8_t)(oo_data.state_sensor1_on_off)&0xff; #elif defined(YUNHORN_STS_R0_ENABLED) + AppData.Buffer[i++] = (uint8_t)(0x04)&0xff; //#length of following bytes AppData.Buffer[i++] = (uint8_t)(r0_data.distance_mm >>8)&0xff; //#05 AppData.Buffer[i++] = (uint8_t)(r0_data.distance_mm)&0xff; //#06 AppData.Buffer[i++] = (uint8_t)(r0_data.distance1_mm >>8)&0xff; //#07 AppData.Buffer[i++] = (uint8_t)(r0_data.distance1_mm)&0xff; //#08 +#ifdef TOF_3 AppData.Buffer[i++] = (uint8_t)(r0_data.distance2_mm >>8)&0xff; //#09 AppData.Buffer[i++] = (uint8_t)(r0_data.distance2_mm)&0xff; //#10 - +#endif +#ifdef SOAP_LEVEL AppData.Buffer[i++] = (uint8_t)(sts_soap_level_state)&0xff; //#11 - - AppData.Buffer[i++] = (uint8_t)(r0_data.battery_mV >>8)&0xff; //#12 - AppData.Buffer[i++] = (uint8_t)(r0_data.battery_mV)&0xff; //#13 +#endif +// AppData.Buffer[i++] = (uint8_t)(r0_data.battery_mV >>8)&0xff; //#12 +// AppData.Buffer[i++] = (uint8_t)(r0_data.battery_mV)&0xff; //#13 #endif } @@ -2220,7 +2224,7 @@ void STS_SENSOR_Function_Test_Process(void) tstbuf[i++] = (uint8_t) (((uint16_t)sts_distance_rss_distance)%10+0x30)&0xff; #endif -#if defined(YUNHORN_STS_R0_ENABLED)||defined(YUNHORN_STS_R5_ENABLED) +#if (defined(YUNHORN_STS_R0_ENABLED)||defined(YUNHORN_STS_R5_ENABLED)) tstbuf[i++] = (uint8_t)6; //length of following data MX_TOF_Process(); tstbuf[i++] = (uint8_t) ((sts_tof_distance_data[0] >>8 ) &0xff); diff --git a/STM32CubeIDE/.cproject b/STM32CubeIDE/.cproject index 2f13bb8..cc131c0 100644 --- a/STM32CubeIDE/.cproject +++ b/STM32CubeIDE/.cproject @@ -26,7 +26,7 @@