S&B Volcano vaporizer remote control with Pi Pico W
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ble.h 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. int8_t ble_discover(const uint8_t *service, const uint8_t *characteristic);
  48. int32_t ble_read(const uint8_t *characteristic, uint8_t *buff, uint16_t buff_len);
  49. int8_t ble_write(const uint8_t *service, const uint8_t *characteristic,
  50. const uint8_t *buff, uint16_t buff_len);
  51. int8_t ble_notification_disable(const uint8_t *service, const uint8_t *characteristic);
  52. int8_t ble_notification_enable(const uint8_t *service, const uint8_t *characteristic);
  53. bool ble_notification_ready(void);
  54. uint16_t ble_notification_get(uint8_t *buff, uint16_t buff_len, uint8_t *characteristic);
  55. #endif // __BLE_H__