S&B Volcano vaporizer remote control with Pi Pico W
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * ble.h
  3. *
  4. * Copyright (c) 2023 Thomas Buck (thomas@xythobuz.de)
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * See <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef __BLE_H__
  19. #define __BLE_H__
  20. #include "btstack.h"
  21. #define BLE_MAX_NAME_LENGTH 32
  22. #define BLE_MAX_DATA_LENGTH 26
  23. #define BLE_MAX_SCAN_RESULTS 32
  24. #define BLE_MAX_VALUE_LEN 64
  25. enum ble_scan_mode {
  26. BLE_SCAN_OFF = 0,
  27. BLE_SCAN_ON = 1,
  28. BLE_SCAN_TOGGLE = 2,
  29. };
  30. struct ble_scan_result {
  31. bool set;
  32. uint32_t time;
  33. bd_addr_t addr;
  34. bd_addr_type_t type;
  35. int8_t rssi;
  36. char name[BLE_MAX_NAME_LENGTH + 1];
  37. uint8_t data[BLE_MAX_DATA_LENGTH];
  38. size_t data_len;
  39. };
  40. void ble_init(void);
  41. bool ble_is_ready(void);
  42. void ble_scan(enum ble_scan_mode mode);
  43. int32_t ble_get_scan_results(struct ble_scan_result *buf, uint16_t len);
  44. void ble_connect(bd_addr_t addr, bd_addr_type_t type);
  45. bool ble_is_connected(void);
  46. void ble_disconnect(void);
  47. int32_t ble_read(const uint8_t *characteristic, uint8_t *buff, uint16_t buff_len);
  48. int8_t ble_write(const uint8_t *service, const uint8_t *characteristic,
  49. uint8_t *buff, uint16_t buff_len);
  50. #endif // __BLE_H__