Skip to content

Commit b41281f

Browse files
committed
added missing device infomations
1 parent bcf9e64 commit b41281f

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

main/blehr_sens.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ extern "C" {
3434
#define GATT_DEVICE_INFO_UUID 0x180A
3535
#define GATT_MANUFACTURER_NAME_UUID 0x2A29
3636
#define GATT_MODEL_NUMBER_UUID 0x2A24
37+
#define GATT_FIRMWARE_REVISION_UUID 0x2A26
38+
#define GATT_SOFTWARE_REVISION_UUID 0x2A28
3739
#define GATT_BATTERYS_UUID 0x180f
3840
#define GATT_BATTERY_LEVEL_UUID 0x2a19
3941

main/gatt_svr.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
static const char *manuf_name = "Apache Mynewt ESP32 devkitC";
3030
static const char *model_num = "Mynewt HR Sensor demo";
31+
static const char *firmware_rev = "2.0";
32+
static const char *software_rev = "4.8";
3133
uint16_t hrs_hrm_handle;
3234

3335
static int
@@ -67,7 +69,7 @@ static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
6769
.uuid = BLE_UUID16_DECLARE(GATT_DEVICE_INFO_UUID),
6870
.characteristics = (struct ble_gatt_chr_def[])
6971
{ {
70-
/* Characteristic: * Manufacturer name */
72+
/* Characteristic: Manufacturer name */
7173
.uuid = BLE_UUID16_DECLARE(GATT_MANUFACTURER_NAME_UUID),
7274
.access_cb = gatt_svr_chr_access_device_info,
7375
.flags = BLE_GATT_CHR_F_READ,
@@ -76,6 +78,16 @@ static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
7678
.uuid = BLE_UUID16_DECLARE(GATT_MODEL_NUMBER_UUID),
7779
.access_cb = gatt_svr_chr_access_device_info,
7880
.flags = BLE_GATT_CHR_F_READ,
81+
}, {
82+
/* Characteristic: Firmware Revision string */
83+
.uuid = BLE_UUID16_DECLARE(GATT_FIRMWARE_REVISION_UUID),
84+
.access_cb = gatt_svr_chr_access_device_info,
85+
.flags = BLE_GATT_CHR_F_READ,
86+
}, {
87+
/* Characteristic: Software Revision string */
88+
.uuid = BLE_UUID16_DECLARE(GATT_SOFTWARE_REVISION_UUID),
89+
.access_cb = gatt_svr_chr_access_device_info,
90+
.flags = BLE_GATT_CHR_F_READ,
7991
}, {
8092
0, /* No more characteristics in this service */
8193
},
@@ -143,6 +155,16 @@ gatt_svr_chr_access_device_info(uint16_t conn_handle, uint16_t attr_handle,
143155
return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
144156
}
145157

158+
if (uuid == GATT_FIRMWARE_REVISION_UUID) {
159+
rc = os_mbuf_append(ctxt->om, firmware_rev, strlen(firmware_rev));
160+
return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
161+
}
162+
163+
if (uuid == GATT_SOFTWARE_REVISION_UUID) {
164+
rc = os_mbuf_append(ctxt->om, software_rev, strlen(software_rev));
165+
return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
166+
}
167+
146168
if (uuid == GATT_BATTERY_LEVEL_UUID) {
147169
int percentage = 99;
148170
rc = os_mbuf_append(ctxt->om, &percentage, sizeof(percentage));

0 commit comments

Comments
 (0)