~AiVoiceConnectingView();
static AiVoiceConnectingView *GetInstance(void);
UIScrollView *CreateAiVoiceConnectingView(void);
-
+ UIScrollView *CreateAiVoiceConnectingView(uint8_t);
private:
const char **CreateImagePathsArray(const char *basePath, const int numImages, const char *fileExtension = "bin");
void FreeImagePathsArray(const char **imagePaths, const int numImages);
bool CreateAiVoiceConnectingViewButton(void);
bool CreateAivoiceConnectingImageAnimator(void);
bool CreateAiVoiceConnectingScrollView(void);
+ bool CreateAiVoiceConnectingScrollView(uint8_t);
void ClearAll(void);
UIScrollView *scrollView{nullptr};
UILabelExt *title{nullptr};
static constexpr int16_t AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_Y = 153;
static constexpr int16_t AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_W = 100;
static constexpr int16_t AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_H = 120;
- static constexpr int16_t AIVOICE_CONNECTING_IMAGE_ANIMATOR_DELAY = 200; // 图片更新间隔
+ static constexpr int16_t AIVOICE_CONNECTING_IMAGE_ANIMATOR_DELAY = 50; // 图片更新间隔
static constexpr const char *AIVoiceListeningImagePaths = "/user/res/connect/";
static AiVoiceConnectingView *g_pAiVoiceConnecting{nullptr};
return true;
}
+ bool AiVoiceConnectingView::CreateAiVoiceConnectingScrollView(uint8_t type)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingScrollView");
+ scrollView = new UIScrollView();
+ if (scrollView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceConnectTimeoutView::scrollView new fail!");
+ return false;
+ }
+ scrollView->SetPosition(0, 0, 466, 466);
+ scrollView->SetTouchable(true);
+ scrollView->SetDraggable(true);
+
+ return true;
+ }
+
+
UIScrollView *AiVoiceConnectingView::CreateAiVoiceConnectingView(void)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingView");
return scrollView;
}
+ UIScrollView *AiVoiceConnectingView::CreateAiVoiceConnectingView(uint8_t type)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingView");
+ if (!CreateAiVoiceConnectingScrollView(type) || !CreateAivoiceConnectingImageAnimator()|| !CreateAiVoiceConnectingViewLabel() )
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingView fail!!");
+ return nullptr;
+ }
+ scrollView->Add(connectingAnimatorView);
+ return scrollView;
+ }
+
}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: BluetoothModel view
+ * Author:
+ * Create: 2021-10-13
+ */
+
+#ifndef C_BLUETOOTH_MODEL_H_
+#define C_BLUETOOTH_MODEL_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int uapi_a2dp_snk_connect_(void);
+int uapi_a2dp_snk_disconnect_(void);
+//int uapi_disconnect_remote_device_(void);
+
+int uapi_reconnect_(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
*/\r
#include <cstdint>\r
#include "BluetoothModel.h"\r
+#include "BluetoothModelC.h"\r
+\r
#include "BluetoothWrapper.h"\r
#include "BluetoothPresenter.h"\r
#include "ConnectPhonePresenter.h"\r
#include "bts_spp.h"\r
#include "osal_task.h"\r
#include "bts_pbap.h"\r
-\r
+#include "ConfigModelC.h"\r
+#include "custom_utils.h"\r
#ifdef SUPPORT_ALIPAY_SEC\r
#include "alipay_feature.h"\r
#endif\r
#include "BluetoothWrapper.h"\r
#endif\r
#include "Bluetooyhpabpserver.h"\r
+#include "bletest.h"\r
+#include "ConfigModelC.h"\r
namespace OHOS {\r
\r
#define BT_SPP_TASK_STACK_SIZE 2048\r
\r
/**TODO: 断开BR链接**/\r
bd_addr_t bdaddr={0};\r
- get_phone_addr(&bdaddr);\r
+ uapi_get_br_address(&bdaddr);\r
if (bt_is_acl_connected(&bdaddr))\r
{\r
ret = gap_disconnect_remote_device(&bdaddr);\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BtGapPairStatusChangedCallback addr: ****%02x%02x%02x%02x status: %d\n",\r
bdAddr->addr[3], bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0], status); /* addr下标 0 1 2 3 */\r
memcpy(&BtGapPair_bdAddr,bdAddr,sizeof(bd_addr_t));\r
- uapi_a2dp_snk_connect();\r
+ // if(status == GAP_PAIR_PAIRED)\r
+ // { \r
+ \r
+ \r
+ //}\r
//uapi_a2dp_snk_connect();\r
//a2dp_snk_connect(bdAddr);\r
- \r
+ if(cm_custom_ble_service_on_flag() && !get_ble_pair())\r
+ {\r
+ if(cm_get_A2DP_switch() || cm_get_HFP_switch())\r
+ uapi_a2dp_snk_connect();\r
+ //uapi_reconnect();\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_a2dp_snk_connect");\r
+ }\r
if (status == GAP_PAIR_PAIRED) {\r
if (ConnectPhonePresenter::GetInstance() != nullptr) {\r
NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING);\r
}\r
+ \r
}\r
}\r
\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "addr: %02x%02x%02x%02x%02x%02x",\r
bdAddr->addr[5], bdAddr->addr[4], bdAddr->addr[3], /* mac下标 0 1 2 3 4 5 */\r
bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0]); /* mac下标 0 1 2 3 4 5 */\r
+ //效果不好\r
+ if(!cm_custom_ble_service_on_flag())\r
+ {\r
+ gap_disconnect_remote_device(bdAddr);\r
+ }\r
\r
//ALC_State_flag=state;\r
\r
\r
void uapi_get_br_address(bd_addr_t *bdaddr)\r
{\r
+ \r
if(BtGapPair_bdAddr.addr[0]==0 && BtGapPair_bdAddr.addr[1]==0 &&\r
BtGapPair_bdAddr.addr[2]==0 && BtGapPair_bdAddr.addr[3]==0 )\r
get_phone_addr(bdaddr);\r
memcpy(bdaddr,&BtGapPair_bdAddr,sizeof(bd_addr_t));\r
\r
}\r
+static uint8_t br_cmd=0;\r
int uapi_a2dp_snk_connect()\r
+{\r
+ br_cmd=BR_A2DP_CONNECT;\r
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_BR_CONNECT,&br_cmd,sizeof(br_cmd));\r
+ return 0;\r
+\r
+}\r
+ \r
+\r
+int uapi_a2dp_snk_connect_()\r
{\r
\r
bd_addr_t bdaddr={0};\r
}\r
\r
int uapi_a2dp_snk_disconnect()\r
+{\r
+ br_cmd=BR_A2DP_DISCONNECT;\r
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_BR_CONNECT,&br_cmd,sizeof(br_cmd));\r
+ return 0;\r
+}\r
+ \r
+\r
+int uapi_a2dp_snk_disconnect_()\r
{\r
\r
bd_addr_t bdaddr={0};\r
return ret;\r
}\r
\r
+// int uapi_disconnect_remote_device_()\r
+// {\r
+// do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_BR_CONNECT,&br_cmd,sizeof(br_cmd));\r
+// return 0;\r
+// }\r
+ \r
+\r
int uapi_disconnect_remote_device()\r
{\r
bd_addr_t bdaddr={0};\r
}\r
\r
\r
+int uapi_reconnect_()\r
+{\r
+ \r
+ br_cmd=BR_RECONNECT;\r
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_BR_CONNECT,&br_cmd,sizeof(br_cmd));\r
+ return 0;\r
+}\r
+ \r
+\r
int uapi_reconnect(void)\r
{\r
bd_addr_t bdaddr={0};\r
return 0;\r
}\r
\r
+\r
+\r
// /////////////////////////////////////////HFP hf端 代码///////////////////////////////////////////////////\r
\r
// int uapi_HFP_hf_connect()\r
#include "components/ui_button.h"
#include "components/ui_image_view.h"
#include "components/ui_toggle_button.h"
+#include "aivoice/include/AiVoiceConnectingView.h"
namespace OHOS
{
// 返回setting视图界面
uint16_t textId;
uint8_t lineBreakMode; // 断行模式。
};
+
+ typedef enum
+ {
+ CONNECT_HFP = 0,
+ DISCONNECT_HFP,
+ CONNECT_A2DP,
+ DISCONNECT_A2DP,
+ } BluetoothServiceOptionsView_state;
+
BluetoothServiceOptionsView();
virtual ~BluetoothServiceOptionsView();
static BluetoothServiceOptionsView *GetInstance(void);
void ClearAll(void);
UIToggleButton *GetHFP_ToggleButton(void);
UIToggleButton *GetA2DP_ToggleButton(void);
-
+ void show_connecting_view(bool data);
+ void Button_UPdata(void);
+ bool init_connect_timer(uint8_t type);
+ bool get_connectview_Visible(void);
public:
virtual void OnStart() override;
virtual void OnSetUpView() override;
UIImageView *A2DP_Image{nullptr};
UIToggleButton *HFP_ToggleButton{nullptr}; // HFP
UIToggleButton *A2DP_ToggleButton{nullptr}; // A2DP
+ UIScrollView * connectingScrollView{nullptr};
+ AiVoiceConnectingView* p_AiVoiceConnectingView{nullptr};
+
bool initViewStatus{false};
};
}
UIToggleButton *toggleButton = dynamic_cast<UIToggleButton *>(&view);
if (toggleButton != nullptr)
{
+ classicBlueToothView->show_connecting_view(true);
if (toggleButton->GetState() == true)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s is enable!", it->second.c_str());
+ //WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s is enable!", it->second.c_str());
if (it->second == "HFP")
{
ConfigModel::GetInstance()->SetHFPState(true);
//enable_hfp_service(true);
uapi_hfp_connect();
+ classicBlueToothView->init_connect_timer(BluetoothServiceOptionsView::CONNECT_HFP);
+
}
else if (it->second == "A2DP")
{
ConfigModel::GetInstance()->SetA2DPState(true);
uapi_a2dp_snk_connect();
+ classicBlueToothView->init_connect_timer(BluetoothServiceOptionsView::CONNECT_A2DP);
//enable_a2dp_service(true);
}
}
else
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s is disable!", it->second.c_str());
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s is disable!", it->second.c_str());
if (it->second == "HFP")
{
ConfigModel::GetInstance()->SetHFPState(false);
//enable_hfp_service(false);
uapi_hfp_disconnect();
+ classicBlueToothView->init_connect_timer(BluetoothServiceOptionsView::DISCONNECT_HFP);
// errcode_t ret = gap_ble_set_ctkd_enable(false);
// WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_ble_set_ctkd_enable ret = %u", ret);
}
ConfigModel::GetInstance()->SetA2DPState(false);
uapi_a2dp_snk_disconnect();
+ classicBlueToothView->init_connect_timer(BluetoothServiceOptionsView::DISCONNECT_HFP);
// uapi_hfp_disconnect();
- // uapi_disconnect_remote_device();
+ //uapi_disconnect_remote_device();
// errcode_t ret = gap_ble_set_ctkd_enable(false);
// WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_ble_set_ctkd_enable ret = %u", ret);
//bluetooth_set_auto_reconnect(1);
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsPresenter::OnDragEnd");
if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
{
+ if(! BluetoothServiceOptionsView::GetInstance()->get_connectview_Visible())
NativeAbility::GetInstance().Back();
}
// 如果是power键,且是亮屏状态,按键释放就返回上一级
if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
{
+ if(! BluetoothServiceOptionsView::GetInstance()->get_connectview_Visible())
NativeAbility::GetInstance().Back();
}
return true;
#include "phoneservice/include/PhoneService.h"
#include "BluetoothModel.h"
#include "ui_resource_string.h"
+#include "cmsis_os2.h"
+
namespace OHOS
{
static BluetoothServiceOptionsView *g_pBluetoothServiceOptionsView{nullptr};
delete A2DP_ToggleButton;
A2DP_ToggleButton = nullptr;
}
+ if(p_AiVoiceConnectingView)
+ {
+ delete p_AiVoiceConnectingView;
+ p_AiVoiceConnectingView=nullptr;
+ }
+ if(connectingScrollView)
+ {
+ delete connectingScrollView;
+ connectingScrollView = nullptr;
+ }
delete BlueToothScrollView;
BlueToothScrollView = nullptr;
}
}
}
+ static osTimerId_t MG_TEST_timer=NULL;
+ static uint8_t button_state=0;
+ static uint8_t count_num=0;
+
+ bool BluetoothServiceOptionsView::get_connectview_Visible(void)
+ {
+ return connectingScrollView->IsVisible();
+ }
+
+ void connectTimerCallBack(int data)
+ {
+ bool connect_state=false;
+ count_num++;
+ switch (button_state)
+ {
+ case BluetoothServiceOptionsView::CONNECT_HFP:
+ if(uapi_hfp_connect_state())
+ {
+ BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false);
+ connect_state=true;
+ }
+ break;
+ case BluetoothServiceOptionsView::DISCONNECT_HFP:
+ if(!uapi_hfp_connect_state())
+ {
+ BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false);
+ connect_state=true;
+ }
+ break;
+ case BluetoothServiceOptionsView::CONNECT_A2DP:
+ if(uapi_a2dp_snk_get_device_connect_state())
+ {
+ BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false);
+ connect_state=true;
+ }
+ break;
+ case BluetoothServiceOptionsView::DISCONNECT_A2DP:
+ if(!uapi_a2dp_snk_get_device_connect_state())
+ {
+ BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false);
+ connect_state=true;
+ }
+ break;
+
+ default:
+ break;
+
+ }
+ if(count_num==3 || connect_state)
+ {
+ if( BluetoothServiceOptionsView::GetInstance())
+ BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false);
+ osTimerStop(MG_TEST_timer);
+ osTimerDelete(MG_TEST_timer);
+ MG_TEST_timer = NULL;
+ }
+ else if(count_num==2)
+ {
+ //仅尝试重连一次
+ switch (button_state)
+ {
+ case BluetoothServiceOptionsView::CONNECT_HFP:
+ //uapi_hfp_connect();
+ break;
+ case BluetoothServiceOptionsView::DISCONNECT_HFP:
+ //uapi_hfp_disconnect();
+ break;
+ case BluetoothServiceOptionsView::CONNECT_A2DP:
+ // uapi_a2dp_snk_connect();
+ break;
+ case BluetoothServiceOptionsView::DISCONNECT_A2DP:
+ //uapi_a2dp_snk_disconnect();
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ bool BluetoothServiceOptionsView::init_connect_timer(uint8_t type)
+ {
+ uint32_t tick;
+ osStatus_t retTimer;
+ count_num=0;
+ button_state=type;
+
+ if(MG_TEST_timer)
+ {
+ osTimerStop(MG_TEST_timer);
+ osTimerDelete(MG_TEST_timer);
+ MG_TEST_timer = NULL;
+
+ }
+ MG_TEST_timer = osTimerNew((osTimerFunc_t)connectTimerCallBack, osTimerPeriodic, NULL, NULL);
+ tick =1500;
+ retTimer = osTimerStart(MG_TEST_timer, tick);
+ if (retTimer != osOK && MG_TEST_timer != NULL) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer);
+ osTimerDelete(MG_TEST_timer);
+ MG_TEST_timer = NULL;
+ return false;
+ }
+ return true;
+ }
+
+
bool BluetoothServiceOptionsView::SetUpBlueToothScrollView(void)
{
BlueToothScrollView = new UIScrollView();
{
BluetoothServiceOptionsViewInit();
initViewStatus = true;
+
}
// 增加按键监听
RootView::GetInstance()->SetOnKeyActListener(keyactListener);
}
+ void BluetoothServiceOptionsView::show_connecting_view(bool data)
+ {
+
+ connectingScrollView->SetVisible(data);
+ if(data==false)
+ {
+ A2DP_ToggleButton->SetState(uapi_a2dp_snk_get_device_connect_state());
+ HFP_ToggleButton->SetState(uapi_hfp_connect_state()); // ConfigModel::GetInstance()->GetHFPState());
+ }
+ }
+
+ void BluetoothServiceOptionsView::Button_UPdata(void)
+ {
+
+ A2DP_ToggleButton->SetState(uapi_a2dp_snk_get_device_connect_state());
+ HFP_ToggleButton->SetState(uapi_hfp_connect_state()); // ConfigModel::GetInstance()->GetHFPState());
+
+ }
+
void BluetoothServiceOptionsView::OnSetUpView()
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::OnSetUpView");
BlueToothScrollView->Add(A2DP_Label);
BlueToothScrollView->Add(HFP_ToggleButton);
BlueToothScrollView->Add(A2DP_ToggleButton);
+ p_AiVoiceConnectingView = new AiVoiceConnectingView();
+
+ connectingScrollView= p_AiVoiceConnectingView->CreateAiVoiceConnectingView(1);
+ connectingScrollView->SetVisible(false);
+ connectingScrollView->SetDraggable(false);
+ BlueToothScrollView->Add(connectingScrollView);
+
RootView::GetInstance()->Add(BlueToothScrollView);
Draw();
}
--- /dev/null
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: PhoneService
+ * Create: 2021-09-22
+ */
+
+#ifndef PHONE_SERVICE_H
+#define PHONE_SERVICE_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int uapi_hfp_disconnect_(void);
+
+int uapi_hfp_connect_(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // PHONE_SERVICE_H
*/
#include "PhoneService.h"
+#include "PhoneServiceC.h"
+
#include "PhoneAudio.h"
#include "securec.h"
#include <cstdio>
#include "BluetoothModel.h"
#include "notification_manager.h"
#include "CallerLogModel.h"
+#include "custom_utils.h"
#ifdef __cplusplus
extern "C" {
#endif
case PROFILE_STATE_CONNECTED: // 蓝牙连接成功
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ConnStateChanged] BT connected");
BtConnectedPro(bdAddr);
+ SendMsgToUIService(BT_CONNECTED_TO_UI, 0, nullptr, 0);
+ //SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0);
break;
case PROFILE_STATE_DISCONNECTING: // 蓝牙连接断连
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ConnStateChanged] BT disconnecting");
BtDisconnectedPro();
if(0==OHOS::uapi_a2dp_snk_get_device_connect_state() && 0==uapi_hfp_connect_state())
{
- // remove by merge patch
+ SendMsgToUIService(BT_DISCONNECTED_TO_UI, 0, nullptr, 0);
+ //SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0);
}
break;
}
}
-int uapi_hfp_disconnect(void)
+int uapi_hfp_disconnect_(void)
{
int ret;
bd_addr_t bdaddr={0};
- get_phone_addr(&bdaddr);
+ OHOS:: uapi_get_br_address(&bdaddr);
ret = hfp_hf_disconnect(&bdaddr);
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "addr: ****%02x %02x %02x %02x g_bdAddr.type: %x\n",
bdaddr.addr[3], bdaddr.addr[2], bdaddr.addr[1], bdaddr.addr[0], bdaddr.type); /* 3 2 1 0 idx */
return ret;
}
-int uapi_hfp_connect(void)
+int uapi_hfp_connect_(void)
{
int ret;
- bd_addr_t bdaddr={0};
- get_phone_addr(&bdaddr);
- if(false==OHOS::uapi_get_acl_connect_state())
+ bd_addr_t bdaddr={0};
+ OHOS:: uapi_get_br_address(&bdaddr);
+
+ if(0==OHOS::uapi_a2dp_snk_get_device_connect_state() && 0==uapi_hfp_connect_state())
{
// ret= gap_connect_remote_device(&bdaddr);
// WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[gap_connect_remote_device] ret:%X", ret);
{
int ret;
bd_addr_t bdaddr={0};
- get_phone_addr(&bdaddr);
+ OHOS:: uapi_get_br_address(&bdaddr);
+
ret = hfp_hf_get_device_connect_state(&bdaddr);
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[hfp_connect_hfp] ret:%d", ret);
if(PROFILE_STATE_CONNECTED==ret || PROFILE_STATE_CONNECTING ==ret)
void uapi_hfp_send_DTMF_CODE(char code)
{
bd_addr_t bdaddr={0};
- get_phone_addr(&bdaddr);
+ OHOS:: uapi_get_br_address(&bdaddr);
+
int ret= hfp_hf_send_dtmf_tone(&bdaddr,code);
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[hfp_hf_send_dtmf_tone] ret:%d", ret);
}
+
+static uint8_t br_cmd=0;
+int uapi_hfp_connect()
+{
+ br_cmd=BR_HFP_CONNECT;
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_BR_CONNECT,&br_cmd,sizeof(br_cmd));
+ return 0;
+}
+
+
+int uapi_hfp_disconnect()
+{
+ br_cmd=BR_HFP_DISCONNECT;
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_BR_CONNECT,&br_cmd,sizeof(br_cmd));
+ return 0;
+}
+
+
+
#ifdef __cplusplus
}
#endif
#include "settings/include/SettingModel.h"
#include "main/include/PullUpDownView.h"
#include "ui_resource_string.h"
+#include "classicbluetooth/include/BluetoothServiceOptionsView.h"
namespace OHOS
{
SettingModel::SettingModel() {}
{
PullUpDownView::GetInstance()->UpdateEarPhoneStatus(status);
}
+ if(BluetoothServiceOptionsView::GetInstance())
+ {
+ BluetoothServiceOptionsView::GetInstance()->Button_UPdata();
+ }
}
// 更新蓝牙连接状态
{
PullUpDownView::GetInstance()->UpdateBlueToothStatus(status);
}
+ if(BluetoothServiceOptionsView::GetInstance())
+ {
+ BluetoothServiceOptionsView::GetInstance()->Button_UPdata();
+ }
}
}
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GAP_BLE_STATE_DISCONNECTED!!! \r\n");\r
// WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GAP_BLE_STATE_DISCONNECTED!!! svr_alipay_get_adv_start_state %d alipay_get_binding_status:%d\r\n",svr_alipay_get_adv_start_state(),alipay_get_binding_status());\r
// if(AdverFlag == true){\r
- free_ble_data(); \r
- svr_ble_adv_start(); \r
+ free_ble_data(); \r
+ if(cm_custom_ble_service_on_flag()) \r
+ svr_ble_adv_start();\r
+\r
ble_disconnect_ok(); \r
// } \r
} else {\r
\r
\r
}else{\r
- if(false==(bt_is_acl_connected(addr)))\r
+ \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(&phone_addr);\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
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
set(PUBLIC_HEADER
${CMAKE_CURRENT_SOURCE_DIR}
+ ${ROOT_DIR}/application/wearable/fd230app/nativeui/phoneservice/include
)
set(PRIVATE_HEADER
#include "custom_utils.h"
+#include "BluetoothModelC.h"
+
+#include "PhoneServiceC.h"
+
+
typedef struct
{
uint8_t cmd;
case CUSTOM_CMD_MSG_TYPE_VIBRATOR_TEST:
uapi_vibrator_test(2 * 60 * 60);
break;
+ case CUSTOM_CMD_MSG_BR_CONNECT:
+
+ switch (mail.data[0])
+ {
+ //hfp connect
+ case BR_HFP_CONNECT:
+ uapi_hfp_connect_();
+ break;
+ //hfp disconnect
+ case BR_HFP_DISCONNECT:
+ uapi_hfp_disconnect_();
+ break;
+ //a2dp connect
+ case BR_A2DP_CONNECT:
+ uapi_a2dp_snk_connect_();
+ break;
+ //a2dp disconnect
+ case BR_A2DP_DISCONNECT:
+ uapi_a2dp_snk_disconnect_();
+ break;
+ case BR_RECONNECT:
+ uapi_reconnect_();
+ break;
+ default:
+ break;
+ }
+ break;
+
default:
PRINT("Unknown CUSTOM_CMD_MSG cmd 0x%02X \r\n", mail.cmd);
break;
#define CUSTOM_CMD_MSG_TYPE_CROWN_TEST 0x0A
#define CUSTOM_CMD_MSG_TYPE_VIBRATOR_TEST 0x0B
+#define CUSTOM_CMD_MSG_BR_CONNECT 0x0C
+
+typedef enum {
+ BR_HFP_CONNECT=1,
+ BR_HFP_DISCONNECT,
+ BR_A2DP_CONNECT,
+ BR_A2DP_DISCONNECT,
+ BR_RECONNECT,
+
+} CUSTOM_CMD_MSG_BR_CONNECT_TYPE;
+
errcode_t uapi_custom_cmd_service_init(void);
void do_custom_cmd_service_check_msg(int cmd, void *params, int paramlen);
int uapi_delete_files(const char *file_path);
case 1:
uapi_reconnect();
break;
- // case 2:
- // custom_ble_service_start();
- // break;
+ case 2:
+ custom_ble_service_start();
+ break;
case 3:
custom_ble_service_start_(atoi( (char *)argv[1]));
break;
case 4:
uapi_a2dp_snk_connect();
break;
- // case 5:
- // svr_ble_adv_stop();
- // break;
- // case 6:
- // uapi_disconnect_remote_device();
- // break;
- // case 7:
- // uapi_ble_disconnect_device();
- // break;
+ case 5:
+ svr_ble_adv_stop();
+ break;
+ case 6:
+ uapi_disconnect_remote_device();
+ break;
+ case 7:
+ uapi_ble_disconnect_device();
+ break;
- // case 3:
- // gap_br_set_bt_scan_mode(GAP_SCAN_MODE_NONE, 20);;
- // break;
-
default:
break;
}