PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
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.

87 line
2.2KB

  1. /*********************************************************************
  2. This is a library for our nRF8001 Bluetooth Low Energy Breakout
  3. Pick one up today in the adafruit shop!
  4. ------> http://www.adafruit.com/products/1697
  5. These displays use SPI to communicate, 4 or 5 pins are required to
  6. interface
  7. Adafruit invests time and resources providing this open source code,
  8. please support Adafruit and open-source hardware by purchasing
  9. products from Adafruit!
  10. Written by Kevin Townsend/KTOWN for Adafruit Industries.
  11. MIT license, check LICENSE for more information
  12. All text above, and the splash screen below must be included in any redistribution
  13. *********************************************************************/
  14. #if ARDUINO >= 100
  15. #include "Arduino.h"
  16. #else
  17. #include "WProgram.h"
  18. #endif
  19. #ifndef _ADAFRUIT_BLE_UART_H_
  20. #define _ADAFRUIT_BLE_UART_H_
  21. #include "utility/aci_evts.h"
  22. #define BLE_RW_DEBUG
  23. extern "C"
  24. {
  25. /* Callback prototypes */
  26. typedef void (*aci_callback)(aci_evt_opcode_t event);
  27. typedef void (*rx_callback) (uint8_t *buffer, uint8_t len);
  28. }
  29. class Adafruit_BLE_UART : public Stream
  30. {
  31. public:
  32. Adafruit_BLE_UART (int8_t req, int8_t rdy, int8_t rst);
  33. bool begin ( uint16_t advTimeout = 0, uint16_t advInterval = 80 );
  34. void pollACI ( void );
  35. size_t write ( uint8_t * buffer, uint8_t len );
  36. size_t write ( uint8_t buffer);
  37. size_t println(const char * thestr);
  38. size_t print(const char * thestr);
  39. size_t print(String thestr);
  40. size_t print(int theint);
  41. size_t print(const __FlashStringHelper *ifsh);
  42. void setACIcallback(aci_callback aciEvent = NULL);
  43. void setRXcallback(rx_callback rxEvent = NULL);
  44. void setDeviceName(const char * deviceName);
  45. // Stream compatibility
  46. int available(void);
  47. int read(void);
  48. int peek(void);
  49. void flush(void);
  50. aci_evt_opcode_t getState(void);
  51. private:
  52. void defaultACICallback(aci_evt_opcode_t event);
  53. void defaultRX(uint8_t *buffer, uint8_t len);
  54. // callbacks you can set with setCallback function for user extension
  55. aci_callback aci_event;
  56. rx_callback rx_event;
  57. bool debugMode;
  58. uint16_t adv_timeout;
  59. uint16_t adv_interval;
  60. char device_name[8];
  61. aci_evt_opcode_t currentStatus;
  62. // pins usd
  63. int8_t _REQ, _RDY, _RST;
  64. };
  65. #endif