try fix port 0 issue

This commit is contained in:
Yunhorn 2024-05-10 21:04:45 +08:00
parent d7fed51854
commit a10ec2dde2
4 changed files with 60 additions and 12 deletions

View File

@ -399,7 +399,7 @@ int sts_presence_rss_fall_rise_detection(void)
}
acc_detector_presence_deactivate(handle);
APP_LOG(TS_OFF, VLEVEL_M,"First Half Presence Detection, Motion Count = %u \r\n", (int)motion_count);
APP_LOG(TS_OFF, VLEVEL_H,"First Half Presence Detection, Motion Count = %u \r\n", (int)motion_count);
// ******** Second Half detection of fall down and rise up
@ -457,7 +457,7 @@ int sts_presence_rss_fall_rise_detection(void)
acc_integration_sleep_ms(1000 / DEFAULT_UPDATE_RATE_PRESENCE); // DEFAULT_UPDATE_RATE);
}
APP_LOG(TS_OFF, VLEVEL_M,"Second Half, Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count);
APP_LOG(TS_OFF, VLEVEL_H,"Second Half, Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count);
sts_rss_result = (average_result > 3)? 1: 0;
average_distance = (1000.0f*average_distance)/average_result; // in meters
@ -466,7 +466,7 @@ int sts_presence_rss_fall_rise_detection(void)
sts_presence_rss_score = average_score;
if (average_score) //if (average_score !=0) //if (sts_rss_result)
{
APP_LOG(TS_OFF, VLEVEL_M,"\r\n######## Motion: %u Distance=%u mm, Score=%u Average_result=%u out of %u \r\n",
APP_LOG(TS_OFF, VLEVEL_H,"\r\n######## Motion: %u Distance=%u mm, Score=%u Average_result=%u out of %u \r\n",
(uint8_t)sts_rss_result,(int) average_distance, (int)(average_score), (int)average_result, (int)iterations);
}

View File

@ -600,7 +600,7 @@ void STS_FallDetection_LampBarProcess(void)
APP_LOG(TS_OFF, VLEVEL_L, "\r\n <<<<<<<<<<<<<< Fall Rise state=%d, send buf size = %25s \r\n",
sts_presence_fall_detection_message[sts_fall_rising_detected_result], i )
STS_SENSOR_Upload_Message((LORAWAN_USER_APP_PORT+2), i, buf);
STS_SENSOR_Upload_Message((LORAWAN_USER_APP_PORT+2), i, (char*)buf);
sts_fall_rising_detected_result = STS_PRESENCE_NONE;

View File

@ -916,19 +916,66 @@ static void SendTxData(void)
heart_beat_timer = 0U;
AppData.Port = sts_sendhtbtport; //LORAWAN_USER_APP_PORT+1;
AppData.Buffer[i++]= AppLedStateOn|0x80;
AppData.Buffer[i++] = (uint8_t)(0xFF & (99*batteryLevel/254)); //#05
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)
{
sensor_data_ready =0;
upload_message_timer =0;
//AppData.Buffer[i++] = AppLedStateOn;
i = PrepareSendTxData();
}
// i = PrepareSendTxData();
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
AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor1_on_off)&0xff; //03 Sensor head #1 status
AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor2_on_off)&0xff; //04 Sensor head #2 status
AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor3_on_off)&0xff; //05 Sensor head #3 status
#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_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.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_score>>8)&0xff; //09 MSB score
AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.rss_presence_score)&0xff; //10 LSB score
//}
#endif
#if 0
AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.unconcious_state)&0xff; //11 unconcious state detected or not
AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.fall_state)&0xff; //12 fall detected or not
AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.overtime)&0xff; //13 occupancy over time or not
AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.over_stay_duration>>8)&0xff; //13 occupancy over time or not
AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.over_stay_duration)&0xff; //13 occupancy over time or not
#endif
#if 0
APP_LOG(TS_OFF, VLEVEL_L,
"\r\n######| Color | Mode |\r\n######| %4s | %5s |\r\n",(char *)sts_lamp_color_code[(uint8_t)(AppData.Buffer[0])], (char*)sts_work_mode_code[AppData.Buffer[1]]);
APP_LOG(TS_OFF, VLEVEL_L,
"\r\n######| S1-DoorOpen | S2-Motion | S3-No_Emergency | S4 |Distance(mm) | MotionScore| Unconcious | Over_Stay| Fall Detected|"
"\r\n######| %1d | %1d | %1d | %1d | %04d | %04d | %1d | %1d | %1d |\r\n",
AppData.Buffer[2], AppData.Buffer[3],AppData.Buffer[4], AppData.Buffer[5],
(uint16_t)sts_o7_sensorData.rss_presence_distance,(uint16_t)sts_o7_sensorData.rss_presence_score,
sts_o7_sensorData.unconcious_state, sts_o7_sensorData.unconcious_duration, sts_o7_sensorData.fall_state );
#endif
}
AppData.BufferSize = (sts_service_mask > STS_SERVICE_MASK_L1? 0:i);
APP_LOG(TS_OFF, VLEVEL_L, "\r\n\n\n** ** AppData.PORT =%3d ** ** AppData.BufferSize=%3d ** Count Size=%3d\r\n", AppData.Port, AppData.BufferSize, i);
if (i!=0)
{
AppData.BufferSize = (sts_service_mask > STS_SERVICE_MASK_L1? 0:i);
//AppData.BufferSize = (sts_service_mask > STS_SERVICE_MASK_L1? 0:i);
if ((JoinLedTimer.IsRunning) && (LmHandlerJoinStatus() == LORAMAC_HANDLER_SET))
{
@ -2103,9 +2150,10 @@ void STS_SENSOR_Upload_Message(uint8_t appDataPort, uint8_t appBufferSize, char
if (LmHandlerIsBusy() == false)
{
for (uint8_t i=0;i<appBufferSize; i++) {
AppData.Buffer[i] = appDataBuffer[i];
}
//for (uint8_t i=0;i<appBufferSize; i++) {
// AppData.Buffer[i] = appDataBuffer[i];
// }
UTIL_MEM_cpy_8(AppData.Buffer, appDataBuffer, appBufferSize);
AppData.Port = appDataPort;
AppData.BufferSize = (sts_service_mask >1 ?0:appBufferSize);
@ -2411,7 +2459,7 @@ void STS_SENSOR_Function_Test_Process(void)
memset((void*)outbuf,0x0, sizeof(outbuf));
memcpy((void*)outbuf, tstbuf, i);
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (char*)outbuf);
}

Binary file not shown.