void led_flash_for_btn_single_click( mg_dev_t *dev, button_code_t btn_code );
void light_set_key_br( mg_dev_t *dev, uint32_t id, uint32_t br );
void light_set_atmos_br( mg_dev_t *dev, uint32_t id, uint32_t br );
+int32_t load_light_cfg( light_cfg_t * cfg );
//-------------------------------------------------------------------------------------
//net config
//ble广播配置文件
char *load_ble_adv_local_name( void );
-uint32_t device_uptime_sec( void );
+extern time_t device_uptime_sec( void );
+extern time_t device_uptime_msec( void );
#endif //__MG_DEVICE_H__
if ((repeating_gestures != ev) || (no_hands == 1))
{
dp_gesture_event_report(ev);
- timeout = time(NULL);
+ timeout = device_uptime_sec();
no_hands = 0;
printf("上报dp ===================== %d\n", ev);
}
uint32_t privacy =0;
gr_ctrl_t *p_gr = (gr_ctrl_t *)param;
- gr_time = time(NULL);
+ gr_time = device_uptime_sec();
my_privacy = -1;
usleep(100 * 000);
if (time_flasg)
{
- gr_time = time(NULL);
+ gr_time = device_uptime_sec();
time_flasg = 0;
}
dp_timeout = cfg_recognition_duration_read(p_gr->dev);
- if (time(NULL) - gr_time > dp_timeout)
+ if (device_uptime_sec() - gr_time > dp_timeout)
{
printf("gesture Time out\n");
reportdp_and_close_ring_gr(p_gr->light_ctrl);
MG_LOGE( "mg_led_open fail!" );
}
}
-
+/*
char *light_mode_name[]={
"led_off",
"led_on",
"led_breath",
"led_nochange",
};
+*/
+static const char* light_mode_name[] = {
+ "LIGHT_MODE_INIT", //开机初始状态,所有灯常灭
+ "LIGHT_MODE_NO_AUTH", //未授权:控制所有按键背光连续慢闪,装饰灯带常灭;不加载涂鸦 SDK应用程序轮询授权是否已写入,并校验写入长度符合要求;
+ "LIGHT_MODE_AUTH_NO_WIFICONFIG", //已授权未配网:所有灯光常灭;
+ "LIGHT_MODE_AUTH_WIFICONFIGING", //配网过程中 LED7 & LED8 连续慢闪, 2分钟超时后退出
+ "LIGHT_MODE_AUTH_WIFICONFIG_NO_ACTIVE", //已授权已配网未激活:所有灯光常灭;
+ "LIGHT_MODE_ACTIVE", //已授权已配网已激活:进入主流程,灯光根据 DP 设置处理。
+ "LIGHT_MODE_CLEAN",
+ "LIGHT_MODE_TOF_ACTIVE",
+ "LIGHT_MODE_TOF_DEACTIVE"
+};
void light_mode_set( mg_dev_t *dev, light_mode_t mode )
{
extern int32_t mg_device_bind_flag_write( void );
-//使用sysinfo来获取系统运行时间,因使用time(NULL)获取时间会受到ntp的干扰。
-uint32_t device_uptime_sec( void )
-{
- struct sysinfo info;
-
- if( sysinfo( &info ) ){
- return 0;
- }
-
- return info.uptime;
-}
-
int32_t netconfig_start( mg_dev_t *dev )
{
printf( "netconfig_start,now:%ld, , cfg:%d, s:%ld\n", device_uptime_sec(), dev->netconfig, dev->netconfig_start_time );
#define PID_FILE "/var/run/mg_app/mg_app.pid"
+extern int32_t read_device_uuid( mg_dev_t *dev );
+
static mg_dev_t g_mg_dev;
+time_t device_uptime_msec( void )
+{
+ struct timespec ts;
+
+ clock_gettime( CLOCK_BOOTTIME, &ts );
+
+ return (time_t )(ts.tv_sec*1000+ts.tv_nsec/1000/1000);
+}
+
+time_t device_uptime_sec( void )
+{
+ //struct sysinfo info;
+ //( sysinfo( &info ) ){
+ //return info.uptime;
+ struct timespec ts;
+
+ clock_gettime( CLOCK_BOOTTIME, &ts );
+
+ return ts.tv_sec;
+}
+
char * dev_uuid_str( void )
{
return g_mg_dev.uuid;
#include <string.h>
#include <time.h>
#include <sys/time.h>
+#include <time.h>
#include <unistd.h>
#include "button.h"
static uint32_t get_systime_ms( void )
{
- struct timeval tm;
- gettimeofday( &tm, NULL );
- return (uint32_t)(tm.tv_sec*1000+tm.tv_usec/1000);
+ //struct timeval tm;
+ //gettimeofday( &tm, NULL );
+ //return (uint32_t)(tm.tv_sec*1000+tm.tv_usec/1000);
+ struct timespec ts;
+
+ clock_gettime( CLOCK_BOOTTIME, &ts );
+
+ return (time_t )(ts.tv_sec*1000+ts.tv_nsec/1000/1000);
}
void single_btn_report( btn_ctrl_t btn_ctrl, uint32_t code, button_event_t event )
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/time.h>
+#include <time.h>
#include "led.h"
#include "mg_log.h"
static int32_t mg_led_st( light_ctrl_t ctrl, uint32_t led_id, light_st_t *st );
//--------------------------------------------------------------------------------------------------------------------------------
-uint32_t now_msec( void )
+static uint32_t now_msec( void )
{
- struct timeval tm;
- gettimeofday( &tm, NULL );
- return (uint32_t)(tm.tv_sec*1000+tm.tv_usec/1000 );
+// struct timeval tm;
+// gettimeofday( &tm, NULL );
+// return (uint32_t)(tm.tv_sec*1000+tm.tv_usec/1000 );
+ struct timespec ts;
+
+ clock_gettime( CLOCK_BOOTTIME, &ts );
+ return (time_t )(ts.tv_sec*1000+ts.tv_nsec/1000/1000);
}
static uint32_t get_key_led_id( uint32_t key_led )