update decoder
This commit is contained in:
parent
890d31711f
commit
b4a29c440d
|
@ -117,7 +117,7 @@ function Decode(fPort, data, variables) {
|
|||
return { "Yunhorn_SmarToilets_data": data };
|
||||
}
|
||||
// Heart Beat
|
||||
else if (fPort === 20) {
|
||||
else if ((fPort === 20) || (fPort === 18)) {
|
||||
var data = {};
|
||||
data.led_state = (bytes[0] & 0x7f) === 0 ? "Off" : "On";
|
||||
data.battery_level = bytes[1] + " %";
|
||||
|
@ -136,15 +136,65 @@ function Decode(fPort, data, variables) {
|
|||
}
|
||||
|
||||
|
||||
if ((bytes[0] === 0x59) && (bytes[1] === 0x44)) {
|
||||
if ((bytes[0] === 0x59) && (bytes[1] === 0x44)) //Duration interval
|
||||
{
|
||||
data.Heart_beat_Duration = (bytes[2] - 0x30) * 10 + (bytes[3] - 0x30);
|
||||
data.Unit = String.fromCharCode(bytes[4]);
|
||||
}
|
||||
else if ((bytes[0] === 0x59) && (bytes[1] === 0x53)) {
|
||||
|
||||
else if ((bytes[0] === 0x59) && (bytes[1] === 0x53)) //Sampling interval or Heart-beat interval
|
||||
{
|
||||
data.Wakeup_sampling_interval = (bytes[2] - 0x30) * 10 + (bytes[3] - 0x30);
|
||||
data.Unit = String.fromCharCode(bytes[4]);
|
||||
}
|
||||
|
||||
else if (bytes[0] === 0x43) { // report current nvm config
|
||||
data.mtm_code1 = bytes[1];
|
||||
data.mtm_code2 = bytes[2];
|
||||
data.sts_verion = bytes[3];
|
||||
data.sts_hw_ver = bytes[4];
|
||||
data.sts_uplink_interval = bytes[5];
|
||||
data.sts_uplink_interval_unit = String.fromCharCode(bytes[6]);
|
||||
data.sts_sampling_interval = bytes[7];
|
||||
data.sts_sampling_interval_unit = String.fromCharCode(bytes[8]);
|
||||
data.sts_work_mode = bytes[9];
|
||||
data.sts_service_mask = bytes[10];
|
||||
data.sts_reserve01 = bytes[11];
|
||||
data.sts_payload_length = bytes[12];
|
||||
data.rss_start_distance = bytes[13] * 0.1 + " meter";
|
||||
data.rss_range_length = bytes[14] * 0.1 + " meter";
|
||||
data.rss_threshold = bytes[15] * 0.1;
|
||||
data.rss_receiving_gain = bytes[16] + " %";
|
||||
data.rss_profile = bytes[17];
|
||||
data.rss_rate_tracking = bytes[18];
|
||||
data.rss_rate_presence = bytes[19];
|
||||
data.rss_HWAAS = bytes[20];
|
||||
data.rss_nbr_removed_pc = bytes[21];
|
||||
data.rss_inter_frame_deviation_time_const = bytes[22] * 0.1;
|
||||
data.rss_inter_frame_fast_cutoff = bytes[23];
|
||||
data.rss_inter_frame_slow_cutoff = bytes[24];
|
||||
data.rss_intra_frame_time_const = bytes[25];
|
||||
data.rss_intra_frame_weight = bytes[26] * 0.1;
|
||||
data.rss_output_time_const = bytes[27] * 0.1;
|
||||
data.rss_downsampling_factor = bytes[28];
|
||||
data.rss_power_saving_mode_active = bytes[29];
|
||||
data.rss_reserve02 = bytes[30];
|
||||
data.rss_reserve03 = bytes[31];
|
||||
data.rss_reserve04 = bytes[32];
|
||||
data.reserve2 = bytes[33];
|
||||
data.reserve3 = bytes[34];
|
||||
data.reserve4 = bytes[35];
|
||||
data.reserve5 = bytes[36];
|
||||
|
||||
data.alarm_mute_expire_tier = bytes[37];
|
||||
data.fall_down_confirm_threshold = bytes[38];
|
||||
data.motionless_duration_threshold = bytes[39];
|
||||
data.lamp_bar_flashing_color = bytes[40];
|
||||
data.fall_detection_acc_threshold = bytes[41];
|
||||
data.fall_detection_depth_threshold = bytes[42];
|
||||
data.unconcious_threshold = bytes[43];
|
||||
data.occupancy_overtime_threshold = bytes[44];
|
||||
}
|
||||
else if (bytes[0] === 0x53) { // SELF TEST FUNCTION
|
||||
data.mtm_code1 = bytes[1];
|
||||
data.mtm_code2 = bytes[2];
|
||||
|
@ -164,7 +214,23 @@ function Decode(fPort, data, variables) {
|
|||
data.sts_rss_sub_code10 = bytes[16];
|
||||
data.sts_sensor_install_height = String.fromCharCode(bytes[17]) + String.fromCharCode(bytes[18]) + String.fromCharCode(bytes[19]) + String.fromCharCode(bytes[20]) + " mm";
|
||||
}
|
||||
else if (bytes[0] === 0x56) {
|
||||
else if (bytes[0] === 0x44) { // MEASURE INSTALLATION HEIGHT
|
||||
data.mtm_code1 = bytes[1];
|
||||
data.mtm_code2 = bytes[2];
|
||||
data.sts_verion = bytes[3];
|
||||
data.sts_hw_ver = bytes[4];
|
||||
data.battery_level = bytes[5];
|
||||
data.payload_length = bytes[6];
|
||||
data.Measure_Distance = String.fromCharCode(bytes[7]) + String.fromCharCode(bytes[8]) + String.fromCharCode(bytes[9]) + String.fromCharCode(bytes[10]);
|
||||
data.Distance_unit = "mm";
|
||||
}
|
||||
else if (bytes[0] === 0x4c) {
|
||||
data.mtm_code1 = bytes[1];
|
||||
data.mtm_code2 = bytes[2];
|
||||
data.sts_verion = bytes[3];
|
||||
data.LoRaWAN_Class = String.fromCharCode(bytes[4]);
|
||||
}
|
||||
else if (bytes[0] === 0x56) { // FIRMWARE VERSION
|
||||
|
||||
data.mtm_code1 = bytes[1];
|
||||
data.mtm_code2 = bytes[2];
|
||||
|
|
|
@ -598,9 +598,10 @@ typedef struct sts_cfg_nvm {
|
|||
uint8_t reserve03;
|
||||
uint8_t reserve04;
|
||||
uint8_t reserve05;
|
||||
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 alarm_mute_or_reset_expire_timer_in_Sec;//60(0x3C) sec alarm_mute_or_reset_expire_timer_in_sec
|
||||
uint8_t falldown_confirm_threshold_in_Sec; //0-60(0x3C) Sec, or 30(0x1E) sec default falldown_confirm_threshold_in_sec
|
||||
uint8_t motionless_duration_threshold_in_Sec; //120(0x78) Sec (2 min.) 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
|
||||
|
|
|
@ -85,7 +85,7 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = {
|
|||
'M', //Uplink data interval for heart-beat uplink
|
||||
0x01,
|
||||
'S', //Sampling sensor interval for real-time sensing of MEMS
|
||||
0x04, // dual mode
|
||||
0x04, // dual mode=4, uni_mode =5
|
||||
0x00, // service mask
|
||||
0x00, //reserve01
|
||||
0x20, //32 bytes, below start of p[0] 20 BYTES AND 12 BYTES FALL DOWN CFG
|
||||
|
@ -113,8 +113,8 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = {
|
|||
}, // above 20 bytes
|
||||
0x00, //reserve2
|
||||
0x00, //reserve3
|
||||
0x00, //reserve4 alarm_indictor_reset_state
|
||||
0x00, //reserve5 alarm_indictor_mute_state
|
||||
0x00, //reserve4
|
||||
0x00, //reserve5
|
||||
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
|
||||
|
@ -1877,8 +1877,6 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
|
|||
uint8_t cfg_in_nvm[YUNHORN_STS_MAX_NVM_CFG_SIZE]="";
|
||||
OnRestoreSTSCFGContextRequest((uint8_t *)cfg_in_nvm);
|
||||
i=0;
|
||||
|
||||
|
||||
outbuf[i++] = (uint8_t) 'C';
|
||||
outbuf[i++] = (uint8_t) cfg_in_nvm[NVM_MTM1]; //MTM Code
|
||||
outbuf[i++] = (uint8_t) cfg_in_nvm[NVM_MTM2]; //MTM Code
|
||||
|
|
Loading…
Reference in New Issue