time_t tof_check_time;
tof_info_t info;
+ int32_t tof_changed_start_time = 0;
+
MG_LOGI( "btn light ctrl task run..." );
dev = ( mg_dev_t * )para;
Distance_parameter_correction(dev->tof, tof_threshold_cm * 10 );
}
+ int32_t somebody = 0;
+ int32_t now_secs = device_uptime_sec();
+
if( !row_disabled && tof_sync ){
//联排功能,平台设置人感状态
- light_mode_set( dev, LIGHT_MODE_TOF_ACTIVE );
+ //light_mode_set( dev, LIGHT_MODE_TOF_ACTIVE );
+ somebody = 1;
+
}else if( !dev->tof ){
//TOF传感器故障,LED按无人显示
- light_mode_set( dev, LIGHT_MODE_TOF_DEACTIVE );
+ //light_mode_set( dev, LIGHT_MODE_TOF_DEACTIVE );
+ somebody = 0;
+ }else{
+ mg_tof_read( dev->tof, &info );
+ somebody = (info.status==TOF_ANYBODY)?1:0;
}
+ if( dev->tof_somebody == somebody ){
+ tof_changed_start_time = now_secs;
+ }else if( somebody == 1){
+ //无人到有人, 立即上报
+ dev->tof_somebody = somebody; //无人--> 有人
+ dp_tof_status_report(1); //状态变化,上报DP
+ MG_LOGI( "[%d]device tof status - > 1\n", now_secs );
+ tof_changed_start_time = now_secs;
+ }else if( now_secs - tof_changed_start_time > cfg_mg_tof_interval_read( dev ) ){
+ //有人到无人,持续时间需达到DP人感检测周期设定时间(10s-20s)后切换
+ dev->tof_somebody = somebody; // 有人-->无人
+ dp_tof_status_report(0); //状态变化,上报DP
+ MG_LOGI( "[%d - %d]device tof status - > 0\n", now_secs, tof_changed_start_time );
+ tof_changed_start_time = now_secs;
+ }
+ if( dev->tof_somebody ){
+ light_mode_set( dev, LIGHT_MODE_TOF_ACTIVE );
+ }else{
+ light_mode_set( dev, LIGHT_MODE_TOF_DEACTIVE );
+ }
+#if 0
if( dev->tof && device_uptime_sec() - tof_check_time > cfg_mg_tof_interval_read( dev ) ){
//printf( "%d - %d > %d\n", device_uptime_sec(), tof_check_time, cfg_mg_tof_interval_read(dev) );
tof_check_time = device_uptime_sec();
static tof_info_t dbg_info;
if( dbg_info.enable != info.enable || dbg_info.status != info.status || abs( dbg_info.distance-info.distance)>5 ){
memcpy( &dbg_info, &info, sizeof( dbg_info ) );
- MG_LOGD( "read tof info, enable:%d, status:%d, dist:%d", info.enable, info.status, info.distance );
+ MG_LOGD(
+"read tof info, enable:%d, status:%d, dist:%d", info.enable, info.status, info.distance );
}
}else{
MG_LOGW( "read tof info fail, g_tof:%p", dev->tof );
MG_LOGI( "device tof status - > %d \n", tof_st );
}
}
+#endif
}
}
}
wifi_config_store( ssid, password );
}
-extern int open_udp_listen( void );
-extern int close_udp_listen( void );
+//extern int open_udp_listen( void );
+//extern int close_udp_listen( void );
extern char *ble_get_local_ip( char* buf, int32_t buf_sz );
extern void ip_change_notify( char * ip );
ble_get_local_ip( ip_str, sizeof( ip_str ) );
ble_start = dev->netconfig;
ble_wificonfig_start();
- open_udp_listen();
+ //open_udp_listen();
}else if( ble_start && !dev->netconfig ){
//停止配网
MG_LOGD( "ble stop....\n" );
ble_start = dev->netconfig;
ble_wificonfig_stop();
- close_udp_listen();
+ //close_udp_listen();
}
if( ble_start ){