pabp服务添加
authorhcj <1224667075@qq.com>
Tue, 20 Aug 2024 03:11:38 +0000 (11:11 +0800)
committerhcj <1224667075@qq.com>
Tue, 20 Aug 2024 03:11:38 +0000 (11:11 +0800)
15 files changed:
code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/Bluetooyhpabpserver.h
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/Bluetooyhpabpserver.cpp
code/sdk/application/wearable/fd230app/nativeui/callerlog/include/CallerLogModel.h
code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp
code/sdk/application/wearable/fd230app/nativeui/makephone/include/CallerDisplayView.h
code/sdk/application/wearable/fd230app/nativeui/makephone/include/CallingView.h
code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallerDisplayView.cpp
code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallingView.cpp
code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneServiceC.h
code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp
code/sdk/application/wearable/service/ble_service/bleservice/bleService.c
code/sdk/drivers/peripheral/utils/custom_cmd_service.c
code/sdk/drivers/peripheral/utils/custom_utils.h
code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c

index 0af43bc..e6de15a 100644 (file)
@@ -15,11 +15,11 @@ void uapi_pbap_pce_reg_callback(void);
 void uapi_pbap_cmd_start_client(void);
 
 void uapi_pbap_cmd_pull_phonebook(void);
-void uapi_pbap_cmd_pull_vcard_listing(void);
+void uapi_pbap_cmd_pull_vcard_listing(unsigned char *tell);
 void uapi_pbap_cmd_pull_vcard_entry(td_char *vcf_name);
 
-#endif /* SAMPLE_PBAP_SERVICE_H */
 
 #ifdef  __cplusplus
 }
+#endif
 #endif
\ No newline at end of file
index b00f97d..20a2f85 100644 (file)
@@ -179,7 +179,7 @@ static int bluetooth_init_all(void)
     \r
     // BtInitCallBacksEx(); //BLE\r
     // BtInitGatts(); //BLE \r
-    //uapi_pbap_pce_reg_callback();\r
+    uapi_pbap_pce_reg_callback();\r
     // BtInitSpp();\r
     BtA2dpInit();\r
 \r
@@ -1395,6 +1395,9 @@ static void BtA2dpSnkConnectStateChangedCb(bd_addr_t *bd_addr, int conn_state)
     {\r
         SendMsgToUIService(BT_CONNECTED_TO_UI, 0, nullptr, 0);\r
         SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0);\r
+        if(pbap_pce_get_device_connect_state(bd_addr)==PROFILE_STATE_DISCONNECTING ||\r
+         pbap_pce_get_device_connect_state(bd_addr)==PROFILE_STATE_DISCONNECTED)\r
+        uapi_pbap_cmd_start_client();\r
         // if(conn_state==PROFILE_STATE_CONNECTED)\r
         // {\r
         //     if(pbap_pce_get_device_connect_state(bd_addr)==PROFILE_STATE_DISCONNECTED)\r
index 5d057e7..ddffb93 100644 (file)
@@ -22,6 +22,8 @@
 #include "bts_spp.h"
 #include "osal_task.h"
 #include "bleService.h"
+#include "BluetoothModel.h"
+#include "CallerLogModel.h"
 
 #ifdef  __cplusplus
 extern "C" {
@@ -53,7 +55,11 @@ static void sample_pbap_print_addr(const bd_addr_t *bd_addr)
 static void sample_pbap_conn_state(const bd_addr_t *bd_addr, profile_connect_state_t state)
 {
     sample_pbap_print_addr(bd_addr);
-    printf("%d\n", state);
+    printf("sample_pbap_conn_state %d\n", state);
+    if(state==PROFILE_STATE_CONNECTED)
+    {
+        uapi_pbap_cmd_pull_phonebook();
+    }
     return;
 }
 //接收数据回调
@@ -62,6 +68,13 @@ static void sample_pbap_receive_data(const bd_addr_t *bd_addr, const uint8_t* da
     sample_pbap_print_addr(bd_addr);
 
     printf("receive %d bytes(%s)\n", len, data);
+    if(strstr((char*)data,"vcard-listing.dtd"))
+    {
+        char * name_str=strstr((char*)data,"name");
+        char *name_=strtok(name_str,"\"");
+        name_=strtok(NULL,"\"");
+        OHOS:: CallerLogModel::GetInstance()->Setphonebname(name_,strlen(name_));
+    }
 
     return;
 }
@@ -132,7 +145,7 @@ void uapi_pbap_pce_reg_callback(void)
         sample_pbap_handle_error_code,
     };
     ret = (errcode_t)pbap_pce_register_callbacks(&callbacks);
-    printf("ret=0x%x\n", ret);
+    printf("uapi_pbap_pce_reg_callback ret=0x%x\n", ret);
 }
 
 
@@ -143,7 +156,7 @@ static int32_t sample_pbap_connect_task_body(const void *bd_addr)
     if (result != ERRCODE_BT_SUCCESS) {
         printf("Connect to PBAP service failed\n");
     }
-    printf("[Line: %d] finish, result: 0x%x!\n", __LINE__, result);
+    printf("sample_pbap_connect_task_body [Line: %d] finish, result: 0x%x!\n", __LINE__, result);
     return 0;
 }
 
@@ -174,7 +187,7 @@ static void sample_pbap_create_conn_task(const bd_addr_t *bd_addr)
     // if (!sample_pbap_is_null_pointer((uint16_t)sample_mode, 0)) {
     //     bd_addr = sample_pbap_parse_addr(params[1]);
     bd_addr_t bdaddr={0};
-    get_phone_addr(&bdaddr);
+    OHOS::uapi_get_br_address(&bdaddr);
     // }
     sample_pbap_create_conn_task((const bd_addr_t*)&bdaddr);
 }
@@ -182,7 +195,7 @@ static void sample_pbap_create_conn_task(const bd_addr_t *bd_addr)
 void uapi_pbap_cmd_stop_client()
 {
     bd_addr_t bdaddr={0};
-    get_phone_addr(&bdaddr);
+    OHOS::uapi_get_br_address(&bdaddr);
 
     uint32_t ret = (uint32_t)pbap_pce_disconnect(&bdaddr);
     printf("[Line: %d] finish, ret: %u\n", __LINE__, ret);
@@ -306,7 +319,7 @@ void uapi_pbap_cmd_pull_phonebook()
     uint8_t vcf=PBAP_VCF_PB;//写死 电话簿
     uint16_t max_list_count=0xFFFF;//最大数量
     uint16_t list_offset=0;
-    uint8_t format=0;//编码格式
+    uint8_t format=1;//编码格式
 
     if (!wstp_pbap_check_param_valid(folder, vcf, max_list_count, list_offset, format)) {
         printf("pbap param invalid\n");
@@ -443,7 +456,7 @@ static bool sample_pbap_set_vcard_listing_name(bd_addr_t* bd_addr, uint8_t folde
 }
 
 /* get phone vCard-Listing */
-void uapi_pbap_cmd_pull_vcard_listing()
+void uapi_pbap_cmd_pull_vcard_listing(unsigned char *tell)
 {
     uint8_t folder=1;
     uint8_t vcf=PBAP_VCF_PB;
@@ -475,8 +488,8 @@ void uapi_pbap_cmd_pull_vcard_listing()
     }
     (void)memset_s(thr_par->name, PBAP_APP_FOLDER_MAXLENGTH, 0, PBAP_APP_FOLDER_MAXLENGTH);
 
-    thr_par->search_property=PBAP_PROPERTY_MASK_TEL;
-    thr_par->search_value=(unsigned char*)"15111454038";
+    thr_par->search_property=PBAP_SEARCH_PROPERTY_NUMBER;
+    thr_par->search_value=tell;
     thr_par->max_list_count = max_list_count;
     thr_par->list_offset = list_offset; /* index = 5 */
     /* 0:索引序 1:字典序 */
@@ -599,9 +612,9 @@ void uapi_pbap_cmd_pull_vcard_entry(td_char *vcf_name)
 {
     printf("uapi_pbap_cmd_pull_vcard_entry: %s\r\n",vcf_name);
     bd_addr_t bdaddr={0};
-    get_phone_addr(&bdaddr);
+    OHOS::uapi_get_br_address(&bdaddr);
 
-    uint8_t format=0;
+    uint8_t format=1;
     uint8_t vcf=PBAP_VCF_PB;
     uint8_t folder=1;
     if (!wstp_pbap_check_param_valid(folder, vcf, 0, 0, format)) {
@@ -700,7 +713,7 @@ static void sample_pbap_cmd_pull_vcard_entry(const char **params, int32_t params
 {
 
     bd_addr_t bdaddr={0};
-    get_phone_addr(&bdaddr);
+    OHOS::uapi_get_br_address(&bdaddr);
 
     if (pbap_pce_get_device_connect_state(&bdaddr) != PROFILE_STATE_CONNECTED) {
         printf("No PBAP connection selected!\n");
@@ -714,7 +727,7 @@ static void sample_pbap_cmd_pull_vcard_entry(const char **params, int32_t params
 void uapi_pbap_amd_get_conn_state(void)
 {
     bd_addr_t bdaddr={0};
-    get_phone_addr(&bdaddr);
+    OHOS::uapi_get_br_address(&bdaddr);
 
     uint32_t result = (uint32_t)pbap_pce_get_device_connect_state(&bdaddr);
     printf("[Line: %d] finish, conn state: 0x%x\n", __LINE__, result);
@@ -766,3 +779,4 @@ typedef struct {
 #ifdef  __cplusplus
 }
 #endif
+
index b85d61d..364ad57 100644 (file)
@@ -54,9 +54,24 @@ typedef enum {
         CallSourcePhone,\r
         CallSourceCat1,\r
     } CallSource;\r
+   \r
+\r
     void InitPhoneService();\r
     static CallerLogModel *GetInstance(void);\r
 \r
+    std::string Getphonename(void)\r
+    {\r
+        return call_name;\r
+    }\r
+\r
+    void Setphonebname(char *name,uint8_t name_len)\r
+    {\r
+        call_name.clear();\r
+        call_name.append(reinterpret_cast<const char*>(name), name_len);\r
+       \r
+        //printf("%s\r\n",call_name.c_str());\r
+    }\r
+\r
     std::string GetPhoneNumber(void);\r
     void SetoperateNumber(const char *number, char number_len);\r
 \r
@@ -103,6 +118,7 @@ private:
     std::string timers; // 时间显示\r
     std::string callDuration; // 通话时长\r
     std::string phoneNumber; // 电话号码\r
+    std ::string call_name;\r
     bool mulitplePhoneStatus{false}; // 判断是否多路通话界面\r
     bool waitingStatus{false}; // 判断是否等待提醒界面\r
     bool volumeStatus{false}; // 判断是否音量界面\r
index 4f4d230..0fae7f6 100644 (file)
@@ -59,7 +59,7 @@ static void SetPriorityNumber()
 {
     time_t seconds;
     time(&seconds);
-    
+
     CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSourcePhone);
 
     // 接听和挂起状态需要持续显示通话计时
@@ -101,6 +101,7 @@ void StatusReset()
     CallerLogModel::GetInstance()->SetCallStatus(false);
     CallerLogModel::GetInstance()->SetWaitingStatus(false);
     DisableCallingTimer();
+    CallerLogModel::GetInstance()->Setphonebname("0",0);
     // If the call is handling in the notification, the slice is not switched
     if (!CallerLogModel::GetInstance()->GetNotifyFlag()) {
         NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_PHONE);
index fd39f52..bf6af48 100644 (file)
@@ -23,6 +23,7 @@ public:
     UIViewGroup *CreateUIViewGroup();
 
     static CallerDisplayView *GetInstance();
+    void updataCallingname();
 private:
     bool InitAddOnclickevent(void);
     bool InitImageViewDisplay(void);
index c2f80ab..9f83efe 100644 (file)
@@ -31,6 +31,7 @@ public:
     UILabel *GetCallingDurationLabel();
     void showdial(bool);
     void text_updata_buf(const char *buf);
+    void updataCallingname(void);
 private:
     bool InitAddOnclickevent(void);
     bool InitImageViewDisplay(void);
index a8ebfd9..812153a 100644 (file)
@@ -137,6 +137,16 @@ bool CallerDisplayView::InitImageViewDisplay()
     return true;
 }
 
+void CallerDisplayView::updataCallingname(void)
+{
+    if(CallerLogModel::GetInstance()->Getphonename().length()>5)
+    {
+        callerDisplay->SetText(CallerLogModel::GetInstance()->Getphonename().c_str());
+    } 
+}
+
+
+
 bool CallerDisplayView::InitUILabelDisplay()
 {
     callerDisplay = new UILabel();
@@ -156,7 +166,7 @@ bool CallerDisplayView::InitUILabelDisplay()
     {
        callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
     }
-    
+    updataCallingname();
     callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER);
     callerDisplay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CALLER_SIZE);
     callerDisplay->SetTextColor(Color::White());
index 64884b1..bce2d16 100644 (file)
@@ -139,6 +139,14 @@ UILabel *CallingView::GetCallingDurationLabel()
     return callDuration;
 }
 
+void CallingView::updataCallingname(void)
+{
+    if(CallerLogModel::GetInstance()->Getphonename().length()>5)
+    {
+        callerDisplay->SetText(CallerLogModel::GetInstance()->Getphonename().c_str());
+    } 
+}
+
 bool CallingView::InitImageViewDisplay()
 {
     imageMicrophone = new UIImageView();
@@ -245,6 +253,8 @@ bool CallingView::InitUILabelDisplay()
     {
        callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
     }
+    updataCallingname();
+
     
     callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER);
     callerDisplay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_DISPLAY_FONE_SIZE);
index 584f819..7ea6e7c 100644 (file)
@@ -31,6 +31,7 @@
 #include "notification_manager.h"
 #include "CallerLogModel.h"
 #include "custom_utils.h"
+#include "Bluetooyhpabpserver.h"
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -603,6 +604,7 @@ static void ConnStateChanged(const bd_addr_t *bdAddr, profile_connect_state_t st
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ConnStateChanged] BT connected");
             BtConnectedPro(bdAddr);
             SendMsgToUIService(BT_CONNECTED_TO_UI, 0, nullptr, 0);
+            uapi_pbap_cmd_start_client();
             //SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0);
             break;
         case PROFILE_STATE_DISCONNECTING: // 蓝牙连接断连
@@ -1415,6 +1417,7 @@ static void CallStateChanged(const bd_addr_t *bdAddr, const hfp_hf_calls_info_t
     SetCompleteCallFlag(call);
     CatCallStateChangedInfo(bdAddr, call);
     CallAudioHandle(call);
+    uapi_pbap_cmd_pull_vcard_listing((unsigned char *)call->number);
 
     WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "CallStateChanged state:%d", call->state);
     switch (call->state) {
@@ -1927,6 +1930,15 @@ int uapi_hfp_connect_(void)
         ret = hfp_hf_connect(&bdaddr);
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[uapi_hfp_connect] ret:%X", ret);
     }
+
+    if(ret!=ERRCODE_SUCC)
+    {
+        uint8_t br_cmd_code[5]={0};
+        br_cmd_code[0]=BR_HFP_CONNECT_FAIL;
+        memcpy_s(&br_cmd_code[1],4,&ret,4);
+
+        do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_BR_CONNECT,br_cmd_code,sizeof(uint8_t)*5);
+    }
  
     
     
@@ -1978,6 +1990,16 @@ int uapi_hfp_disconnect()
 }
 
 
+int uapi_hfp_fail_cbk(int32_t errcode)
+{
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%X", errcode);
+
+    return 0;
+}
+
+
+
+
 
 #ifdef __cplusplus
 }
index d9ab479..84872f2 100644 (file)
@@ -383,23 +383,31 @@ void svr_pair_result_cbt_cb(uint16_t conn_id, const bd_addr_t *addr, errcode_t s
             \r
             }else{\r
                 \r
-                bd_addr_t bdaddr={0};\r
-                uapi_get_br_address(&bdaddr);\r
-                if(false==(bt_is_acl_connected(&bdaddr)))\r
+                if(get_br_is_pair())\r
                 {\r
-                    if(cm_get_A2DP_switch() || cm_get_HFP_switch())\r
+                    bd_addr_t bdaddr={0};\r
+                    uapi_get_br_address(&bdaddr);\r
+                    if(false==(bt_is_acl_connected(&bdaddr)))\r
                     {\r
-                        int ret=gap_reconnect_media_device(&bdaddr);\r
-                        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_reconnect_media_device!!! %X\r\n",ret);\r
+                        if(cm_get_A2DP_switch() || cm_get_HFP_switch())\r
+                        {\r
+                            int ret=gap_reconnect_media_device(&bdaddr);\r
+                            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_reconnect_media_device!!! %X\r\n",ret);\r
+                        }\r
+                        // if(cm_get_A2DP_switch() || cm_get_HFP_switch())\r
+                        // uapi_a2dp_snk_connect();\r
+                        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_reconnect_media_device!!! \r\n");\r
+                    \r
                     }\r
-                   \r
-                }\r
-                else\r
-                {\r
-                    if(cm_get_A2DP_switch() || cm_get_HFP_switch())\r
-                    uapi_a2dp_snk_connect();\r
-                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_a2dp_snk_connect!!! \r\n");\r
+                    else\r
+                    {\r
+                        if(cm_get_A2DP_switch() || cm_get_HFP_switch())\r
+                        uapi_a2dp_snk_connect();\r
+                        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_a2dp_snk_connect!!! \r\n");\r
+                    }\r
+\r
                 }\r
+               \r
                 // int ret = gap_connect_remote_device(addr);\r
                 //  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_connect_remote_device!!! %X\r\n",ret);\r
                 \r
index b35c2ea..33c20a3 100644 (file)
@@ -85,6 +85,7 @@ static void custom_cmd_service_check_task(void const *arg)
     custom_cmd_cmd_t mail;
     uint32_t msgsize = (uint32_t)sizeof(custom_cmd_cmd_t);
     custom_cmd_service_running_stat = true;
+    int code=0;
 
     while (1)
     {
@@ -222,6 +223,11 @@ static void custom_cmd_service_check_task(void const *arg)
                 case BR_RECONNECT:
                     uapi_reconnect_();
                     break;
+                case BR_HFP_CONNECT_FAIL:
+                    
+                    memcpy_s(&code,4,&mail.data[1],4);
+                    uapi_hfp_fail_cbk(code);
+                    break;
                 default:
                     break;
             }
index 2349a7e..d62487d 100644 (file)
@@ -213,6 +213,7 @@ typedef enum {
     BR_A2DP_CONNECT,
     BR_A2DP_DISCONNECT,
     BR_RECONNECT,
+    BR_HFP_CONNECT_FAIL,
    
 } CUSTOM_CMD_MSG_BR_CONNECT_TYPE;
 
index 14871c9..0ec208d 100644 (file)
@@ -906,7 +906,6 @@ static uint32_t custom_get_aging_data(uint8_t *para, uint32_t paraLen, char *str
 
     uint8_t aging_data[4] = {0};
     uapi_get_file_data("user/userdata/aging_test.bin",aging_data,4);
-    wstp_print("aging_test fail_num[%d], display_error_num[%d] ,microhone_error_num[%d] ,ppg_error_num[%d] \n",aging_data[0],aging_data[1],aging_data[2],aging_data[3]);
     return ERRCODE_SUCC;
 }
 
@@ -1023,7 +1022,7 @@ static uint32_t PBAP_LS(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
     }
 
     #ifdef FD230
-    uapi_pbap_cmd_pull_vcard_listing();
+    uapi_pbap_cmd_pull_vcard_listing((unsigned char *)argv[0]);
     #endif
     return ERRCODE_SUCC;
 }
@@ -1070,7 +1069,11 @@ static uint32_t BLE_TEST(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
     case 7:
         uapi_ble_disconnect_device();
         break;
-        
+    case 8:
+        br_adv_start(atoi( (char *)argv[1]));
+    case 9:
+        br_adv_stop();
+        break;
     default:
         break;
     }