adding Adafruit Neo Pixel service
This commit is contained in:
1 parent
205587c30a
commit
bf4ac6ba71
4 files changed
+156
-6
No files matched your search
@@ -61,6 +61,7 @@
|
||||
#include "services/EddyStone.h"
|
||||
|
||||
#include "services/BLEAdafruitTemperature.h"
|
||||
#include "services/BLEAdafruitNeopixel.h"
|
||||
|
||||
#include "clients/BLEAncs.h"
|
||||
#include "clients/BLEClientUart.h"
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Ha Thach (tinyusb.org) for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "bluefruit.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
|
||||
//------------- IMPLEMENTATION -------------//
|
||||
/* Adafruit NeoPixel Service
|
||||
* - Service: ADAF-0002-C332-42A8-93BD-25E905756CB8
|
||||
* - Count : ADAF-0003-C332-42A8-93BD-25E905756CB8
|
||||
* - Type : ADAF-0004-C332-42A8-93BD-25E905756CB8
|
||||
* - Data : ADAF-0005-C332-42A8-93BD-25E905756CB8
|
||||
*/
|
||||
|
||||
const uint8_t BLEAdafruitNeopixel::UUID128_SERVICE[16] =
|
||||
{
|
||||
0xB8, 0x6c, 0x75, 0x05, 0xE9, 0x25, 0xBD, 0x93,
|
||||
0xA8, 0x42, 0x32, 0xC3, 0x02, 0x00, 0xAF, 0xAD
|
||||
};
|
||||
|
||||
const uint8_t BLEAdafruitNeopixel::UUID128_CHR_COUNT[16] =
|
||||
{
|
||||
0xB8, 0x6c, 0x75, 0x05, 0xE9, 0x25, 0xBD, 0x93,
|
||||
0xA8, 0x42, 0x32, 0xC3, 0x03, 0x00, 0xAF, 0xAD
|
||||
};
|
||||
|
||||
const uint8_t BLEAdafruitNeopixel::UUID128_CHR_TYPE[16] =
|
||||
{
|
||||
0xB8, 0x6c, 0x75, 0x05, 0xE9, 0x25, 0xBD, 0x93,
|
||||
0xA8, 0x42, 0x32, 0xC3, 0x04, 0x00, 0xAF, 0xAD
|
||||
};
|
||||
|
||||
const uint8_t BLEAdafruitNeopixel::UUID128_CHR_DATA[16] =
|
||||
{
|
||||
0xB8, 0x6c, 0x75, 0x05, 0xE9, 0x25, 0xBD, 0x93,
|
||||
0xA8, 0x42, 0x32, 0xC3, 0x05, 0x00, 0xAF, 0xAD
|
||||
};
|
||||
|
||||
// Constructor
|
||||
BLEAdafruitNeopixel::BLEAdafruitNeopixel(void)
|
||||
: BLEService(UUID128_SERVICE), Count(UUID128_CHR_COUNT), Type(UUID128_CHR_TYPE), Data(UUID128_CHR_DATA)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
err_t BLEAdafruitNeopixel::begin (void)
|
||||
{
|
||||
// Invoke base class begin()
|
||||
VERIFY_STATUS( BLEService::begin() );
|
||||
|
||||
// Add Characteristic
|
||||
Count.setProperties(CHR_PROPS_READ | CHR_PROPS_WRITE);
|
||||
Count.setPermission(SECMODE_OPEN, SECMODE_OPEN);
|
||||
Count.setFixedLen(2);
|
||||
Count.setUserDescriptor("Count");
|
||||
VERIFY_STATUS( Count.begin() );
|
||||
Count.write16(0);
|
||||
|
||||
// Add Characteristic
|
||||
Type.setProperties(CHR_PROPS_READ | CHR_PROPS_WRITE);
|
||||
Type.setPermission(SECMODE_OPEN, SECMODE_OPEN);
|
||||
Type.setFixedLen(2);
|
||||
Type.setUserDescriptor("Type");
|
||||
VERIFY_STATUS( Type.begin() );
|
||||
Type.write16(0);
|
||||
|
||||
// Add Characteristic
|
||||
Data.setProperties(CHR_PROPS_WRITE);
|
||||
Data.setPermission(SECMODE_NO_ACCESS, SECMODE_OPEN);
|
||||
Data.setMaxLen(Bluefruit.getMaxMtu(BLE_GAP_ROLE_PERIPH));
|
||||
Data.setUserDescriptor("Data");
|
||||
VERIFY_STATUS( Data.begin() );
|
||||
|
||||
return ERROR_NONE;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Ha Thach (tinyusb.org) for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef BLEADAFRUITNEOPIXEL_H_
|
||||
#define BLEADAFRUITNEOPIXEL_H_
|
||||
|
||||
#include "bluefruit_common.h"
|
||||
|
||||
#include "BLECharacteristic.h"
|
||||
#include "BLEService.h"
|
||||
|
||||
class BLEAdafruitNeopixel : public BLEService
|
||||
{
|
||||
public:
|
||||
static const uint8_t UUID128_SERVICE[16];
|
||||
static const uint8_t UUID128_CHR_COUNT[16];
|
||||
static const uint8_t UUID128_CHR_TYPE[16];
|
||||
static const uint8_t UUID128_CHR_DATA[16];
|
||||
|
||||
BLECharacteristic Count;
|
||||
BLECharacteristic Type;
|
||||
BLECharacteristic Data;
|
||||
|
||||
BLEAdafruitNeopixel(void);
|
||||
virtual err_t begin(void);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* BLEADAFRUITNEOPIXEL_H_ */
|
||||
@@ -24,16 +24,14 @@
|
||||
|
||||
#include "bluefruit.h"
|
||||
|
||||
#include "BLEAdafruitTemperature.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
/* Adafruit Temperature Service
|
||||
* - Service: 20E6-0001-C332-42A8-93BD-25E905756CB8
|
||||
* - Temperature Celsius : 0x2A6E
|
||||
* - Measurement Interval : 0x2A21
|
||||
* - Service: ADAF-0001-C332-42A8-93BD-25E905756CB8
|
||||
* - Temperature Celsius : 0x2A6E
|
||||
* - Measurement Interval : 0x2A21
|
||||
*
|
||||
* https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.temperature.xml
|
||||
* https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.measurement_interval.xml
|
||||
@@ -42,7 +40,7 @@
|
||||
const uint8_t BLEAdafruitTemperature::UUID128_SERVICE[16] =
|
||||
{
|
||||
0xB8, 0x6c, 0x75, 0x05, 0xE9, 0x25, 0xBD, 0x93,
|
||||
0xA8, 0x42, 0x32, 0xC3, 0x01, 0x00, 0xE6, 0x20
|
||||
0xA8, 0x42, 0x32, 0xC3, 0x01, 0x00, 0xAF, 0xAD
|
||||
};
|
||||
|
||||
// Constructor
|
||||
|
||||
Reference in new issue
Block a user