From 06ecec96b1df20fe0334bb9970b6d92b16b82bf3 Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Wed, 25 Sep 2024 16:22:59 +0800 Subject: [PATCH] revised for P-CMD parse --- STS/Core/Inc/yunhorn_sts_prd_conf.h | 2 +- STS/Core/Src/yunhorn_sts_process.c | 56 ++++++++++++++++++++++++++--- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/STS/Core/Inc/yunhorn_sts_prd_conf.h b/STS/Core/Inc/yunhorn_sts_prd_conf.h index 023277a..d2efb7c 100644 --- a/STS/Core/Inc/yunhorn_sts_prd_conf.h +++ b/STS/Core/Inc/yunhorn_sts_prd_conf.h @@ -193,7 +193,7 @@ enum sts_lamp_color { STS_REEDSWITCH_MODE, // 2 REED SWITCH ONLY STS_RSS_MODE, // 3 RSS ONLY STS_DUAL_MODE, // 4 RSS + REED SWITCH IN ONE UNIT - STS_REMOTE_REED_RSS_MODE, // 5 REMOTE REED SWITCH + RSS MODE 2023-05-04 + STS_UNI_MODE, // 5 RSS + REEDSWITCH +PIR + TOF 2023-09-24 STS_DUAL_RSS_MODE, // 6 RSS_1 + RSS_2 IN TWO UNITS STS_TOF_RSS_MODE, // 7 TOF + RSS MODE STS_TOF_DISTANCE_MODE, // 8 TOF DISTANCE diff --git a/STS/Core/Src/yunhorn_sts_process.c b/STS/Core/Src/yunhorn_sts_process.c index cfaf93d..ab787ac 100644 --- a/STS/Core/Src/yunhorn_sts_process.c +++ b/STS/Core/Src/yunhorn_sts_process.c @@ -513,6 +513,52 @@ void STS_O5_SENSOR_Read(STS_OO_SensorDataTypeDef *oo_data) void USER_APP_Parse_CMD_P(uint8_t *parse_buffer, uint8_t parse_buffer_size) { + switch (parse_buffer_size) { + + case 4: + sts_work_mode = (uint8_t)(parse_buffer[CFG_CMD4]-0x30); + switch (sts_work_mode) { + case STS_NETWORK_MODE: + + break; + case STS_WIRED_MODE: // STS-O2 + + break; + case STS_REEDSWITCH_MODE: // STS-O2 + break; + case STS_RSS_MODE: // STS-O6 + break; + case STS_DUAL_MODE: // STS-O6 + break; + case STS_UNI_MODE: // STS-O7 + break; + case STS_DUAL_RSS_MODE: + break; + case STS_TOF_RSS_MODE: // STS-O7T + break; + case STS_TOF_DISTANCE_MODE: // STS-R1/R2/R5/R1D + break; + case STS_TOF_PRESENCE_MODE: // STS-O6T + break; + case STS_TOF_IN_OUT_MODE: // STS-P2 + break; + case STS_FALL_DETECTION_MODE: // STS-O7F + break; + case STS_OTHER_MODE: + break; + default: + break; + } + break; + case 5: + break; + case 12: + break; + default: + break; + } + + } // following to be fill up #if 0 @@ -1604,14 +1650,14 @@ void STS_SENSOR_Function_Test_Process(void) #ifdef STS_P2 STS_SENSOR_MEMS_Get_ID(&sensor_id); - if (((sensor_id & 0xff)!= 0xCC) || (((sensor_id >>8) & 0xFF)!=0xEA)) // no VL53LX found + if (((sensor_id & 0xff)!= 0xCC) && (((sensor_id >>8) & 0xFF)!=0xEA)) // no VL53L1X found { tstbuf[i++] = (uint8_t) 'X'; // Slave MEMS Not Avaliable } else { STS_SENSOR_Distance_Test_Process(); APP_LOG(TS_OFF, VLEVEL_M, "\nSensor Install Height =%4d mm\n", sts_sensor_install_height); - tstbuf[i++] = (uint8_t) (2+1)&0xff; //length of following data + tstbuf[i++] = (uint8_t) (2)&0xff; //length of following data tstbuf[i++] = (uint8_t) (sts_sensor_install_height>>8)&0xff; // MSB of sensor height tstbuf[i++] = (uint8_t) (sts_sensor_install_height)&0xff; // LSB of sensor height } @@ -1633,8 +1679,11 @@ 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)||defined(YUNHORN_STS_R1_ENABLED)) +#if (defined(STS_R1D)) tstbuf[i++] = (uint8_t) (4)&0xff; +#elif (defined(STS_R5)||defined(STS_R1)) + tstbuf[i++] = (uint8_t) (2)&0xff; +#endif //MX_TOF_Process(); #ifdef STS_P2 MX_TOF_Init(); @@ -1659,7 +1708,6 @@ void STS_SENSOR_Function_Test_Process(void) tstbuf[i++] = (uint8_t) (sts_tof_distance_data[2] &0xff); #endif -#endif UTIL_MEM_set_8((void*)outbuf,0x0,sizeof(outbuf)); UTIL_MEM_cpy_8((void*)outbuf, tstbuf, i);