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

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

需要更换库文件(针对安卓)
当前版本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"

在这里插入图片描述

  • 8
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值