workable L8
This commit is contained in:
parent
a80b70e3dd
commit
c8d616916b
|
@ -612,23 +612,26 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||
{
|
||||
case BUT1_Pin:
|
||||
/* Note: when "EventType == TX_ON_TIMER" this GPIO is not initialized */
|
||||
HAL_Delay(150);
|
||||
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
|
||||
HAL_Delay(250);
|
||||
//__HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
|
||||
sts_hall1_read = HALL1_STATE;
|
||||
if (last_sts_hall1_read != sts_hall1_read) // to eliminate power drop issue of PCB with long REEDSWITCH CABLES
|
||||
{
|
||||
// 1) record event start/stop time
|
||||
APP_LOG(TS_OFF, VLEVEL_M,"\r\n EXIT_CALLBACK, Door state =%d \r\n", sts_hall1_read);
|
||||
OnSensor1StateChanged();
|
||||
// 2) change lamp bar color
|
||||
if (sts_hall1_read == STS_Status_Door_Close)
|
||||
{
|
||||
sts_lamp_bar_color = STS_OCCUPANCY_NORMAL_COLOR;
|
||||
sts_status_color = STS_OCCUPANCY_NORMAL_COLOR;
|
||||
//APP_LOG(TS_OFF, VLEVEL_M,"\r\n EXIT_CALLBACK, Door CLOSED: sts status color =%d, lampbar_color=%d \r\n", sts_status_color, sts_lamp_bar_color);
|
||||
// APP_LOG(TS_OFF, VLEVEL_M,"\r\n EXIT_CALLBACK, Door CLOSED: sts status color =%d, lampbar_color=%d \r\n", sts_status_color, sts_lamp_bar_color);
|
||||
} else
|
||||
{
|
||||
//sts_lamp_bar_color = prev_color;
|
||||
sts_status_color = STS_VACANT_COLOR;
|
||||
sts_lamp_bar_color = STS_VACANT_COLOR;
|
||||
//APP_LOG(TS_OFF, VLEVEL_M,"\r\n EXTI_CALLBACK, Door Open: sts status color =%d, lampbar_color=%d \r\n", sts_status_color, sts_lamp_bar_color);
|
||||
// APP_LOG(TS_OFF, VLEVEL_M,"\r\n EXTI_CALLBACK, Door Open: sts status color =%d, lampbar_color=%d \r\n", sts_status_color, sts_lamp_bar_color);
|
||||
}
|
||||
// 3) combine states and colors
|
||||
//STS_YunhornSTSEventP1_Process();
|
||||
|
@ -645,6 +648,9 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
last_sts_hall1_read = sts_hall1_read;
|
||||
} else {
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n --- ---- ----- -------- hall 1, door close again \r\n");
|
||||
}
|
||||
break;
|
||||
|
||||
#ifndef STS_R4
|
||||
|
@ -946,7 +952,7 @@ void STS_SENSOR_Upload_Message(uint8_t appDataPort, uint8_t appBufferSize, uint8
|
|||
AppData.Port = appDataPort;
|
||||
AppData.BufferSize = appBufferSize;
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\n\r AppPort=%d BufferSize=%d \r\n", AppData.Port,AppData.BufferSize);
|
||||
//APP_LOG(TS_OFF, VLEVEL_M, "\n\r AppPort=%d BufferSize=%d \r\n", AppData.Port,AppData.BufferSize);
|
||||
|
||||
status = LmHandlerSend(&AppData, LmHandlerParams.IsTxConfirmed, false);
|
||||
if (LORAMAC_HANDLER_SUCCESS == status)
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -52,7 +52,7 @@ uint32_t sts_hmac_verify(void)
|
|||
|
||||
hmac_result.ac_pass = (ret == 0x0)?1U:0U;
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nHMAC Verify Success = %u \r\n", hmac_result.ac_pass);
|
||||
//APP_LOG(TS_OFF, VLEVEL_M, "\r\nHMAC Verify Success = %u \r\n", hmac_result.ac_pass);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -346,7 +346,7 @@ void STS_YunhornSTSEventRFAC_Process(void)
|
|||
}
|
||||
}
|
||||
#if 1
|
||||
if ((rfac_timer > (STS_BURN_IN_RFAC + 3)))
|
||||
if ((rfac_timer >= (STS_BURN_IN_RFAC + 3)))
|
||||
{
|
||||
//APP_LOG(TS_OFF, VLEVEL_M, "\r\n -Verify RFAC Success or Not\r\n");
|
||||
STS_YunhornAuthenticationCode_Process();
|
||||
|
@ -1335,8 +1335,9 @@ void USER_APP_AUTO_RESPONDER_Parse(uint8_t *parse_buffer, uint8_t parse_buffer_s
|
|||
outbuf[i++] = (uint8_t) (cfg_in_nvm[NVM_CFG_START+j]);
|
||||
}
|
||||
#endif
|
||||
UTIL_MEM_cpy_8(outbuf, cfg_in_nvm,44);
|
||||
i=44;
|
||||
outbuf[i++] = (uint8_t) 'C';
|
||||
UTIL_MEM_cpy_8(outbuf+1, cfg_in_nvm,44);
|
||||
i=45;
|
||||
STS_SENSOR_Upload_Message(YUNHORN_STS_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
|
||||
|
||||
break;
|
||||
|
@ -1578,6 +1579,7 @@ void USER_APP_AUTO_RESPONDER_Parse(uint8_t *parse_buffer, uint8_t parse_buffer_s
|
|||
sts_service_mask = STS_SERVICE_MASK_L0;
|
||||
|
||||
sts_cfg_nvm.sts_service_mask = sts_service_mask;
|
||||
//APP_LOG(TS_OFF, VLEVEL_M, "\r\n Good ac code, start to store in NVM \r\n");
|
||||
OnStoreSTSCFGContextRequest();
|
||||
|
||||
|
||||
|
@ -1732,17 +1734,19 @@ void OnStoreSTSCFGContextRequest(void)
|
|||
to_store__value[i++] = sts_cfg_nvm.fall_detection_depth_threshold;
|
||||
to_store__value[i++] = sts_cfg_nvm.fall_confirm_threshold_in_10sec;
|
||||
#endif
|
||||
if ((nvm_store_value[NVM_AC_CODE_START]!= 0x0) && (nvm_store_value[NVM_AC_CODE_START+19]!=0x0))
|
||||
|
||||
if ((nvm_store_value[NVM_AC_CODE_START]!= 0x0) && (nvm_store_value[NVM_AC_CODE_START+19]!=0x0)&&(nvm_store_value[NVM_AC_CODE_START]!= 0xff) && (nvm_store_value[NVM_AC_CODE_START+19]!=0xff))
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\n\r Transfer good NVM Stored ac_code to NVM_STORE_VALUE\r\n");
|
||||
//APP_LOG(TS_OFF, VLEVEL_M, "\n\r Transfer good NVM Stored ac_code to NVM_STORE_VALUE\r\n");
|
||||
UTIL_MEM_cpy_8((void*)&to_store__value[NVM_AC_CODE_START], (void*)&nvm_store_value[NVM_AC_CODE_START],YUNHORN_STS_AC_CODE_SIZE);
|
||||
} else if ((sts_ac_code[0]!=0x0) && (sts_ac_code[YUNHORN_STS_AC_CODE_SIZE-1]!=0x0))
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\n\r Transfer new generated ac_code to NVM_STORE_VALUE\r\n");
|
||||
//APP_LOG(TS_OFF, VLEVEL_M, "\n\r Transfer new generated ac_code to NVM_STORE_VALUE\r\n");
|
||||
UTIL_MEM_cpy_8((void*)&to_store__value[NVM_AC_CODE_START], (void*)sts_ac_code,YUNHORN_STS_AC_CODE_SIZE);
|
||||
UTIL_MEM_cpy_8((void*)&nvm_store_value[NVM_AC_CODE_START], (void*)sts_ac_code,YUNHORN_STS_AC_CODE_SIZE);
|
||||
}
|
||||
|
||||
|
||||
/* USER CODE END OnStoreContextRequest_1 */
|
||||
/* store nvm in flash */
|
||||
|
||||
|
@ -1902,6 +1906,7 @@ void OnRestoreSTSCFGContextProcess(void)
|
|||
|
||||
sts_work_mode = sts_cfg_nvm.work_mode;
|
||||
sts_service_mask = sts_cfg_nvm.sts_service_mask;
|
||||
sts_sensor_install_height = sts_cfg_nvm.sensor_install_height_in_10cm*100;
|
||||
|
||||
#ifdef YUNHORN_STS_O6_ENABLED
|
||||
sts_lamp_bar_color = STS_GREEN;
|
||||
|
@ -2063,26 +2068,23 @@ void STS_SENSOR_Distance_Test_Process(void)
|
|||
//MX_TOF_Init();
|
||||
STSWakeupScanTimerStop();
|
||||
//STS_TOF_L8_Process();
|
||||
|
||||
uint32_t range_once=0;
|
||||
|
||||
//MX_TOF_Process();
|
||||
uint32_t range_once=0, range_sum=0;
|
||||
uint8_t rpt=0;
|
||||
for (rpt=0; rpt<3; rpt++)
|
||||
do
|
||||
{
|
||||
range_once = range_once + (uint16_t)MX_TOF_Ranging_Process();
|
||||
//APP_LOG(TS_OFF, VLEVEL_M, "\r\n Range_once=%d \r\n", range_once);
|
||||
range_once = (uint16_t)MX_TOF_Ranging_Process();
|
||||
if (range_once > 0)
|
||||
{
|
||||
rpt++;
|
||||
range_sum += range_once ;
|
||||
}
|
||||
HAL_Delay(150);
|
||||
}
|
||||
}while (rpt<3);
|
||||
|
||||
range_once /= 3;
|
||||
range_sum /= 3;
|
||||
sts_sensor_install_height = range_sum;
|
||||
|
||||
//APP_LOG(TS_OFF, VLEVEL_M, "\r\n Range_once=%d \r\n", range_once);
|
||||
|
||||
sts_sensor_install_height = range_once; //(uint16_t)MX_TOF_Ranging_Process();
|
||||
|
||||
//sts_sensor_install_height = (uint16_t)STS_Get_Center_Range_Distance();
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\n STS SENSOR INSTALLATION HEIGHT =%d mm\n\r", (uint16_t)sts_sensor_install_height);
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "\n STS SENSOR INSTALLATION HEIGHT =%d mm\n\r", (uint16_t)sts_sensor_install_height);
|
||||
|
||||
STS_LMZ_Ambient_Height_Scan_Process();
|
||||
|
||||
|
@ -2503,7 +2505,7 @@ void YunhornSTSDurationCheckTimer(void)
|
|||
fhmos_cfg.th_fall_duration_potential_15sec*15,
|
||||
fhmos_cfg.th_fall_duration_confirm_15sec*15);
|
||||
#endif
|
||||
if ((sts_o7_sensorData.event_sensor3_fall_duration >= fhmos_cfg.th_fall_duration_confirm_15sec*15) &&
|
||||
if ((sts_o7_sensorData.event_sensor3_fall_duration >= (fhmos_cfg.th_fall_duration_potential_15sec*15 + fhmos_cfg.th_fall_duration_confirm_15sec*15)) &&
|
||||
(STS_FHMOS_FALL_STATE_POTENTIAL ==fhmos_data.state_fall))
|
||||
{
|
||||
uint32_t time_stamp=STS_Get_Date_Time_Stamp(); //uint8_t datetimestamp[8]={0};
|
||||
|
@ -2527,15 +2529,12 @@ void YunhornSTSDurationCheckTimer(void)
|
|||
|
||||
|
||||
} else if ((sts_o7_sensorData.event_sensor3_fall_duration >= fhmos_cfg.th_fall_duration_potential_15sec*15) &&
|
||||
(sts_o7_sensorData.event_sensor3_fall_duration < fhmos_cfg.th_fall_duration_confirm_15sec*15) &&
|
||||
(sts_o7_sensorData.event_sensor3_fall_duration < (fhmos_cfg.th_fall_duration_potential_15sec*15 + fhmos_cfg.th_fall_duration_confirm_15sec*15)) &&
|
||||
(STS_FHMOS_FALL_STATE_NORMAL == fhmos_data.state_fall)) //fhmos_cfg.th_motionless_long_15sec*15))
|
||||
{
|
||||
// stay this state until > long threshold
|
||||
fhmos_data.state_fall = STS_FHMOS_FALL_STATE_POTENTIAL;
|
||||
fhmos_data.state_fall_released = 0;
|
||||
// APP_LOG(TS_OFF, VLEVEL_M, "\r\n 002 Fall State =%d \r\n", fhmos_data.state_fall);
|
||||
// sts_lamp_bar_color = STS_FALL_SUSPICIOUS_COLOR;
|
||||
// APP_LOG(TS_OFF, VLEVEL_M, "\r\nSensor L8 set FALL POTENTIAL color to %d color:%s \r\n",sts_lamp_bar_color, (char*) code2color[sts_lamp_bar_color]);
|
||||
|
||||
over_threshold |= 1<<7;
|
||||
// APP_LOG(TS_OFF, VLEVEL_M, "\r\n 1<<7 Over Threshold =0x%02x \r\n", over_threshold);
|
||||
|
@ -2662,7 +2661,7 @@ void YunhornSTSDurationCheckTimer(void)
|
|||
// APP_LOG(TS_OFF, VLEVEL_M, "\r\n Over Threshold =0x%02x \r\n", over_threshold);
|
||||
last_sts_cmb_result = sts_cmb_result;
|
||||
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
// UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
}
|
||||
|
||||
over_threshold = 0;
|
||||
|
@ -3025,7 +3024,7 @@ void OnSensorL8AStateChanged(void)
|
|||
|
||||
sts_fhmos_state_changed = 1;
|
||||
|
||||
} else if ((sts_head_level_low == 0) && (last_head_level_low_state ==1))
|
||||
} else if ((sts_head_level_low == 0) && (last_head_level_low_state ==1)&&(STS_Status_Door_Close==sts_hall1_read))
|
||||
{
|
||||
fhmos_data.head_low_level_stop_time = sensor_event_time.Seconds;
|
||||
fhmos_data.state_fall = STS_FHMOS_FALL_STATE_NORMAL;
|
||||
|
|
|
@ -83,7 +83,8 @@ static uint32_t STS_Get_Center_Range_Distance(RANGING_SENSOR_Result_t *Result);
|
|||
*/
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
#define TIMING_BUDGET (30U) /* 16 ms < TimingBudget < 500 ms */
|
||||
//#define TIMING_BUDGET (30U) /* 16 ms < TimingBudget < 500 ms */
|
||||
#define TIMING_BUDGET (50U) /* 16 ms < TimingBudget < 500 ms */
|
||||
#define POLLING_PERIOD (250U) /* refresh rate for polling mode (milliseconds, shall be consistent with TimingBudget value) */
|
||||
|
||||
#ifdef L8
|
||||
|
@ -197,6 +198,8 @@ void STS_LMZ_Ambient_Height_Scan_Process(void)
|
|||
|
||||
sts_high_threshold = sts_sensor_install_height;
|
||||
sts_low_threshold = sts_sensor_install_height-1400;
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nReconfig ----> Threshold High=%d mm, Low=%d mm \r\n", sts_high_threshold, sts_low_threshold);
|
||||
|
||||
STS_TOF_L8_Reconfig();
|
||||
|
||||
status = VL53L8A1_RANGING_SENSOR_Start(VL53L8A1_DEV_CENTER, RS_MODE_ASYNC_CONTINUOUS);
|
||||
|
@ -521,6 +524,10 @@ static void MX_53L8A1_ThresholdDetection_Process(void)
|
|||
//ITConfig.LowThreshold = LOW_THRESHOLD; /* mm */
|
||||
//ITConfig.HighThreshold = HIGH_THRESHOLD; /* mm */
|
||||
|
||||
sts_high_threshold = sts_sensor_install_height;
|
||||
sts_low_threshold = sts_high_threshold - 1400;
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Threshold High=%4d, Low=%4d \r\n", sts_high_threshold, sts_low_threshold);
|
||||
|
||||
ITConfig.LowThreshold = sts_low_threshold;
|
||||
ITConfig.HighThreshold = sts_high_threshold;
|
||||
|
||||
|
@ -669,7 +676,7 @@ static void print_result(RANGING_SENSOR_Result_t *Result)
|
|||
}
|
||||
|
||||
|
||||
head_height_level_from_floor = sts_sensor_install_height - head_distance_from_ceiling;
|
||||
head_height_level_from_floor = MIN(1400, abs(sts_sensor_install_height - head_distance_from_ceiling));
|
||||
#if 0
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n #### Head distance from ceiling = %4d \r\n Head distance from floor =%d \r\n",
|
||||
head_distance_from_ceiling, head_height_level_from_floor);
|
||||
|
@ -680,7 +687,7 @@ static void print_result(RANGING_SENSOR_Result_t *Result)
|
|||
factor1_floor_level_from_ceiling, factor2_head_level_from_floor, fhmos_cfg.th_fall_body_min_height_cm);
|
||||
|
||||
#endif
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nBodyLow=%d < Obj: %d > Head_Max=%d\r\n", 10*fhmos_cfg.th_fall_body_min_height_cm, head_height_level_from_floor, (10*fhmos_cfg.th_head_level_height_cm));
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nBodyLow=%d <= Target: %d <=Head_Max=%d\r\n", 10*fhmos_cfg.th_fall_body_min_height_cm, head_height_level_from_floor, (10*fhmos_cfg.th_head_level_height_cm));
|
||||
if ((head_distance_from_ceiling <= factor1_floor_level_from_ceiling) && ((head_height_level_from_floor) <= (10*fhmos_cfg.th_head_level_height_cm)) && (head_height_level_from_floor >= (10*fhmos_cfg.th_fall_body_min_height_cm )))
|
||||
{
|
||||
|
||||
|
@ -699,7 +706,8 @@ static void print_result(RANGING_SENSOR_Result_t *Result)
|
|||
} else if ((head_distance_from_ceiling < (factor2_head_level_from_floor - 150))) // TODO XXX 50mm gap to avoid flapping back and forth
|
||||
{
|
||||
sts_head_level_low = 0;
|
||||
fhmos_data.state_fall = STS_FHMOS_FALL_STATE_NORMAL;
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Not reset fhmos_data.state_fall to Normal \r\n");
|
||||
//fhmos_data.state_fall = STS_FHMOS_FALL_STATE_NORMAL;
|
||||
sts_fhmos_bitmap_pending = 0;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue