杰理-耳机获取当前手机时间
需要更换库文件(针对安卓)
当前版本v136
链接:https://pan.baidu.com/s/1Bc2BSwxaGuEKB-CF3W7BEQ
javascript
#define USER_SUPPORT_PROFILE_MAP 1
javascript
#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
javascript
//获取手机的日期和时间, 苹果可以;
//安卓需要打上安卓手机同步时间补丁;
//建议此函数放在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]);
}
}
}
javascript
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:
javascript
#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
javascript
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
javascript
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);
}
javascript
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;
}
}
javascript
#include "btstack/avctp_user.h"