2016-11-04 18:48:16 +00:00
|
|
|
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2016-11-15 12:56:15 +00:00
|
|
|
#include "esp_gap_bt_api.h"
|
2016-10-26 03:25:24 +00:00
|
|
|
#include "bta_api.h"
|
|
|
|
#include "bt_trace.h"
|
2016-12-26 09:26:54 +00:00
|
|
|
#include <string.h>
|
2016-10-26 03:25:24 +00:00
|
|
|
|
2016-10-31 13:40:01 +00:00
|
|
|
esp_err_t esp_bt_gap_set_scan_mode(bt_scan_mode_t mode)
|
2016-10-26 03:25:24 +00:00
|
|
|
{
|
|
|
|
tBTA_DM_DISC disc_mode;
|
|
|
|
tBTA_DM_CONN conn_mode;
|
|
|
|
|
2016-11-24 18:10:15 +00:00
|
|
|
switch (mode) {
|
2016-10-26 03:25:24 +00:00
|
|
|
case BT_SCAN_MODE_NONE:
|
|
|
|
disc_mode = BTA_DM_NON_DISC;
|
|
|
|
conn_mode = BTA_DM_NON_CONN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BT_SCAN_MODE_CONNECTABLE:
|
|
|
|
disc_mode = BTA_DM_NON_DISC;
|
|
|
|
conn_mode = BTA_DM_CONN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE:
|
|
|
|
disc_mode = BTA_DM_GENERAL_DISC;
|
|
|
|
conn_mode = BTA_DM_CONN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-10-31 13:40:01 +00:00
|
|
|
// BTIF_TRACE_ERROR("invalid scan mode (0x%x)", mode);
|
|
|
|
return ESP_ERR_INVALID_ARG;
|
2016-10-26 03:25:24 +00:00
|
|
|
}
|
|
|
|
|
2016-10-31 13:40:01 +00:00
|
|
|
// BTIF_TRACE_EVENT("set property scan mode : %x", mode);
|
2016-10-26 03:25:24 +00:00
|
|
|
BTA_DmSetVisibility(disc_mode, conn_mode, BTA_DM_IGNORE, BTA_DM_IGNORE);
|
2016-11-24 18:10:15 +00:00
|
|
|
|
2016-10-31 13:40:01 +00:00
|
|
|
return ESP_OK;
|
2016-10-26 03:25:24 +00:00
|
|
|
}
|
2016-12-26 09:26:54 +00:00
|
|
|
|
|
|
|
esp_err_t esp_bt_gap_set_device_name(const char *name)
|
|
|
|
{
|
|
|
|
if (name == NULL || *name == '\0') {
|
|
|
|
return ESP_ERR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
#define ESP_GAP_DEVICE_NAME_MAX (32)
|
|
|
|
char dev_name[ESP_GAP_DEVICE_NAME_MAX+1];
|
|
|
|
strncpy(dev_name, name, ESP_GAP_DEVICE_NAME_MAX);
|
|
|
|
dev_name[ESP_GAP_DEVICE_NAME_MAX] = '\0';
|
|
|
|
BTA_DmSetDeviceName(dev_name);
|
|
|
|
return ESP_OK;
|
|
|
|
}
|