Skip to content

Commit 205587c

Browse files
committed
ading Adafruit Temperature Service
1 parent 0bcf55c commit 205587c

File tree

4 files changed

+155
-13
lines changed

4 files changed

+155
-13
lines changed

libraries/Bluefruit52Lib/src/BLEUuid.h

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,20 @@ class BLEUuid
101101
#define UUID16_SVC_BMS 0x181E
102102
#define UUID16_SVC_CGM 0x181F
103103
#define UUID16_SVC_PLX 0x1822
104+
#define UUID16_SVC_OTS 0x1825
104105

105106
#define UUID16_SVC_EDDYSTONE 0xFEAA
106107

108+
//
109+
#define UUID16_EXTERNAL_REPORT_REF_DESCR 0x2907
110+
#define UUID16_REPORT_REF_DESCR 0x2908
111+
107112
/*------------------------------------------------------------------*/
108113
/* Characteristic UUID
109114
* https://www.bluetooth.com/specifications/gatt/characteristics
110115
*------------------------------------------------------------------*/
116+
#define UUID16_CHR_TEMPERATURE_CELSIUS 0x2A1F
117+
#define UUID16_CHR_TEMPERATURE_FAHRENHEIT 0x2A20
111118
#define UUID16_CHR_REMOVABLE 0x2A3A
112119
#define UUID16_CHR_SERVICE_REQUIRED 0x2A3B
113120
#define UUID16_CHR_ALERT_CATEGORY_ID 0x2A43
@@ -178,25 +185,36 @@ class BLEUuid
178185
#define UUID16_CHR_SC_CTRLPT 0x2A55
179186
#define UUID16_CHR_RSC_MEASUREMENT 0x2A53
180187
#define UUID16_CHR_SENSOR_LOCATION 0x2A5D
181-
#define UUID16_EXTERNAL_REPORT_REF_DESCR 0x2907
182-
#define UUID16_REPORT_REF_DESCR 0x2908
183188
#define UUID16_CHR_LN_FEATURE 0x2A6A
184189
#define UUID16_CHR_LN_POSITION_QUALITY 0x2A69
185190
#define UUID16_CHR_LN_LOCATION_AND_SPEED 0x2A67
186191
#define UUID16_CHR_LN_NAVIGATION 0x2A68
187192
#define UUID16_CHR_LN_CONTROL_POINT 0x2A6B
188-
#define UUID16_BMS_CTRLPT 0x2AA4
189-
#define UUID16_BMS_FEATURE 0x2AA5
190-
#define UUID16_CGM_MEASUREMENT 0x2AA7
191-
#define UUID16_CGM_FEATURE 0x2AA8
192-
#define UUID16_CGM_STATUS 0x2AA9
193-
#define UUID16_CGM_SESSION_START_TIME 0x2AAA
194-
#define UUID16_CGM_SESSION_RUN_TIME 0x2AAB
195-
#define UUID16_CGM_SPECIFIC_OPS_CTRLPT 0x2AAC
196-
#define UUID16_PLX_SPOT_CHECK_MEAS 0x2A5E
197-
#define UUID16_PLX_CONTINUOUS_MEAS 0x2A5F
198-
#define UUID16_PLX_FEATURES 0x2A60
193+
#define UUID16_CHR_BMS_CTRLPT 0x2AA4
194+
#define UUID16_CHR_BMS_FEATURE 0x2AA5
195+
#define UUID16_CHR_CGM_MEASUREMENT 0x2AA7
196+
#define UUID16_CHR_CGM_FEATURE 0x2AA8
197+
#define UUID16_CHR_CGM_STATUS 0x2AA9
198+
#define UUID16_CHR_CGM_SESSION_START_TIME 0x2AAA
199+
#define UUID16_CHR_CGM_SESSION_RUN_TIME 0x2AAB
200+
#define UUID16_CHR_CGM_SPECIFIC_OPS_CTRLPT 0x2AAC
201+
#define UUID16_CHR_PLX_SPOT_CHECK_MEAS 0x2A5E
202+
#define UUID16_CHR_PLX_CONTINUOUS_MEAS 0x2A5F
203+
#define UUID16_CHR_PLX_FEATURES 0x2A60
204+
#define UUID16_CHR_TEMPERATURE 0x2A6E
199205
#define UUID16_CHR_UV_INDEX 0x2A76
206+
#define UUID16_CHR_OTS_FEATURES 0x2ABD
207+
#define UUID16_CHR_OTS_OBJECT_NAME 0x2ABE
208+
#define UUID16_CHR_OTS_OBJECT_TYPE 0x2ABF
209+
#define UUID16_CHR_OTS_OBJECT_SIZE 0x2AC0
210+
#define UUID16_CHR_OTS_OBJECT_FIRST_CREATED 0x2AC1
211+
#define UUID16_CHR_OTS_OBJECT_LAST_MODIFIED 0x2AC2
212+
#define UUID16_CHR_OTS_OBJECT_ID 0x2AC3
213+
#define UUID16_CHR_OTS_OBJECT_PROPERTIES 0x2AC4
214+
#define UUID16_CHR_OTS_OACP 0x2AC5
215+
#define UUID16_CHR_OTS_OLCP 0x2AC6
216+
#define UUID16_CHR_OTS_LF 0x2AC7
217+
#define UUID16_CHR_OTS_OBJECT_CHANGED 0x2AC8
200218

201219
/*------------------------------------------------------------------*/
202220
/* Company UUID

libraries/Bluefruit52Lib/src/bluefruit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
#include "services/BLEMidi.h"
6161
#include "services/EddyStone.h"
6262

63+
#include "services/BLEAdafruitTemperature.h"
64+
6365
#include "clients/BLEAncs.h"
6466
#include "clients/BLEClientUart.h"
6567
#include "clients/BLEClientDis.h"
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2019 Ha Thach (tinyusb.org) for Adafruit Industries
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
#include "bluefruit.h"
26+
27+
#include "BLEAdafruitTemperature.h"
28+
29+
//--------------------------------------------------------------------+
30+
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
31+
//--------------------------------------------------------------------+
32+
33+
/* Adafruit Temperature Service
34+
* - Service: 20E6-0001-C332-42A8-93BD-25E905756CB8
35+
* - Temperature Celsius : 0x2A6E
36+
* - Measurement Interval : 0x2A21
37+
*
38+
* https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.temperature.xml
39+
* https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.measurement_interval.xml
40+
*/
41+
42+
const uint8_t BLEAdafruitTemperature::UUID128_SERVICE[16] =
43+
{
44+
0xB8, 0x6c, 0x75, 0x05, 0xE9, 0x25, 0xBD, 0x93,
45+
0xA8, 0x42, 0x32, 0xC3, 0x01, 0x00, 0xE6, 0x20
46+
};
47+
48+
// Constructor
49+
BLEAdafruitTemperature::BLEAdafruitTemperature(void)
50+
: BLEService(UUID128_SERVICE), Temperature(UUID16_CHR_TEMPERATURE), MeasurementInterval(UUID16_CHR_MEASUREMENT_INTERVAL)
51+
{
52+
53+
}
54+
55+
err_t BLEAdafruitTemperature::begin (void)
56+
{
57+
// Invoke base class begin()
58+
VERIFY_STATUS( BLEService::begin() );
59+
60+
// Add Temperature Characteristic
61+
Temperature.setProperties(CHR_PROPS_READ | CHR_PROPS_NOTIFY);
62+
Temperature.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS);
63+
Temperature.setFixedLen(2);
64+
Temperature.setUserDescriptor("Temperature");
65+
VERIFY_STATUS( Temperature.begin() );
66+
67+
// Add Measurement Interval Characteristic
68+
MeasurementInterval.setProperties(CHR_PROPS_READ | CHR_PROPS_WRITE);
69+
MeasurementInterval.setPermission(SECMODE_OPEN, SECMODE_OPEN);
70+
MeasurementInterval.setFixedLen(2);
71+
MeasurementInterval.setUserDescriptor("Measurement Interval");
72+
VERIFY_STATUS( MeasurementInterval.begin() );
73+
74+
MeasurementInterval.write16(30); // measure every 30 seconds
75+
76+
return ERROR_NONE;
77+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2019 Ha Thach (tinyusb.org) for Adafruit Industries
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
#ifndef BLEADAFRUITTEMPERATURE_H_
26+
#define BLEADAFRUITTEMPERATURE_H_
27+
28+
#include "bluefruit_common.h"
29+
30+
#include "BLECharacteristic.h"
31+
#include "BLEService.h"
32+
33+
class BLEAdafruitTemperature : public BLEService
34+
{
35+
public:
36+
static const uint8_t UUID128_SERVICE[16];
37+
38+
BLECharacteristic Temperature;
39+
BLECharacteristic MeasurementInterval;
40+
41+
BLEAdafruitTemperature();
42+
virtual err_t begin(void);
43+
};
44+
45+
#endif /* BLEADAFRUITTEMPERATURE_H_ */

0 commit comments

Comments
 (0)