ading Adafruit Temperature Service

This commit is contained in:
hathach committed 2019-11-06 10:00:59 +07:00
1 parent 0bcf55cc44
commit 205587c30a
4 files changed
+155 -13

No files matched your search

+31 -13
View File
@@ -101,13 +101,20 @@ class BLEUuid
#define UUID16_SVC_BMS 0x181E
#define UUID16_SVC_CGM 0x181F
#define UUID16_SVC_PLX 0x1822
#define UUID16_SVC_OTS 0x1825
#define UUID16_SVC_EDDYSTONE 0xFEAA
//
#define UUID16_EXTERNAL_REPORT_REF_DESCR 0x2907
#define UUID16_REPORT_REF_DESCR 0x2908
/*------------------------------------------------------------------*/
/* Characteristic UUID
* https://www.bluetooth.com/specifications/gatt/characteristics
*------------------------------------------------------------------*/
#define UUID16_CHR_TEMPERATURE_CELSIUS 0x2A1F
#define UUID16_CHR_TEMPERATURE_FAHRENHEIT 0x2A20
#define UUID16_CHR_REMOVABLE 0x2A3A
#define UUID16_CHR_SERVICE_REQUIRED 0x2A3B
#define UUID16_CHR_ALERT_CATEGORY_ID 0x2A43
@@ -178,25 +185,36 @@ class BLEUuid
#define UUID16_CHR_SC_CTRLPT 0x2A55
#define UUID16_CHR_RSC_MEASUREMENT 0x2A53
#define UUID16_CHR_SENSOR_LOCATION 0x2A5D
#define UUID16_EXTERNAL_REPORT_REF_DESCR 0x2907
#define UUID16_REPORT_REF_DESCR 0x2908
#define UUID16_CHR_LN_FEATURE 0x2A6A
#define UUID16_CHR_LN_POSITION_QUALITY 0x2A69
#define UUID16_CHR_LN_LOCATION_AND_SPEED 0x2A67
#define UUID16_CHR_LN_NAVIGATION 0x2A68
#define UUID16_CHR_LN_CONTROL_POINT 0x2A6B
#define UUID16_BMS_CTRLPT 0x2AA4
#define UUID16_BMS_FEATURE 0x2AA5
#define UUID16_CGM_MEASUREMENT 0x2AA7
#define UUID16_CGM_FEATURE 0x2AA8
#define UUID16_CGM_STATUS 0x2AA9
#define UUID16_CGM_SESSION_START_TIME 0x2AAA
#define UUID16_CGM_SESSION_RUN_TIME 0x2AAB
#define UUID16_CGM_SPECIFIC_OPS_CTRLPT 0x2AAC
#define UUID16_PLX_SPOT_CHECK_MEAS 0x2A5E
#define UUID16_PLX_CONTINUOUS_MEAS 0x2A5F
#define UUID16_PLX_FEATURES 0x2A60
#define UUID16_CHR_BMS_CTRLPT 0x2AA4
#define UUID16_CHR_BMS_FEATURE 0x2AA5
#define UUID16_CHR_CGM_MEASUREMENT 0x2AA7
#define UUID16_CHR_CGM_FEATURE 0x2AA8
#define UUID16_CHR_CGM_STATUS 0x2AA9
#define UUID16_CHR_CGM_SESSION_START_TIME 0x2AAA
#define UUID16_CHR_CGM_SESSION_RUN_TIME 0x2AAB
#define UUID16_CHR_CGM_SPECIFIC_OPS_CTRLPT 0x2AAC
#define UUID16_CHR_PLX_SPOT_CHECK_MEAS 0x2A5E
#define UUID16_CHR_PLX_CONTINUOUS_MEAS 0x2A5F
#define UUID16_CHR_PLX_FEATURES 0x2A60
#define UUID16_CHR_TEMPERATURE 0x2A6E
#define UUID16_CHR_UV_INDEX 0x2A76
#define UUID16_CHR_OTS_FEATURES 0x2ABD
#define UUID16_CHR_OTS_OBJECT_NAME 0x2ABE
#define UUID16_CHR_OTS_OBJECT_TYPE 0x2ABF
#define UUID16_CHR_OTS_OBJECT_SIZE 0x2AC0
#define UUID16_CHR_OTS_OBJECT_FIRST_CREATED 0x2AC1
#define UUID16_CHR_OTS_OBJECT_LAST_MODIFIED 0x2AC2
#define UUID16_CHR_OTS_OBJECT_ID 0x2AC3
#define UUID16_CHR_OTS_OBJECT_PROPERTIES 0x2AC4
#define UUID16_CHR_OTS_OACP 0x2AC5
#define UUID16_CHR_OTS_OLCP 0x2AC6
#define UUID16_CHR_OTS_LF 0x2AC7
#define UUID16_CHR_OTS_OBJECT_CHANGED 0x2AC8
/*------------------------------------------------------------------*/
/* Company UUID
+2
View File
@@ -60,6 +60,8 @@
#include "services/BLEMidi.h"
#include "services/EddyStone.h"
#include "services/BLEAdafruitTemperature.h"
#include "clients/BLEAncs.h"
#include "clients/BLEClientUart.h"
#include "clients/BLEClientDis.h"
@@ -0,0 +1,77 @@
/*
* 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"
#include "BLEAdafruitTemperature.h"
//--------------------------------------------------------------------+
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
//--------------------------------------------------------------------+
/* Adafruit Temperature Service
* - Service: 20E6-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
*/
const uint8_t BLEAdafruitTemperature::UUID128_SERVICE[16] =
{
0xB8, 0x6c, 0x75, 0x05, 0xE9, 0x25, 0xBD, 0x93,
0xA8, 0x42, 0x32, 0xC3, 0x01, 0x00, 0xE6, 0x20
};
// Constructor
BLEAdafruitTemperature::BLEAdafruitTemperature(void)
: BLEService(UUID128_SERVICE), Temperature(UUID16_CHR_TEMPERATURE), MeasurementInterval(UUID16_CHR_MEASUREMENT_INTERVAL)
{
}
err_t BLEAdafruitTemperature::begin (void)
{
// Invoke base class begin()
VERIFY_STATUS( BLEService::begin() );
// Add Temperature Characteristic
Temperature.setProperties(CHR_PROPS_READ | CHR_PROPS_NOTIFY);
Temperature.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS);
Temperature.setFixedLen(2);
Temperature.setUserDescriptor("Temperature");
VERIFY_STATUS( Temperature.begin() );
// Add Measurement Interval Characteristic
MeasurementInterval.setProperties(CHR_PROPS_READ | CHR_PROPS_WRITE);
MeasurementInterval.setPermission(SECMODE_OPEN, SECMODE_OPEN);
MeasurementInterval.setFixedLen(2);
MeasurementInterval.setUserDescriptor("Measurement Interval");
VERIFY_STATUS( MeasurementInterval.begin() );
MeasurementInterval.write16(30); // measure every 30 seconds
return ERROR_NONE;
}
@@ -0,0 +1,45 @@
/*
* 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 BLEADAFRUITTEMPERATURE_H_
#define BLEADAFRUITTEMPERATURE_H_
#include "bluefruit_common.h"
#include "BLECharacteristic.h"
#include "BLEService.h"
class BLEAdafruitTemperature : public BLEService
{
public:
static const uint8_t UUID128_SERVICE[16];
BLECharacteristic Temperature;
BLECharacteristic MeasurementInterval;
BLEAdafruitTemperature();
virtual err_t begin(void);
};
#endif /* BLEADAFRUITTEMPERATURE_H_ */