diff --git a/Core/Inc/yunhorn_sts_sensors.h b/Core/Inc/yunhorn_sts_sensors.h index 45a921d..83f635c 100644 --- a/Core/Inc/yunhorn_sts_sensors.h +++ b/Core/Inc/yunhorn_sts_sensors.h @@ -168,6 +168,8 @@ typedef struct STS_OO_SensorStatusDataTypeDef uint8_t state_sensor3_on_off; /* urinal_sensor_on_off urinal sensor state */ uint8_t state_sensor4_on_off; /* reserved_sensor_on_off sensor state */ uint16_t rss_presence_distance; // in mm + uint8_t rss_presence_zone[10]; + uint8_t rss_presence_zone_count[10]; uint16_t rss_presence_score; // in 1000*score uint8_t unconcious_state; uint16_t unconcious_threshold; diff --git a/Core/Src/yunhorn_sts_process.c b/Core/Src/yunhorn_sts_process.c index e6e9312..2fa09cd 100644 --- a/Core/Src/yunhorn_sts_process.c +++ b/Core/Src/yunhorn_sts_process.c @@ -747,6 +747,9 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(void) // } } + + + #if 0 void STS_PRESENCE_SENSOR_Read(STS_OO_SensorStatusDataTypeDef *oo_data) { diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index fc8877f..e668977 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -905,25 +905,31 @@ static void SendTxData(void) UTIL_TIMER_Time_t nextTxIn = 0; uint8_t i = 0; - APP_LOG(TS_OFF, VLEVEL_L, "\r\n\n\n**** heart_beat timer =%2u \r\n**** sensor_data_ready=%2u\r\n", - heart_beat_timer, sensor_data_ready); - if (LmHandlerIsBusy() == false) + if (LmHandlerIsBusy() != false){ + APP_LOG(TS_OFF, VLEVEL_L, "\r\n\n\n** ** LmHandlerIsBusy ** **\r\n\n\n"); + } else { AppData.Port = LORAWAN_USER_APP_PORT; //AppData.Buffer[i++] = AppLedStateOn; //#01 + STS_PRESENCE_SENSOR_Prepare_Send_Data(); if ((heart_beat_timer != 0L)) // sensor data OVERWRITE heart-beat message, 2024-05-12 { + heart_beat_timer=0; AppData.Port = sts_sendhtbtport; //LORAWAN_USER_APP_PORT+1; AppData.Buffer[i++]= AppLedStateOn|0x80; AppData.Buffer[i++] = (uint8_t)(99*batteryLevel/254)&0xff; //#05 } else if ((upload_message_timer != 0U)||(sensor_data_ready!= 0U)) //sensor_data_ready for manual push button-1 trigger) { - //AppData.Buffer[i++] = AppLedStateOn; + + sensor_data_ready =0; + + + AppData.Buffer[i++] = AppLedStateOn; //i = PrepareSendTxData(); - STS_PRESENCE_SENSOR_Prepare_Send_Data(); + //STS_PRESENCE_SENSOR_Prepare_Send_Data(); AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.lamp_bar_color)&0xff; //01 AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.workmode)&0xff; //02 WORK MODE @@ -934,21 +940,34 @@ static void SendTxData(void) #if 1 AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor4_on_off)&0xff; //06 Sensor head #4 status #endif - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor4_on_off)&0xff; //06 Sensor head #4 status - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor4_on_off)&0xff; //06 Sensor head #4 status - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor4_on_off)&0xff; //06 Sensor head #4 status + AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor1_on_off)&0xff; //06 Sensor head #4 status + AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor2_on_off)&0xff; //06 Sensor head #4 status + AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor3_on_off)&0xff; //06 Sensor head #4 status AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor4_on_off)&0xff; //06 Sensor head #4 status //if (o7_data.state_sensor2_on_off != 0) // REF: AppData.Buffer[i++] = (uint8_t)(r0_data.distance_mm >>8)&0xff; //#05 // REF: AppData.Buffer[i++] = (uint8_t)(r0_data.distance_mm)&0xff; //{ #if 0 + AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor1_on_off)&0xff; //06 Sensor head #4 status + AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor2_on_off)&0xff; //06 Sensor head #4 status + AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor3_on_off)&0xff; //06 Sensor head #4 status + + AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor4_on_off)&0xff; //06 Sensor head #4 status + + AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor1_on_off)&0xff; //06 Sensor head #4 status + AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor2_on_off)&0xff; //06 Sensor head #4 status + AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor3_on_off)&0xff; //06 Sensor head #4 status + AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor4_on_off)&0xff; //06 Sensor head #4 status + + AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.fall_state)&0xff; //06 Sensor head #4 status + AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.rss_presence_distance>>8)&0xff; //07 MSB distance - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.rss_presence_distance)&0xff; //08 LSB distance + AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.rss_presence_distance)&0xff; //08 LSB distance - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.rss_presence_score>>8)&0xff; //09 MSB score + AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.rss_presence_score>>8)&0xff; //09 MSB score - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.rss_presence_score)&0xff; //10 LSB score + AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.rss_presence_score)&0xff; //10 LSB score //} #endif #if 0 @@ -972,10 +991,6 @@ static void SendTxData(void) #endif } - heart_beat_timer=0; - sensor_data_ready =0; - upload_message_timer =0; - AppData.BufferSize = (sts_service_mask > STS_SERVICE_MASK_L1? 0:i);