From f2cc56f8f86bb5a5cbe2b06df3035a2008c81a08 Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Wed, 5 Jun 2024 20:54:52 +0800 Subject: [PATCH] minor changes --- Core/Inc/yunhorn_sts_prd_conf.h | 38 +++++++++++++++----- Core/Inc/yunhorn_sts_sensors.h | 12 ++++--- Core/Src/yunhorn_sts_process.c | 7 ++-- LoRaWAN/App/lora_app.c | 63 ++++++++++++++++++++++----------- 4 files changed, 84 insertions(+), 36 deletions(-) diff --git a/Core/Inc/yunhorn_sts_prd_conf.h b/Core/Inc/yunhorn_sts_prd_conf.h index 79b72e4..25764dc 100644 --- a/Core/Inc/yunhorn_sts_prd_conf.h +++ b/Core/Inc/yunhorn_sts_prd_conf.h @@ -63,6 +63,11 @@ #ifdef STS_O7 #define YUNHORN_STS_O7_ENABLED #endif + +#ifdef STS_O6 +#define YUNHORN_STS_O6_ENABLED +#endif + /** YUNHORN SMARTOILETS ENVIRONMENT PRODUCTS **/ /*#define YUNHORN_STS_E1_ENABLED */ /*#define YUNHORN_STS_E2_ENABLED */ @@ -157,6 +162,12 @@ //#define YUNHORN_STS_O5_LORA_APP_DATA_PORT 4U //#define YUNHORN_STS_O5_LORA_APP_HTBT_PORT 5U +#define YUNHORN_STS_O6_LORA_APP_DATA_PORT 17U +#define YUNHORN_STS_O6_LORA_APP_HTBT_PORT 18U +#define YUNHORN_STS_O6_USER_APP_CTRL_PORT 2U +#define YUNHORN_STS_O6_USER_APP_CTRL_REPLY_PORT 1U + + #define YUNHORN_STS_O7_LORA_APP_DATA_PORT 19U #define YUNHORN_STS_O7_LORA_APP_HTBT_PORT 20U #define YUNHORN_STS_O7_USER_APP_CTRL_PORT 2U @@ -207,10 +218,10 @@ //#define YUNHORN_STS_M10_LORA_APP_HTBT_PORT 9U -#ifdef YUNHORN_STS_O7_ENABLED + #define MajorVer 24U -#define MinorVer 05U -#define SubMinorVer 12U +#define MinorVer 06U +#define SubMinorVer 05U #define FirmwareVersion 3U #define YUNHORN_STS_MAX_NVM_CFG_SIZE 64U @@ -223,15 +234,26 @@ #define STS_MODE_COLOR_CMD_LEN 5U #define sts_mtmcode1 0U -#define sts_mtmcode2 16U +#ifdef STS_O6 +#define sts_mtmcode2 3U //MTM-03 for O6, MTM-07 for O7 +#endif +#ifdef STS_O7 +#define sts_mtmcode2 7U //MTM-03 for O6, MTM-07 for O7 +#endif #define sts_version 1U #define sts_hardware_ver 1U - +#ifdef STS_O6 +#define sts_senddataport (YUNHORN_STS_O6_LORA_APP_DATA_PORT) +#define sts_sendhtbtport (YUNHORN_STS_O6_LORA_APP_HTBT_PORT) +#endif +#ifdef STS_O7 #define sts_senddataport (YUNHORN_STS_O7_LORA_APP_DATA_PORT) #define sts_sendhtbtport (YUNHORN_STS_O7_LORA_APP_HTBT_PORT) +#endif +#if defined(STS_O6)||defined(STS_O7) #define sts_appctrlport (YUNHORN_STS_O7_USER_APP_CTRL_PORT) #define sts_appctrl_reply_port (YUNHORN_STS_O7_USER_APP_CTRL_REPLY_PORT) - +#endif #define NVM_CFG_PARAMETER_SIZE (STS_O7_NVM_CFG_SIZE) #define CFG_CMD_RSS_FULL_SIZE (STS_O7_CFG_CMD_SIZE) #define CFG_CMD_RSS_SIMPLE_SIZE (STS_O7_CFG_CMD_SHORT_LEN) @@ -265,7 +287,7 @@ #define I2C_TIMING_FAST_PLUS_MODE 0x20000209 //FAST PLUS MODE 1000Khz #endif -#endif /* YUNHORN_STS_O7_ENABLED */ +/* YUNHORN_STS_O7_ENABLED */ #ifdef YUNHORN_STS_E4_ENABLED @@ -362,8 +384,6 @@ #endif #define STS_BURN_IN_RFAC ((uint32_t) 2) - /* GMT+0800 China Standard Time */ -#define TIME_ZONE_SHIFT 8U /* STM32WL55JC READ/WRITE FLASH ADDRESS AND SIZE diff --git a/Core/Inc/yunhorn_sts_sensors.h b/Core/Inc/yunhorn_sts_sensors.h index 0808b71..c00e962 100644 --- a/Core/Inc/yunhorn_sts_sensors.h +++ b/Core/Inc/yunhorn_sts_sensors.h @@ -192,6 +192,8 @@ typedef struct STS_OO_SensorStatusDataTypeDef uint32_t event_sensor3_duration; uint32_t event_sensor4_start_time; uint32_t event_sensor4_duration; + uint8_t alarm_indictor_mute_state; + uint8_t alarm_indictor_reset_state; } STS_OO_SensorStatusDataTypeDef; //#endif @@ -570,11 +572,11 @@ typedef struct sts_cfg_nvm { uint8_t reserve02; uint8_t reserve03; - uint8_t reserve04; - uint8_t reserve05; - uint8_t reserve06; - uint8_t reserve07; - uint8_t reserve08; + uint8_t alarm_indictor_reset_state; + uint8_t alarm_indictor_mute_state; + uint8_t alarm_mute_or_reset_expire_timer_in_Sec; + uint8_t falldown_confirm_threshold_in_Sec; + uint8_t motionless_duration_threshold_in_Sec; uint8_t lamp_bar_flashing_color; //Lamp Bar Flashing color define, 0x20, 2==STS_RED, 0 = STS_DARK, 0x23, 2=STS_RED, 3=STS_BLUE uint8_t fall_detection_acc_threshold; // 0 - 9: 0:disable: 1-9 accelaration mg/s2 uint8_t fall_detection_depth_threshold; // 0 - 9: 0:disable: 1-9 fall down depth * 10 cm diff --git a/Core/Src/yunhorn_sts_process.c b/Core/Src/yunhorn_sts_process.c index 0efab91..978c4fe 100644 --- a/Core/Src/yunhorn_sts_process.c +++ b/Core/Src/yunhorn_sts_process.c @@ -704,7 +704,9 @@ void STS_PRESENCE_SENSOR_Function_Test_Process(uint8_t *self_test_result, uint8_ for (uint8_t i=0;i < count; i++) //while(1) { STS_Lamp_Bar_Self_Test_Simple(); - + sts_lamp_bar_color = STS_PINK; + STS_Lamp_Bar_Refresh(); + HAL_Delay(1000); sts_presence_rss_bring_up_test(bring_up_result); HAL_Delay(5000); @@ -712,8 +714,9 @@ void STS_PRESENCE_SENSOR_Function_Test_Process(uint8_t *self_test_result, uint8_ STS_PRESENCE_SENSOR_Distance_Measure_Process(); } + HAL_Delay(1000); - memcpy(self_test_result,bring_up_result, 10); + memcpy(self_test_result, bring_up_result, 10); mems_int1_detected=0; } diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 78b17d4..ad3a3df 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -110,11 +110,11 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = { }, // above 20 bytes 0x00, //reserve2 0x00, //reserve3 - 0x00, //reserve4 - 0x00, //reserve5 - 0x00, //reserve6 - 0x00, //reserve7 - 0x00, //reserve8 + 0x00, //reserve4 alarm_indictor_reset_state + 0x00, //reserve5 alarm_indictor_mute_state + 0x3C, //reserve6 60(0x3C) sec alarm_mute_or_reset_expire_timer_in_sec + 0x1E, //reserve7 0-60(0x3C) Sec, or 30(0x1E) sec default falldown_confirm_threshold_in_sec + 0x78, //reserve8 120(0x78) Sec (2 min.) motionless_duration_threshold_in_Sec // below 5 bytes 0x23, //Lamp Bar Flashing color define, 0x20, 2==STS_RED, 0 = STS_DARK, 0x23, 2=STS_RED, 3=STS_BLUE 0x01, //fall_detection_acc_threshold = *10 acceleration measure @@ -897,16 +897,19 @@ static void SendTxData(void) } AppData.BufferSize = (sts_service_mask > STS_SERVICE_MASK_L1? 0:i); - //AppData.BufferSize = (sts_service_mask > STS_SERVICE_MASK_L1? 0:i); + if( IsClockSynched == false ) { status = LmhpClockSyncAppTimeReq( ); + +#if 0 //debug line struct tm localtime; SysTime_t UnixEpoch = SysTimeGet(); UnixEpoch.Seconds -= 18; /*removing leap seconds*/ UnixEpoch.Seconds += 3600 * TIME_ZONE_SHIFT; /*adding time-zone-shift hours*/ SysTimeSet(UnixEpoch); SysTimeLocalTime(UnixEpoch.Seconds, &localtime); +#endif } @@ -1747,22 +1750,42 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size) outbuf[i++] = (uint8_t) MinorVer; outbuf[i++] = (uint8_t) SubMinorVer; - struct tm localtime; - SysTime_t UnixEpoch = SysTimeGet(); - UnixEpoch.Seconds -= 18; /*removing leap seconds*/ -// UnixEpoch.Seconds += 3600 * TIME_ZONE_SHIFT; /*adding time-zone-shift hours*/ -// SysTimeSet(UnixEpoch); - SysTimeLocalTime(UnixEpoch.Seconds, &localtime); - APP_LOG(TS_OFF, VLEVEL_M, "LTIME:%02dh%02dm%02ds on %02d/%02d/%04d\r\n", + struct tm localtime; + SysTime_t UnixEpoch = SysTimeGet(); + UnixEpoch.Seconds -= 18; /*removing leap seconds*/ + + UnixEpoch.Seconds += 3600 * 2; /*adding 2 hours*/ + + SysTimeLocalTime(UnixEpoch.Seconds, & localtime); + + APP_LOG(TS_OFF, VLEVEL_M, "LTIME:%02dh%02dm%02ds on %02d/%02d/%04d\r\n", localtime.tm_hour, localtime.tm_min, localtime.tm_sec, localtime.tm_mday, localtime.tm_mon + 1, localtime.tm_year + 1900); - outbuf[i++] = (uint8_t) localtime.tm_hour; - outbuf[i++] = (uint8_t) localtime.tm_min; - outbuf[i++] = (uint8_t) localtime.tm_sec; - outbuf[i++] = (uint8_t) localtime.tm_mday; - outbuf[i++] = (uint8_t) localtime.tm_mon+1; - outbuf[i++] = (uint8_t) (localtime.tm_year+1900-2000); +#if 0 + LmhPackage_t LmhpClockSyncPackageFactory; + LmhpClockSyncPackageFactory.Init; + if (LmhpClockSyncPackageFactory.IsInitialized) + LmhpClockSyncPackageFactory.Process; + + if (LORAMAC_HANDLER_SUCCESS == LmhpClockSyncAppTimeReq()) { + APP_LOG(TS_OFF, VLEVEL_M, "\r\n Clock Sync Success \r\n"); + } + SysTime_t mytime=SysTimeGet(); + struct tm mylocal; + SysTimeLocalTime((uint32_t)mytime.Seconds, &mylocal); + + APP_LOG(TS_OFF, VLEVEL_M, "\r\nTime YYYYMMDD=%4d:%2d:%2d HHMMSS=%2d:%2d:%2d \r\n", + mylocal.tm_year, mylocal.tm_mon, mylocal.tm_mday, mylocal.tm_hour, mylocal.tm_min, mylocal.tm_sec); + + outbuf[i++] = (uint8_t) mylocal.tm_year>>8&0xff; + outbuf[i++] = (uint8_t) mylocal.tm_year&0xff; + outbuf[i++] = (uint8_t) mylocal.tm_mon; + outbuf[i++] = (uint8_t) mylocal.tm_mday; + outbuf[i++] = (uint8_t) mylocal.tm_hour; + outbuf[i++] = (uint8_t) mylocal.tm_min; + outbuf[i++] = (uint8_t) mylocal.tm_sec; +#endif STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf); APP_LOG(TS_OFF, VLEVEL_M, "###### YUNHORN Report Version [ %10x ] \r\n", (uint8_t *)outbuf); } @@ -1927,7 +1950,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size) sts_cfg_nvm.sts_service_mask = (uint8_t)sts_service_mask; OnStoreSTSCFGContextRequest(); - APP_LOG(TS_OFF, VLEVEL_M, "###### YUNHORN HeartBeat or Sampling Interval Changed to [ %d ] Seconds\r\n", (heart_beat_or_sampling_periodicity_length/1000)); + //APP_LOG(TS_OFF, VLEVEL_M, "###### YUNHORN HeartBeat or Sampling Interval Changed to [ %d ] msec\r\n", (SamplingPeriodicity)); } else { STS_SENSOR_Upload_Config_Invalid_Message();