From 8b85dcfb9cba61c0c2bfb9aeb4087f9195b0787b Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 29 Mar 2017 18:04:44 +0700 Subject: [PATCH] adding ancs --- changelog.md | 2 +- libraries/Bluefruit52Lib/src/bluefruit.h | 1 + .../Bluefruit52Lib/src/services/BLEAncs.cpp | 89 +++++++++++++++++++ .../Bluefruit52Lib/src/services/BLEAncs.h | 67 ++++++++++++++ 4 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 libraries/Bluefruit52Lib/src/services/BLEAncs.cpp create mode 100644 libraries/Bluefruit52Lib/src/services/BLEAncs.h diff --git a/changelog.md b/changelog.md index 6e8c5539..d6928645 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,6 @@ ## 0.5.5 (WIP) -- Start to add central support +- Initial Central API() - Add HardwarePWM class to support up to 12 channels ## 0.5.1 diff --git a/libraries/Bluefruit52Lib/src/bluefruit.h b/libraries/Bluefruit52Lib/src/bluefruit.h index 5748867c..d44dd2df 100644 --- a/libraries/Bluefruit52Lib/src/bluefruit.h +++ b/libraries/Bluefruit52Lib/src/bluefruit.h @@ -55,6 +55,7 @@ #include "services/BLEHidGeneric.h" #include "services/BLEHidAdafruit.h" #include "services/BLEMidi.h" +#include "services/BLEAncs.h" #include "central_services/BLECentralUart.h" diff --git a/libraries/Bluefruit52Lib/src/services/BLEAncs.cpp b/libraries/Bluefruit52Lib/src/services/BLEAncs.cpp new file mode 100644 index 00000000..7c6c8c77 --- /dev/null +++ b/libraries/Bluefruit52Lib/src/services/BLEAncs.cpp @@ -0,0 +1,89 @@ +/**************************************************************************/ +/*! + @file BLEAncs.cpp + @author hathach + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2017, Adafruit Industries (adafruit.com) + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/**************************************************************************/ + +#include "bluefruit.h" + +/* ANCS Service : 7905F431-B5CE-4E99-A40F-4B1E122D00D0 + * Notification Source : 9FBF120D-6301-42D9-8C58-25E699A21DBD + * Control Point : 69D1D8F3-45E1-49A8-9821-9BBDFDAAD9D9 + * Data Source : 22EAC6E9-24D6-4BB5-BE44-B36ACE7C7BFB + */ + +const uint8_t BLEANCS_UUID_SERVICE[] = +{ + 0xD0, 0x00, 0x2D, 0x12, 0x1E, 0x4B, 0x0F, 0xA4, + 0x99, 0x4E, 0xCE, 0xB5, 0x31, 0xF4, 0x05, 0x79 +}; + +const uint8_t BLEANCS_UUID_CHR_NOTIFICATION[] +{ + 0xBD, 0x1D, 0xA2, 0x99, 0xE6, 0x25, 0x58, 0x8C, + 0xD9, 0x42, 0x01, 0x63, 0x0D, 0x12, 0xBF, 0x9F +}; + +const uint8_t BLEANCS_UUID_CHR_CONTROL[] = +{ + 0xD9, 0xD9, 0xAA, 0xFD, 0xBD, 0x9B, 0x21, 0x98, + 0xA8, 0x49, 0xE1, 0x45, 0xF3, 0xD8, 0xD1, 0x69 +}; + +const uint8_t BLEANCS_UUID_CHR_DATA[] = +{ + 0xFB, 0x7B, 0x7C, 0xCE, 0x6A, 0xB3, 0x44, 0xBE, + 0xB5, 0x4B, 0xD6, 0x24, 0xE9, 0xC6, 0xEA, 0x22 +}; + +BLEAncs::BLEAncs(void) + : BLECentralService(BLEANCS_UUID_SERVICE), _notification(BLEANCS_UUID_CHR_NOTIFICATION), + _control(BLEANCS_UUID_CHR_CONTROL), _data(BLEANCS_UUID_CHR_DATA) +{ + +} + +bool BLEAncs::begin(void) +{ + +} + +bool BLEAncs::discover(void) +{ + +} + +void BLEAncs::disconnect(void) +{ + +} diff --git a/libraries/Bluefruit52Lib/src/services/BLEAncs.h b/libraries/Bluefruit52Lib/src/services/BLEAncs.h new file mode 100644 index 00000000..6d3a4d4b --- /dev/null +++ b/libraries/Bluefruit52Lib/src/services/BLEAncs.h @@ -0,0 +1,67 @@ +/**************************************************************************/ +/*! + @file BLEAncs.h + @author hathach + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2017, Adafruit Industries (adafruit.com) + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/**************************************************************************/ +#ifndef BLEANCS_H_ +#define BLEANCS_H_ + +#include "bluefruit_common.h" + +//#include "BLECentralCharacteristic.h" +//#include "BLECentralService.h" + +extern const uint8_t BLEANCS_UUID_SERVICE[]; +extern const uint8_t BLEANCS_UUID_CHR_NOTIFICATION[]; +extern const uint8_t BLEANCS_UUID_CHR_CONTROL[]; +extern const uint8_t BLEANCS_UUID_CHR_DATA[]; + +class BLEAncs : public BLECentralService +{ + public: + BLEAncs(void); + + virtual bool begin(void); + virtual bool discover(void); + + protected: + virtual void disconnect(void); + + private: + BLECentralCharacteristic _notification; + BLECentralCharacteristic _control; + BLECentralCharacteristic _data; +}; + + +#endif /* BLEANCS_H_ */