esp_gap_bt_api.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #include "bt_target.h"
  14. #include <string.h>
  15. #include "esp_bt_main.h"
  16. #include "esp_gap_bt_api.h"
  17. #include "bt_trace.h"
  18. #include "btc_manage.h"
  19. #include "btc_gap_bt.h"
  20. #if BTC_GAP_BT_INCLUDED
  21. esp_err_t esp_bt_gap_set_scan_mode(esp_bt_scan_mode_t mode)
  22. {
  23. btc_msg_t msg;
  24. btc_gap_bt_args_t arg;
  25. if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
  26. return ESP_ERR_INVALID_STATE;
  27. }
  28. msg.sig = BTC_SIG_API_CALL;
  29. msg.pid = BTC_PID_GAP_BT;
  30. msg.act = BTC_GAP_BT_ACT_SET_SCAN_MODE;
  31. arg.set_scan_mode.mode = mode;
  32. return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
  33. }
  34. #endif /* #if BTC_GAP_BT_INCLUDED */