Skip to content

Commit fe78397

Browse files
committed
Correct presentation format descriptor handling
1 parent c1882ee commit fe78397

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

libraries/CurieBle/examples/AutomationIO/AutomationIO.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ struct AnalogPinConfig {
6363
* Note that input pins are only readable by the remote device, while output pins are
6464
* only writable. Different characteristic UUIDs are used for digital and analog pins */
6565
#define DIGITAL_INPUT_PINCONFIG(pin) \
66-
{ (pin), #pin, {CHAR_UUID_DIGITAL, BleRead | BleNotify}, {"2901", #pin}, {"2904", (uint8_t[]){0x2, 0, 0x27, 0x00, 0x1, pin + 1}, 7}, {DESC_UUID_NUMDIGITALS, (uint8_t[]){1}, sizeof(uint8_t)} }
66+
{ (pin), #pin, {CHAR_UUID_DIGITAL, BleRead | BleNotify}, {"2901", #pin}, {"2904", (uint8_t[]){0x02, 0x00, 0x00, 0x027, 0x1, pin + 1, 00}, 7}, {DESC_UUID_NUMDIGITALS, (uint8_t[]){1}, sizeof(uint8_t)} }
6767
#define DIGITAL_OUTPUT_PINCONFIG(pin) \
68-
{ (pin), #pin, {CHAR_UUID_DIGITAL, BleWriteWithoutResponse | BleWrite}, {"2901", #pin}, {"2904", (uint8_t[]){0x2, 0, 0x27, 0x00, 0x1, pin + 1}, 7}, {DESC_UUID_NUMDIGITALS, (uint8_t[]){1}, sizeof(uint8_t)} }
68+
{ (pin), #pin, {CHAR_UUID_DIGITAL, BleWriteWithoutResponse | BleWrite}, {"2901", #pin}, {"2904", (uint8_t[]){0x02, 0x00, 0x00, 0x027, 0x1, pin + 1, 00}, 7}, {DESC_UUID_NUMDIGITALS, (uint8_t[]){1}, sizeof(uint8_t)} }
6969
#define ANALOG_INPUT_PINCONFIG(pin) \
70-
{ (pin), #pin, {CHAR_UUID_ANALOG, BleRead | BleNotify}, {"2901", #pin}, {"2904", (uint8_t[]){0x6, 0, 0x27, 0x00, 0x1, pin + 1}, 7} }
70+
{ (pin), #pin, {CHAR_UUID_ANALOG, BleRead | BleNotify}, {"2901", #pin}, {"2904", (uint8_t[]){0x6, 0x00, 0x00, 0x027, 0x1, pin + 1, 00}, 7} }
7171
#define ANALOG_OUTPUT_PINCONFIG(pin) \
72-
{ (pin), #pin, {CHAR_UUID_ANALOG, BleWriteWithoutResponse | BleWrite}, {"2901", #pin}, {"2904", (uint8_t[]){0x6, 0, 0x27, 0x00, 0x1, pin + 1}, 7} }
72+
{ (pin), #pin, {CHAR_UUID_ANALOG, BleWriteWithoutResponse | BleWrite}, {"2901", #pin}, {"2904", (uint8_t[]){0x6, 0x00, 0x00, 0x027, 0x1, pin + 1, 00}, 7} }
7373

7474
/* The following lists of pins are configured and presented to
7575
* the remote BLE device as digital/analog input/output pins

libraries/CurieBle/src/BleCharacteristic.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,13 @@ BleCharacteristic::add(uint16_t serviceHandle)
182182
}
183183

184184
if (_presentation_format) {
185-
memcpy(&pf_desc, _presentation_format->value(), sizeof(pf_desc));
185+
const uint8_t* pfValue = _presentation_format->value();
186+
187+
pf_desc.format = pfValue[0];
188+
pf_desc.exp = pfValue[1];
189+
pf_desc.unit = (pfValue[3] << 8) | pfValue[2];
190+
pf_desc.name_spc = pfValue[4];
191+
pf_desc.descr = (pfValue[6] << 8) | pfValue[5];
186192

187193
char_data.p_char_pf_desc = &pf_desc;
188194
}

0 commit comments

Comments
 (0)