S&B Volcano vaporizer remote control with Pi Pico W
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ble.h 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_SCAN_RESULTS 32
  23. #define BLE_MAX_VALUE_LEN 64
  24. enum ble_scan_mode {
  25. BLE_SCAN_OFF = 0,
  26. BLE_SCAN_ON = 1,
  27. BLE_SCAN_TOGGLE = 2,
  28. };
  29. struct ble_scan_result {
  30. bool set;
  31. uint32_t time;
  32. bd_addr_t addr;
  33. bd_addr_type_t type;
  34. int8_t rssi;
  35. char name[BLE_MAX_NAME_LENGTH + 1];
  36. };
  37. void ble_init(void);
  38. bool ble_is_ready(void);
  39. void ble_scan(enum ble_scan_mode mode);
  40. int32_t ble_get_scan_results(struct ble_scan_result *buf, uint16_t len);
  41. void ble_connect(bd_addr_t addr, bd_addr_type_t type);
  42. bool ble_is_connected(void);
  43. void ble_disconnect(void);
  44. int32_t ble_read(const uint8_t *characteristic, uint8_t *buff, uint16_t buff_len);
  45. int8_t ble_write(const uint8_t *service, const uint8_t *characteristic,
  46. uint8_t *buff, uint16_t buff_len);
  47. #endif // __BLE_H__