// 获取手机连接状态
bool PullUpDownView::GetPhoneConnectedStatus(void)
{
- return true;
+ uint8_t ret = uapi_dev_runtime_get_ble_connect_stat();
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "ble phone connect stat = %d", ret);
+ if (ret == 1)
+ return true;
+ else
+ return false;
}
// 获取蓝牙耳机连接状态
bool PullUpDownView::GetEarPhoneConnectedStatus(void)
{
- runtime_status_t *g_runtime = get_device_runtime_status();
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "g_runtime->bt_connected = %d", g_runtime->bt_connected);
- return true;
+ uint8_t ret = uapi_dev_runtime_get_earphone_connect_stat();
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "earphone connect stat = %d", ret);
+ if (ret == 1)
+ return true;
+ else
+ return false;
}
// 获取蓝牙连接状态
bool PullUpDownView::GetBluetoothConnectedStatus(void)
{
- return true;
+ uint8_t ret = uapi_dev_runtime_get_br_connect_stat();
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "br connect stat = %d [0 no connect, 1 a2dp, 2 hfp, 3 both]", ret);
+ if (ret != 0)
+ return true;
+ else
+ return false;
}
/// @brief 连接状态
#include "hidService.h"\r
#include "factorytestService.h"\r
#include "ppgBleService.h"\r
+#include "custom_runtime.h"\r
\r
// extern void bts_data_to_uuid_len2(uint16_t uuid_data, bt_uuid_t *out_uuid);\r
// extern void bts_init_128bit_uuid(const bt_uuid_t *uuid);\r
uint16_t data2ae4Cmd = 0;\r
uint16_t data2ae5Cmd = 0;\r
uint16_t data2ae1Cmd = 0;//安卓消息来电\r
+\r
#if 1//def SUPPORT_BLE_SERVICE\r
static void set_phone_info(bd_addr_t *addr)//保存手机信息 包含手机mac地址\r
{\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GAP_BLE_STATE_CONNECTED!!! 0x%x\r\n",pair_state);\r
\r
}\r
+\r
+ uapi_dev_runtime_set_ble_connect_stat(Bleconnect);\r
}\r
\r
static void svr_pair_result_cbt_cb(uint16_t conn_id, const bd_addr_t *addr, errcode_t status)\r
static int g_listen_sock = 0;
struct sockaddr_in sourceAddr = {0};
static osTimerId_t g_timer_time_sync = NULL;
-#if USE_CAT1_SLEEP_TIMER
+#ifdef USE_CAT1_SLEEP_TIMER
static osTimerId_t g_timer_cat1_sleep = NULL;
#endif
static uint8_t g_time_synced = 0;
return 1;
}
-#if USE_CAT1_SLEEP_TIMER
+#ifdef USE_CAT1_SLEEP_TIMER
void mcu_remove_sleepvote_and_stoptimer(void)
{
// uapi_cat1_wakeup_cat1(0);// 反馈给cat1,它也可以自己睡
runtime_status_t * runtime = get_device_runtime_status();
if (uapi_cat1_get_power_stat() == false )
{
+ // PRINT("cat1 power off reset cat1_runtime \n");
//开关是关的 则cat1所有状态清空
runtime->cat1_runtime.cat1_powerOn = 0;
runtime->cat1_runtime.network_on = 0;
restart_time_sync();
-#if USE_CAT1_SLEEP_TIMER
+#ifdef USE_CAT1_SLEEP_TIMER
g_timer_cat1_sleep = osTimerNew((osTimerFunc_t)timeout_handler_sleep_cat1, osTimerPeriodic, NULL, NULL);
if (g_timer_cat1_sleep == NULL)
PRINT("g_timer_cat1_sleep create failed\n");
uapi_cat1_add_cat1_vote();
//中断会在此添加休眠投票,在收到cat1的消息后,会移除投票进入休眠。
//之前的5秒后移除投票延迟太久,与5秒更新一次信号强度
- #if USE_CAT1_SLEEP_TIMER
+ #ifdef USE_CAT1_SLEEP_TIMER
restart_sleep_cat1_timer();
#endif
break;
case CUSTOM_CMD_MSG_TYPE_REMOVE_CAT1VOTE:
- #if USE_CAT1_SLEEP_TIMER
+ #ifdef USE_CAT1_SLEEP_TIMER
mcu_remove_sleepvote_and_stoptimer();
#endif
break;
return &g_runtime;
}
+
+void uapi_dev_runtime_set_bt_powerstat(uint8_t stat)
+{
+ g_runtime.bt_powerOn = stat;
+}
+void uapi_dev_runtime_set_ble_connect_stat(uint8_t connect)
+{
+ g_runtime.bt_ble_connectstat = connect;
+}
+void uapi_dev_runtime_set_br_connect_stat(uint8_t connect)
+{
+ g_runtime.bt_br_connectstat = connect;
+}
+void uapi_dev_runtime_set_earphone_connect_stat(uint8_t connect)
+{
+ g_runtime.bt_earphone_connectstat = connect;
+}
+
+
+
+uint8_t uapi_dev_runtime_get_bt_powerstat(void)
+{
+ return g_runtime.bt_powerOn ;
+}
+uint8_t uapi_dev_runtime_get_ble_connect_stat(void)
+{
+ return g_runtime.bt_ble_connectstat;
+}
+uint8_t uapi_dev_runtime_get_br_connect_stat(void)
+{
+ return g_runtime.bt_br_connectstat ;
+}
+uint8_t uapi_dev_runtime_get_earphone_connect_stat(void)
+{
+ return g_runtime.bt_earphone_connectstat ;
+}
\ No newline at end of file
char modemVer[64] ;
}cat1_runtime_status_t;
-
+/**
+ * 设备实时状态记录
+ * in_silent_mode 勿扰模式 1 勿扰模式, 0 正常模式
+ * in_lowpower_mode 低电模式 1 低电模式, 0 正常模式
+ * stepcount 步数
+ * bt_powerOn 蓝牙开关 1 开 , 0 关
+ * bt_ble_connectstat 设备已连接手机 1连接, 0 未连接
+ * bt_br_connectstat 经典蓝牙连接状态 0 未连接, 1 连接a2dp 2 连接hfp 3 连接 a2dp+hfp
+ * bt_earphone_connectstat 连接耳机状态 1连接, 0 未连接
+ * cat1_runtime cat1实时状态,详见 cat1_runtime_status_t 定义
+ * */
typedef struct
{
uint8_t in_silent_mode;
uint8_t in_lowpower_mode;
uint8_t stepcount;
uint8_t bt_powerOn;
- uint8_t bt_connected;
-
+ uint8_t bt_ble_connectstat;
+ uint8_t bt_br_connectstat;
+ uint8_t bt_earphone_connectstat;
cat1_runtime_status_t cat1_runtime;
} runtime_status_t;
+/**
+ * 获取 设备实时状态变量
+ * 详细内容见 runtime_status_t 定义
+*/
runtime_status_t * get_device_runtime_status(void);
+
+/**
+ * 设置蓝牙开关状态
+*/
+void uapi_dev_runtime_set_bt_powerstat(uint8_t stat);
+/**
+ * 设置ble(手机协议)连接状态 1连接, 0 未连接
+*/
+void uapi_dev_runtime_set_ble_connect_stat(uint8_t connect);
+/**
+ * 设置经典蓝牙协议连接状态, 0 未连接, 1 连接a2dp 2 连接hfp 3 连接 a2dp+hfp
+*/
+void uapi_dev_runtime_set_br_connect_stat(uint8_t connect);
+/**
+ * 设置耳机连接状态 1连接, 0 未连接
+*/
+void uapi_dev_runtime_set_earphone_connect_stat(uint8_t connect);
+
+/**
+ * 获取蓝牙电源状态 1开启0 关闭
+*/
+uint8_t uapi_dev_runtime_get_bt_powerstat(void);
+/**
+ * 获取ble(手机协议)连接状态 1 连接,0 未连接
+*/
+uint8_t uapi_dev_runtime_get_ble_connect_stat(void);
+
+/**
+ * 获取经典蓝牙协议连接状态, 0 未连接, 1 连接a2dp 2 连接hfp 3 连接 a2dp+hfp
+*/
+uint8_t uapi_dev_runtime_get_br_connect_stat(void);
+/**
+ * 获取耳机连接状态 1连接, 0 未连接
+*/
+uint8_t uapi_dev_runtime_get_earphone_connect_stat(void);
+
#ifdef __cplusplus
#if __cplusplus
}
#include "networkandcall/include/NetworkAndCallC.h"
#include <dirent.h>
#include <unistd.h>
-
+#include "custom_runtime.h"
#define SUPPORT_NV
PRINT("start custom protocol classic bt ble service !\r\n");
// bool ret = enable_bt_stack();
#endif
+ uapi_dev_runtime_set_bt_powerstat(1);
return true;
}
bool stop_custom_ble_service(void)
closeBle();
// bool ret = disable_bt_stack();
#endif
+ uapi_dev_runtime_set_bt_powerstat(0);
return true;
}
errcode_t custom_iic_init(void)
{
errcode_t result;
+
+// #ifdef CONFIG_I2C_SUPPORT_DMA
+// #if CONFIG_I2C_SUPPORT_DMA
+// #warning CONFIG_I2C_SUPPORT_DMA = 1
+// #else
+// #warning CONFIG_I2C_SUPPORT_DMA = 0
+// #endif
+// #endif
if(i2c_installed == 0)
{
result = uapi_i2c_master_init(I2C_BUS_2, 400000, I2C_SPEED_MODE_FS); /* 400000: 400KHz */