杰理-耳机获取当前手机时间

杰理-耳机获取当前手机时间

需要更换库文件(针对安卓)
当前版本v136
链接:https://pan.baidu.com/s/1Bc2BSwxaGuEKB-CF3W7BEQ

#define USER_SUPPORT_PROFILE_MAP                  1

在这里插入图片描述

#if (USER_SUPPORT_PROFILE_MAP==1)
extern const u8 sdp_map_mce_service_data[];
u8 map_profile_support = 1;
SDP_RECORD_HANDLER_REGISTER(map_sdp_record_item) = {
.service_record = (u8 *)sdp_map_mce_service_data, 
.service_record_handle = 0x00010009, 
};
#endif

在这里插入图片描述


//获取手机的日期和时间, 苹果可以;
//安卓需要打上安卓手机同步时间补丁;
//建议此函数放在bt_function_select_init函数所在的同一个C文件里
// __attribute__((weak))
void phone_date_and_time_feedback(u8 *data, u16 len)
{
    G_log(" ---------------------- ios 当前时间 ");
    put_buf(data, len);
    puts(data);
    
// 32 33 2F 31 32 2F 31 32 2C 20 31 34 3A 35 35 3A 31 39 
// 2  3  /  1  2  /  1  2  ,     1  4  :  5  5  :  1  9  "
// 0  1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16 17
// 23/12/12, 14:55:19"

    u8 curr_time[6] = {0};
    curr_time[0] =  ((data[0]-'0')*10)  + (data[1]- '0');
    curr_time[1] =  ((data[3]-'0')*10)  + (data[4]- '0');
    curr_time[2] =  ((data[6]-'0')*10)  + (data[7]- '0');
    curr_time[3] =  ((data[10]-'0')*10) + (data[11]-'0');
    curr_time[4]=   ((data[13]-'0')*10) + (data[14]-'0');
    curr_time[5]=   ((data[16]-'0')*10) + (data[17]-'0');
    G_log("  %d年%d月%d日   %d时%d分%d秒  ",curr_time[0],curr_time[1],curr_time[2],curr_time[3],curr_time[4],curr_time[5]);

    if(connect_dev == CONNECT_AC701_DEV){
        if(curr_time[3] > 24 || curr_time[4] > 60 || curr_time[5] > 60 ){
            G_log("--------------  获取时间错误 ");
            return;
        }
        for(u8 cmd=COMMON_YEAR ; cmd<= COMMON_SEC ; cmd++){
            ear_send_data_to_watch(COMMON_CURR_TIME_BEGIN,cmd,curr_time[cmd-1]);
        }
    }
} 


void android_phone_date_and_time_feedback(u8 *data)
{
    
    G_log(" ---------------------- android  当前时间 ");
    put_buf(data, strlen(data));
    puts(data);

//2024年01月09日 19:42:09 
// 2  0  2  4  0  1  0  9  T  1  9  4  2  0  9  +  0  8  0  0
// 0  1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16 17 18 19 


    u8 curr_time[6] = {0};
    curr_time[0] =  ((data[2]- '0')*10)  + (data[3]- '0');
    curr_time[1] =  ((data[4]- '0')*10)  + (data[5]- '0');
    curr_time[2] =  ((data[6]- '0')*10)  + (data[7]- '0');
    curr_time[3] =  ((data[9]- '0')*10) + (data[10]- '0');
    curr_time[4]=   ((data[11]-'0')*10) + (data[12]- '0');
    curr_time[5]=   ((data[13]-'0')*10) + (data[14]- '0');
    G_log("  %d年%d月%d日   %d时%d分%d秒  ",curr_time[0],curr_time[1],curr_time[2],curr_time[3],curr_time[4],curr_time[5]);

    if(connect_dev == CONNECT_AC701_DEV){
        if(curr_time[3] > 24 || curr_time[4] > 60 || curr_time[5] > 60 ){
            G_log("--------------  获取时间错误 ");
            return;
        }
        for(u8 cmd=COMMON_YEAR ; cmd<= COMMON_SEC ; cmd++){
            ear_send_data_to_watch(COMMON_CURR_TIME_BEGIN,cmd,curr_time[cmd-1]);
        }
    }
} 


在这里插入图片描述

case  BT_STATUS_RECONN_OR_CONN:
        log_info("  BT_STATUS_RECONN_OR_CONN \n");
#if USER_SUPPORT_PROFILE_MAP
        user_send_cmd_prepare(USER_CTRL_MAP_READ_TIME,0,NULL);
#endif
        break;
    case BT_STATUS_INIT_OK:

在这里插入图片描述

#if USER_SUPPORT_PROFILE_MAP
#define PROFILE_CMD_TRY_AGAIN_LATER -1004

void bt_get_time_date()
{
    G_log(" bt_get_time_date --------------- 24.01.09 ");
    int error = user_send_cmd_prepare(USER_CTRL_HFP_GET_PHONE_DATE_TIME, 0,NULL);
    printf(">>>>>error = %d\n", error);
    if (error == PROFILE_CMD_TRY_AGAIN_LATER) {
        sys_timeout_add(NULL, bt_get_time_date, 100);
    }
}
// void phone_date_and_time_feedback(u8 *data, u16 len)
// {
//     printf("time:%s ", data);
// }
void map_get_time_data(char *time, int status)
{
    G_log("  map_get_time_data  --------------- 24.01.09  ");
    if (status == 0) {
        printf("time:%s ", time);
        android_phone_date_and_time_feedback(time);
    } else {
        printf(">>>map get fail\n");
        sys_timeout_add(NULL, bt_get_time_date, 100);
    }
}
#endif

在这里插入图片描述

    USER_CTRL_MULTI_HFP_CMD_END,
    USER_CTRL_MAP_CMD_BEGIN, //MAP 读取时间
    USER_CTRL_MAP_READ_TIME, //MAP 读取未读短信
    USER_CTRL_MAP_READ_INBOX,  //MAP 读取已读短信
    USER_CTRL_MAP_READ_OUTBOX,  //MAP 读取已发读短信
    USER_CTRL_MAP_READ_SENT,  //MAP 读取删除短信
    USER_CTRL_MAP_READ_DELETED,  //MAP 读取草稿箱短信
    USER_CTRL_MAP_READ_DRAFT,  //MAP 停止读取
    USER_CTRL_MAP_STOP_READING, 
    USER_CTRL_MAP_CMD_END,
    USER_CTRL_LAST

在这里插入图片描述

//----------------------------------------------------------------------------- ios

if(get_phone_timer){
            sys_timeout_del(get_phone_timer);
            get_phone_timer = 0;
        }
        if(!get_phone_timer){
            get_phone_timer = sys_timeout_add(NULL,get_phone_timer_func,1000);
        }

在这里插入图片描述

static u16 get_phone_timer = 0;
void get_phone_timer_func()
{
    G_log(" --------   同步手机时间 ");
    user_send_cmd_prepare(USER_CTRL_HFP_GET_PHONE_DATE_TIME, 0, NULL);
    if(get_phone_timer){
        sys_timeout_del(get_phone_timer);
        get_phone_timer = 0;
    }
}

在这里插入图片描述

#include "btstack/avctp_user.h"

在这里插入图片描述

相关推荐

  1. js获取当前时间

    2024-03-10 05:06:01       61 阅读
  2. Qt - 获取系统当前时间

    2024-03-10 05:06:01       38 阅读
  3. C语言获取当前时间

    2024-03-10 05:06:01       24 阅读
  4. js获取当前时间,当日零点,前一周时间

    2024-03-10 05:06:01       51 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-10 05:06:01       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-10 05:06:01       106 阅读
  3. 在Django里面运行非项目文件

    2024-03-10 05:06:01       87 阅读
  4. Python语言-面向对象

    2024-03-10 05:06:01       96 阅读

热门阅读

  1. 透明多级分流系统(用户端缓存和负载均衡)

    2024-03-10 05:06:01       39 阅读
  2. 与缓存相关的状态码

    2024-03-10 05:06:01       47 阅读
  3. Flink 资源管理

    2024-03-10 05:06:01       48 阅读
  4. 学习GIT

    2024-03-10 05:06:01       48 阅读
  5. 算法-划分字母区间

    2024-03-10 05:06:01       43 阅读
  6. Http状态码

    2024-03-10 05:06:01       43 阅读
  7. C语言深入学习 --- 7.程序的编译

    2024-03-10 05:06:01       31 阅读
  8. 如何在非spring环境中调用service中的方法

    2024-03-10 05:06:01       45 阅读
  9. React 第六章 生命周期

    2024-03-10 05:06:01       41 阅读
  10. RabbitMQ

    RabbitMQ

    2024-03-10 05:06:01      44 阅读