I'm working on doing A2DP sink over classic BT and Hid over BTLE GATT server on one esp32 at the same time.
The problem is that i can't discover the Hid part. The A2DP works fine by the way. The only way i can use th hid part is commenting BT classic initialisation:
Code: Select all
/* create application task */
// bt_app_task_start_up();
/* Bluetooth device name, connection mode and profile set up */
// bt_app_work_dispatch(bt_av_hdl_stack_evt, BT_APP_EVT_STACK_UP, NULL, 0, NULL);
// if((ret = esp_hidd_profile_init()) != ESP_OK) {
// ESP_LOGE(HID_DEMO_TAG, "%s init bluedroid failed\n", __func__);
// }
I'm providing my main. And can provide logs if needed.
Code: Select all
/*
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
/****************************************************************************
* The demo shows BLE and classic Bluetooth coexistence. You can use BLE gatt server and classic bluetooth A2DP together.
* The BLE GATT SERVER part of demo creates GATT a service and then starts advertising, waiting to be connected by a GATT client.
* After the program is started, the GATT client can discover a device named "ESP_COEX_BLE_DEMO". Once a connection is established,
* GATT client can reaad or write data to the device. Or GATT client receive notification or indication data.
* Attention: IF you test the demo with iphone, BLE gatt server adv name will change to "ESP_COEX_A2DP_DEMO" afte you connect it.
* The classic bluetooth A2DP part of the demo of API implementing Advanced Audio Distribution Profile to receive an audio stream.
* After the program is started, other bluetooth devices such as smart phones can discover a device named "ESP_COEX_A2DP_DEMO".
* Once a connection is established, audio data can be transmitted. This will be visible in the application log including a count
* of audio data packets.
****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "nvs.h"
#include "nvs_flash.h"
#include "esp_system.h"
#include "esp_log.h"
#include "esp_hidd_prf_api.h"
#include "esp_bt_defs.h"
#include "hid_device_le_prf.c"
#include "esp_gap_ble_api.h"
#include "esp_gatts_api.h"
#include "esp_gatt_defs.h"
#include "esp_bt_main.h"
#include "esp_bt_device.h"
#include "driver/gpio.h"
#include "hid_dev.h"
#include "esp_event_loop.h"
#include "esp_bt.h"
#include "bt_app_core.h"
#include "bt_app_av.h"
#include "esp_gap_bt_api.h"
#include "esp_a2dp_api.h"
#include "esp_avrc_api.h"
#include "driver/i2s.h"
#include "esp_gatt_common_api.h"
#define BT_BLE_COEX_TAG "BT_BLE_COEX"
#define BT_DEVICE_NAME "A2DP"
#define HID_DEMO_TAG "HID_DEMO"
#define GPIO_INPUT_IO_HAUT 25
#define GPIO_INPUT_IO_GAUCHE 26
#define GPIO_INPUT_IO_DROITE 27
#define GPIO_INPUT_IO_BAS 14
#define GPIO_INPUT_IO_TRIANGLE 19
#define GPIO_INPUT_IO_CARRE 18
#define GPIO_INPUT_IO_CROIX 17
#define GPIO_INPUT_IO_ROUND 16
#define GPIO_INPUT_PIN_SEL ((1<<GPIO_INPUT_IO_HAUT) | (1<<GPIO_INPUT_IO_GAUCHE) | (1<<GPIO_INPUT_IO_DROITE) | (1<<GPIO_INPUT_IO_BAS) | (1<<GPIO_INPUT_IO_TRIANGLE) | (1<<GPIO_INPUT_IO_CARRE) | (1<<GPIO_INPUT_IO_CROIX) | (1<<GPIO_INPUT_IO_ROUND))
#define ESP_INTR_FLAG_DEFAULT 0
static xQueueHandle gpio_evt_queue = NULL;
static uint16_t hid_conn_id = 0;
static bool sec_conn = false;
#define HIDD_DEVICE_NAME "Gamepad"
static void hidd_event_callback(esp_hidd_cb_event_t event, esp_hidd_cb_param_t *param);
static uint8_t hidd_service_uuid128[] = {
/* LSB <--------------------------------------------------------------------------------> MSB */
//first uuid, 16bit, [12],[13] is the value
0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x12, 0x18, 0x00, 0x00,
};
/* event for handler "bt_av_hdl_stack_up */
enum {
BT_APP_EVT_STACK_UP = 0,
};
static esp_ble_adv_data_t hidd_adv_data = {
.set_scan_rsp = false,
.include_name = true,
.include_txpower = true,
.min_interval = 0x20,
.max_interval = 0x30,
.appearance = 0x03c0, //HID Generic,
.manufacturer_len = 0,
.p_manufacturer_data = NULL,
.service_data_len = 0,
.p_service_data = NULL,
.service_uuid_len = sizeof(hidd_service_uuid128),
.p_service_uuid = hidd_service_uuid128,
.flag = 0x6,
};
static esp_ble_adv_params_t hidd_adv_params = {
.adv_int_min = 0x20,
.adv_int_max = 0x30,
.adv_type = ADV_TYPE_IND,
.own_addr_type = BLE_ADDR_TYPE_PUBLIC,
.channel_map = ADV_CHNL_ALL,
.adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY,
};
void IRAM_ATTR gpio_isr_handler(void* arg)
{
uint32_t gpio_num = (uint32_t) arg;
xQueueSendFromISR(gpio_evt_queue, &gpio_num, NULL);
}
void gpio_task_example(void* arg)
{
static uint8_t i = 0;
uint32_t io_num;
for(;;) {
if(xQueueReceive(gpio_evt_queue, &io_num, portMAX_DELAY)) {
ESP_LOGI(HID_DEMO_TAG, "GPIO[%d] intr, val: %d\n", io_num, gpio_get_level(io_num));
switch (io_num) {
case GPIO_INPUT_IO_HAUT: {
uint8_t key_vaule = {HID_KEY_A};
if(gpio_get_level(io_num)==0)
{
esp_hidd_send_keyboard_value(hid_conn_id, 0, &key_vaule, 1);
ESP_LOGI(HID_DEMO_TAG, "SENDING HID KEYPRESS : %c \n", 'A');
}else{
esp_hidd_send_keyboard_value(hid_conn_id, 0, &key_vaule, 0);
ESP_LOGI(HID_DEMO_TAG, "SENDING HID KEYUP : %c \n", 'A');
}
}
break;
case GPIO_INPUT_IO_GAUCHE: {
uint8_t key_vaule = {HID_KEY_B};
if(gpio_get_level(io_num)==0)
{
esp_hidd_send_keyboard_value(hid_conn_id, 0, &key_vaule, 1);
ESP_LOGI(HID_DEMO_TAG, "SENDING HID KEYPRESS : %c \n", 'B');
}else{
esp_hidd_send_keyboard_value(hid_conn_id, 0, &key_vaule, 0);
ESP_LOGI(HID_DEMO_TAG, "SENDING HID KEYUP : %c \n", 'B');
}
}
break;
case GPIO_INPUT_IO_DROITE: {
uint8_t key_vaule = {HID_KEY_C};
if(gpio_get_level(io_num)==0)
{
esp_hidd_send_keyboard_value(hid_conn_id, 0, &key_vaule, 1);
ESP_LOGI(HID_DEMO_TAG, "SENDING HID KEYPRESS : %c \n", 'C');
}else{
esp_hidd_send_keyboard_value(hid_conn_id, 0, &key_vaule, 0);
ESP_LOGI(HID_DEMO_TAG, "SENDING HID KEYUP : %c \n", 'C');
}
}
break;
case GPIO_INPUT_IO_BAS: {
uint8_t key_vaule = {HID_KEY_D};
if(gpio_get_level(io_num)==0)
{
esp_hidd_send_keyboard_value(hid_conn_id, 0, &key_vaule, 1);
ESP_LOGI(HID_DEMO_TAG, "SENDING HID KEYPRESS : %c \n", 'D');
}else{
esp_hidd_send_keyboard_value(hid_conn_id, 0, &key_vaule, 0);
ESP_LOGI(HID_DEMO_TAG, "SENDING HID KEYUP : %c \n", 'D');
}
}
break;
case GPIO_INPUT_IO_CROIX: {
uint8_t key_vaule = {HID_KEY_E};
if(gpio_get_level(io_num)==0)
{
esp_hidd_send_keyboard_value(hid_conn_id, 0, &key_vaule,0);
ESP_LOGI(HID_DEMO_TAG, "SENDING HID KEYPRESS : %c \n", 'E');
}else{
esp_hidd_send_keyboard_value(hid_conn_id, 0, &key_vaule, 1);
ESP_LOGI(HID_DEMO_TAG, "SENDING HID KEYUP : %c \n", 'E');
}
}
break;
case GPIO_INPUT_IO_CARRE: {
uint8_t key_vaule = {HID_KEY_F};
if(gpio_get_level(io_num)==0)
{
esp_hidd_send_keyboard_value(hid_conn_id, 0, &key_vaule, 0);
ESP_LOGI(HID_DEMO_TAG, "SENDING HID KEYPRESS : %c \n", 'F');
}else{
esp_hidd_send_keyboard_value(hid_conn_id, 0, &key_vaule, 1);
ESP_LOGI(HID_DEMO_TAG, "SENDING HID KEYUP : %c \n", 'F');
}
}
break;
case GPIO_INPUT_IO_ROUND: {
uint8_t key_vaule = {HID_KEY_G};
if(gpio_get_level(io_num)==0)
{
esp_hidd_send_keyboard_value(hid_conn_id, 0, &key_vaule, 0);
ESP_LOGI(HID_DEMO_TAG, "SENDING HID KEYPRESS : %c \n", 'G');
}else{
esp_hidd_send_keyboard_value(hid_conn_id, 0, &key_vaule, 1);
ESP_LOGI(HID_DEMO_TAG, "SENDING HID KEYUP : %c \n", 'G');
}
}
break;
case GPIO_INPUT_IO_TRIANGLE: {
uint8_t key_vaule = {HID_KEY_H};
if(gpio_get_level(io_num)==0)
{
esp_hidd_send_keyboard_value(hid_conn_id, 0, &key_vaule, 0);
ESP_LOGI(HID_DEMO_TAG, "SENDING HID KEYPRESS : %c \n", 'H');
}else{
esp_hidd_send_keyboard_value(hid_conn_id, 0, &key_vaule, 1);
ESP_LOGI(HID_DEMO_TAG, "SENDING HID KEYUP : %c \n", 'H');
}
}
break;
}
if(i == 0) {
++i;
}
}
}
}
static void gpio_demo_init(void)
{
gpio_config_t io_conf;
/*
//disable interrupt
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
//set as output mode
io_conf.mode = GPIO_MODE_OUTPUT;
//bit mask of the pins that you want to set,e.g.GPIO18/19
io_conf.pin_bit_mask = GPIO_OUTPUT_PIN_SEL;
//disable pull-down mode
io_conf.pull_down_en = 0;
//disable pull-up mode
io_conf.pull_up_en = 0;
//configure GPIO with the given settings
gpio_config(&io_conf);
*/
//interrupt of rising edge
io_conf.intr_type = GPIO_INTR_ANYEDGE;
//bit mask of the pins, use GPIO4/5 here
io_conf.pin_bit_mask = GPIO_INPUT_PIN_SEL;
//set as input mode
io_conf.mode = GPIO_MODE_INPUT;
//enable pull-up mode
io_conf.pull_up_en = 0;
io_conf.pull_down_en = 0;
gpio_config(&io_conf);
//change gpio intrrupt type for one pin
gpio_set_intr_type(GPIO_INPUT_IO_HAUT, GPIO_INTR_ANYEDGE);
gpio_set_intr_type(GPIO_INPUT_IO_BAS, GPIO_INTR_ANYEDGE);
gpio_set_intr_type(GPIO_INPUT_IO_GAUCHE, GPIO_INTR_ANYEDGE);
gpio_set_intr_type(GPIO_INPUT_IO_DROITE, GPIO_INTR_ANYEDGE);
gpio_set_intr_type(GPIO_INPUT_IO_CARRE, GPIO_INTR_ANYEDGE);
gpio_set_intr_type(GPIO_INPUT_IO_ROUND, GPIO_INTR_ANYEDGE);
gpio_set_intr_type(GPIO_INPUT_IO_TRIANGLE, GPIO_INTR_ANYEDGE);
gpio_set_intr_type(GPIO_INPUT_IO_CROIX, GPIO_INTR_ANYEDGE);
//create a queue to handle gpio event from isr
gpio_evt_queue = xQueueCreate(20, sizeof(uint32_t));
//start gpio task
xTaskCreate(gpio_task_example, "gpio_task_example", 2048, NULL, 10, NULL);
//install gpio isr service
gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT);
//hook isr handler for specific gpio pin
gpio_isr_handler_add(GPIO_INPUT_IO_BAS, gpio_isr_handler, (void*) GPIO_INPUT_IO_BAS);
//hook isr handler for specific gpio pin
gpio_isr_handler_add(GPIO_INPUT_IO_HAUT, gpio_isr_handler, (void*) GPIO_INPUT_IO_HAUT);
gpio_isr_handler_add(GPIO_INPUT_IO_GAUCHE, gpio_isr_handler, (void*) GPIO_INPUT_IO_GAUCHE);
//hook isr handler for specific gpio pin
gpio_isr_handler_add(GPIO_INPUT_IO_DROITE, gpio_isr_handler, (void*) GPIO_INPUT_IO_DROITE);
//hook isr handler for specific gpio pin
gpio_isr_handler_add(GPIO_INPUT_IO_CROIX, gpio_isr_handler, (void*) GPIO_INPUT_IO_CROIX);
//hook isr handler for specific gpio pin
gpio_isr_handler_add(GPIO_INPUT_IO_ROUND, gpio_isr_handler, (void*) GPIO_INPUT_IO_ROUND);
gpio_isr_handler_add(GPIO_INPUT_IO_CARRE, gpio_isr_handler, (void*) GPIO_INPUT_IO_CARRE);
//hook isr handler for specific gpio pin
gpio_isr_handler_add(GPIO_INPUT_IO_TRIANGLE, gpio_isr_handler, (void*) GPIO_INPUT_IO_TRIANGLE);
}
static void hidd_event_callback(esp_hidd_cb_event_t event, esp_hidd_cb_param_t *param)
{
ESP_LOGE(HID_DEMO_TAG,"hidd_event_callback, ca veut dire que y a hid dans la stack : %d",event);
switch(event) {
case ESP_HIDD_EVENT_REG_FINISH: {
ESP_LOGE(HID_DEMO_TAG,"hidd_event_callback");
if (param->init_finish.state == ESP_HIDD_INIT_OK) {
//esp_bd_addr_t rand_addr = {0x04,0x11,0x11,0x11,0x11,0x05};
esp_ble_gap_set_device_name(HIDD_DEVICE_NAME);
esp_ble_gap_config_adv_data(&hidd_adv_data);
}
break;
}
case ESP_BAT_EVENT_REG: {
ESP_LOGE(HID_DEMO_TAG,"hidd_event_callback,ESP_BAT_EVENT_REG");
break;
}
case ESP_HIDD_EVENT_DEINIT_FINISH:{
ESP_LOGE(HID_DEMO_TAG,"hidd_event_callback,ESP_HIDD_EVENT_DEINIT_FINISH");
}
break;
case ESP_HIDD_EVENT_BLE_CONNECT: {
ESP_LOGI(HID_DEMO_TAG, "ESP_HIDD_EVENT_BLE_CONNECT");
hid_conn_id = param->connect.conn_id;
break;
}
case ESP_HIDD_EVENT_BLE_DISCONNECT: {
sec_conn = false;
ESP_LOGI(HID_DEMO_TAG, "ESP_HIDD_EVENT_BLE_DISCONNECT");
esp_ble_gap_start_advertising(&hidd_adv_params);
break;
}
case ESP_HIDD_EVENT_BLE_VENDOR_REPORT_WRITE_EVT: {
ESP_LOGI(HID_DEMO_TAG, "%s, ESP_HIDD_EVENT_BLE_VENDOR_REPORT_WRITE_EVT", __func__);
ESP_LOG_BUFFER_HEX(HID_DEMO_TAG, param->vendor_write.data, param->vendor_write.length);
}
default:
break;
}
return;
}
static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)
{
switch (event) {
case ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT:
ESP_LOGE(HID_DEMO_TAG,"configuration de l'advertising fait !");
esp_err_t ret = esp_ble_gap_start_advertising(&hidd_adv_params);
if (ret) {
ESP_LOGE(HID_DEMO_TAG,"l'advertising fail !!!!!!!");
return;
}else{
ESP_LOGE(HID_DEMO_TAG,"l'advertising reussi");
}
break;
case ESP_GAP_BLE_SEC_REQ_EVT:
for(int i = 0; i < ESP_BD_ADDR_LEN; i++) {
ESP_LOGD(HID_DEMO_TAG, "%x:",param->ble_security.ble_req.bd_addr[i]);
}
esp_ble_gap_security_rsp(param->ble_security.ble_req.bd_addr, true);
break;
case ESP_GAP_BLE_AUTH_CMPL_EVT:
sec_conn = true;
esp_bd_addr_t bd_addr;
memcpy(bd_addr, param->ble_security.auth_cmpl.bd_addr, sizeof(esp_bd_addr_t));
ESP_LOGI(HID_DEMO_TAG, "remote BD_ADDR: %08x%04x",\
(bd_addr[0] << 24) + (bd_addr[1] << 16) + (bd_addr[2] << 8) + bd_addr[3],
(bd_addr[4] << 8) + bd_addr[5]);
ESP_LOGI(HID_DEMO_TAG, "address type = %d", param->ble_security.auth_cmpl.addr_type);
ESP_LOGI(HID_DEMO_TAG, "pair status = %s",param->ble_security.auth_cmpl.success ? "success" : "fail");
if(!param->ble_security.auth_cmpl.success) {
ESP_LOGE(HID_DEMO_TAG, "fail reason = 0x%x",param->ble_security.auth_cmpl.fail_reason);
}
break;
default:
break;
}
}
/* handler for bluetooth stack enabled events */
static void bt_av_hdl_stack_evt(uint16_t event, void *p_param)
{
ESP_LOGD(BT_BLE_COEX_TAG, "%s evt %d", __func__, event);
switch (event) {
case BT_APP_EVT_STACK_UP: {
/* set up bt device name */
esp_bt_dev_set_device_name(BT_DEVICE_NAME);
/* initialize A2DP sink */
esp_a2d_register_callback(&bt_app_a2d_cb);
esp_a2d_sink_register_data_callback(bt_app_a2d_data_cb);
esp_a2d_sink_init();
/* initialize AVRCP controller */
esp_avrc_ct_init();
esp_avrc_ct_register_callback(bt_app_rc_ct_cb);
/* set discoverable and connectable mode, wait to be connected */
esp_bt_gap_set_scan_mode(ESP_BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE);
break;
}
default:
ESP_LOGE(BT_BLE_COEX_TAG, "%s unhandled evt %d", __func__, event);
break;
}
}
static void ble_gatts_init(void)
{
esp_err_t ret = esp_hidd_register_callbacks(hidd_event_callback);
if (ret){
ESP_LOGE(BT_BLE_COEX_TAG, "hid register error, error code = %x", ret);
return;
}
ret = esp_ble_gap_register_callback(gap_event_handler);
if (ret){
ESP_LOGE(BT_BLE_COEX_TAG, "gap register error, error code = %x", ret);
return;
}
///register the callback function to the gap module
/* set the security iocap & auth_req & key size & init key response key parameters to the stack*/
esp_ble_auth_req_t auth_req = ESP_LE_AUTH_BOND; //bonding with peer device after authentication
esp_ble_io_cap_t iocap = ESP_IO_CAP_NONE; //set the IO capability to No output No input
uint8_t key_size = 16; //the key size should be 7~16 bytes
uint8_t init_key = ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK;
uint8_t rsp_key = ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK;
esp_ble_gap_set_security_param(ESP_BLE_SM_AUTHEN_REQ_MODE, &auth_req, sizeof(uint8_t));
esp_ble_gap_set_security_param(ESP_BLE_SM_IOCAP_MODE, &iocap, sizeof(uint8_t));
esp_ble_gap_set_security_param(ESP_BLE_SM_MAX_KEY_SIZE, &key_size, sizeof(uint8_t));
/* If your BLE device act as a Slave, the init_key means you hope which types of key of the master should distribut to you,
and the response key means which key you can distribut to the Master;
If your BLE device act as a master, the response key means you hope which types of key of the slave should distribut to you,
and the init key means which key you can distribut to the slave. */
esp_ble_gap_set_security_param(ESP_BLE_SM_SET_INIT_KEY, &init_key, sizeof(uint8_t));
esp_ble_gap_set_security_param(ESP_BLE_SM_SET_RSP_KEY, &rsp_key, sizeof(uint8_t));
}
void app_main()
{
esp_err_t ret;
// Initialize NVS.
ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK( ret );
i2s_config_t i2s_config = {
#ifdef CONFIG_A2DP_SINK_OUTPUT_INTERNAL_DAC
.mode = I2S_MODE_DAC_BUILT_IN,
#else
.mode = I2S_MODE_MASTER | I2S_MODE_TX, // Only TX
#endif
.sample_rate = 44100,
.bits_per_sample = 16,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, //2-channels
.communication_format = I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB,
.dma_buf_count = 6,
.dma_buf_len = 60, //
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1 //Interrupt level 1
};
i2s_driver_install(0, &i2s_config, 0, NULL);
#ifdef CONFIG_A2DP_SINK_OUTPUT_INTERNAL_DAC
i2s_set_pin(0, NULL);
#else
i2s_pin_config_t pin_config = {
.bck_io_num = CONFIG_I2S_BCK_PIN,
.ws_io_num = CONFIG_I2S_LRCK_PIN,
.data_out_num = CONFIG_I2S_DATA_PIN,
.data_in_num = -1 //Not used
};
i2s_set_pin(0, &pin_config);
#endif
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
ret = esp_bt_controller_init(&bt_cfg);
if (ret) {
ESP_LOGE(BT_BLE_COEX_TAG, "%s initialize controller failed\n", __func__);
return;
}
ret = esp_bt_controller_enable(ESP_BT_MODE_BTDM); //ESP_BT_MODE_BTDM obligé pour bt dua mode
if (ret) {
ESP_LOGE(BT_BLE_COEX_TAG, "%s enable controller failed\n", __func__);
return;
}else{
ESP_LOGE(BT_BLE_COEX_TAG, " enable controller in dual mode reussi !!!");
}
ret = esp_bluedroid_init();
if (ret) {
ESP_LOGE(BT_BLE_COEX_TAG, "%s init bluetooth failed\n", __func__);
return;
}
ret = esp_bluedroid_enable();
if (ret) {
ESP_LOGE(BT_BLE_COEX_TAG, "%s enable bluetooth failed\n", __func__);
return;
}
//gatt server init
ble_gatts_init();
/* create application task */
bt_app_task_start_up();
/* Bluetooth device name, connection mode and profile set up */
bt_app_work_dispatch(bt_av_hdl_stack_evt, BT_APP_EVT_STACK_UP, NULL, 0, NULL);
if((ret = esp_hidd_profile_init()) != ESP_OK) {
ESP_LOGE(HID_DEMO_TAG, "%s init bluedroid failed\n", __func__);
}
//init the gpio pin
gpio_demo_init();
}