msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
- msg.act = BTC_GAP_BLE_ACT_SET_SCAN_PARAM;
+ msg.act = BTC_GAP_BLE_ACT_START_SCAN;
arg.duration = duration;
- return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+ return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
- esp_ble_gap_args_t arg;
+
+ esp_err_t esp_ble_gap_stop_scanning(void)
+ {
+ btc_msg_t msg;
- return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
++ btc_ble_gap_args_t arg;
+
+ msg.sig = BTC_SIG_API_CALL;
+ msg.pid = BTC_PID_GAP_BLE;
+ msg.act = BTC_GAP_BLE_ACT_STOP_SCAN;
++ return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+ }
+
esp_err_t esp_ble_gap_start_advertising(esp_ble_adv_params_t *adv_params)
{
btc_msg_t msg;
msg.act = BTC_GAP_BLE_ACT_SET_DEV_NAME;
strcpy(arg.device_name, name);
- return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+ return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
+
+ /*******************************************************************************
+ **
+ ** Function esp_ble_resolve_adv_data
+ **
+ ** Description This function is called to get ADV data for a specific type.
+ **
+ ** Parameters p_adv - pointer of ADV data
+ ** type - finding ADV data type
+ ** p_length - return the length of ADV data not including type
+ **
+ ** Returns pointer of ADV data
+ **
+ *******************************************************************************/
+ uint8_t *esp_ble_resolve_adv_data( uint8_t *p_adv, uint8_t type, uint8_t *p_length )
+ {
+ if (((type < ESP_BLE_AD_TYPE_FLAG) || (type > ESP_BLE_AD_TYPE_128SERVICE_DATA)) &&
+ (type != ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE))
+ {
+ LOG_ERROR("the eir type not define, type = %x\n", type);
+ return NULL;
+ }
+
+ if (p_adv == NULL)
+ {
+ LOG_ERROR("Invalid p_eir data.\n");
+ return NULL;
+ }
+
+ return (BTM_CheckAdvData( p_adv, type, p_length));
+ }
+
bool set_scan_rsp;
bool include_name;
bool include_txpower;
- int min_interval;
- int max_interval;
- int appearance;
+ int min_interval;
+ int max_interval;
+ int appearance;
uint16_t manufacturer_len;
- uint8_t *p_manufacturer_data;
+ uint8_t *p_manufacturer_data;
uint16_t service_data_len;
- uint8_t *p_service_data;
+ uint8_t *p_service_data;
uint16_t service_uuid_len;
- uint8_t *p_service_uuid;
- uint8_t flag;
+ uint8_t *p_service_uuid;
+ uint8_t flag;
} esp_ble_adv_data_t;
+ /// Own BD address source of the device
+ typedef enum
+ {
+ /// Public Address
+ ESP_PUBLIC_ADDR,
+ /// Provided random address
+ ESP_PROVIDED_RND_ADDR,
+ /// Provided static random address
+ ESP_GEN_STATIC_RND_ADDR,
+ /// Generated resolvable private random address
+ ESP_GEN_RSLV_ADDR,
+ /// Generated non-resolvable private random address
+ ESP_GEN_NON_RSLV_ADDR,
+ /// Provided Reconnection address
+ ESP_PROVIDED_RECON_ADDR,
+ }esp_ble_own_addr_src_t;
+
+
typedef enum {
BLE_SCAN_TYPE_PASSIVE = 0x0,
BLE_SCAN_TYPE_ACTIVE = 0x1,
ESP_GATT_CHAR_PROP_BIT_EXT_PROP = (1 << 7), /* 0x80 */
} esp_gatt_char_prop_t;
-#define ESP_GATT_MAX_ATTR_LEN 300
+#define ESP_GATT_MAX_ATTR_LEN 600 //as same as GATT_MAX_ATTR_LEN
++
typedef struct {
uint8_t value[ESP_GATT_MAX_ATTR_LEN];
uint16_t handle;
LOG_ERROR("Invalid advertisting type parameters.\n");
return;
}
+ LOG_DEBUG("API_Ble_AppStartAdvertising\n");
- LOG_ERROR("API_Ble_AppStartAdvertising\n");
-
- bd_addr.type = ble_adv_params->peer_addr_type;
- memcpy(&bd_addr.bda, ble_adv_params->peer_addr, sizeof(BD_ADDR));
///
+ memcpy(peer_addr.bda, ble_adv_params->peer_addr, ESP_BD_ADDR_LEN);
+ peer_addr.type = ble_adv_params->peer_addr_type;
BTA_DmSetBleAdvParamsAll(ble_adv_params->adv_int_min,
- ble_adv_params->adv_int_max,
- ble_adv_params->adv_type,
- ble_adv_params->own_addr_type,
- ble_adv_params->channel_map,
- ble_adv_params->adv_filter_policy,
- &bd_addr);
-
-
+ ble_adv_params->adv_int_max,
+ ble_adv_params->adv_type,
+ ble_adv_params->own_addr_type,
+ ble_adv_params->channel_map,
+ ble_adv_params->adv_filter_policy,
+ &peer_addr);
+
-
+ /*set connectable,discoverable, pairable and paired only modes of local device*/
+ BTA_DmSetVisibility(disc_mode, conn_mode, (UINT8)BTA_DM_NON_PAIRABLE, (UINT8)BTA_DM_CONN_ALL);
}
--- /dev/null
--- /dev/null
++#
++# This is a project Makefile. It is assumed the directory this Makefile resides in is a
++# project subdirectory.
++#
++
++PROJECT_NAME := bluedroid_demos
++
++COMPONENT_ADD_INCLUDEDIRS := components/include
++
++include $(IDF_PATH)/make/project.mk
++
--- /dev/null
--- /dev/null
++#
++# Main Makefile. This is basically the same as a component makefile.
++#
++# This Makefile should, at the very least, just include $(SDK_PATH)/make/component_common.mk. By default,
++# this will take the sources in the src/ directory, compile them and link them into
++# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable,
++# please read the ESP-IDF documents if you need to do this.
++#
++
++include $(IDF_PATH)/make/component_common.mk