Skip to content

Commit

Permalink
Set characteristic cpfd to null to prevent crashing when registering …
Browse files Browse the repository at this point in the history
…characteristic.

* TODO: remove or embrace this new addition.
  • Loading branch information
h2zero committed Feb 25, 2024
1 parent aa37fad commit 65cd834
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/NimBLEService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ bool NimBLEService::start() {
pChr_a[i].flags = (*chr_it)->m_properties;
pChr_a[i].min_key_size = 0;
pChr_a[i].val_handle = &(*chr_it)->m_handle;
pChr_a[i].cpfd = nullptr;
++i;
}

Expand Down
2 changes: 1 addition & 1 deletion src/nimble/nimble/host/include/host/ble_gatt.h
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ struct ble_gatt_cpfd {
uint16_t unit;

/** The name space of the description. */
uint8_t namespace_;
uint8_t name_space;

/** The description of this characteristic. Depends on name space. */
uint16_t description;
Expand Down
4 changes: 2 additions & 2 deletions src/nimble/nimble/host/src/ble_gatts.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ ble_gatts_cpfd_is_sane(const struct ble_gatt_cpfd *cpfd)
return 0;
}

if ((cpfd->namespace_ == BLE_GATT_CHR_NAMESPACE_BT_SIG) && (cpfd->description > 0x0110)) {
if ((cpfd->name_space == BLE_GATT_CHR_NAMESPACE_BT_SIG) && (cpfd->description > 0x0110)) {
return 0;
}

Expand Down Expand Up @@ -1058,7 +1058,7 @@ ble_gatts_cpfd_access(uint16_t conn_handle, uint16_t attr_handle,
rc += os_mbuf_append(*om, &(cpfd->format), sizeof(cpfd->format));
rc += os_mbuf_append(*om, &(cpfd->exponent), sizeof(cpfd->exponent));
rc += os_mbuf_append(*om, &(cpfd->unit), sizeof(cpfd->unit));
rc += os_mbuf_append(*om, &(cpfd->namespace_), sizeof(cpfd->namespace_));
rc += os_mbuf_append(*om, &(cpfd->name_space), sizeof(cpfd->name_space));
rc += os_mbuf_append(*om, &(cpfd->description), sizeof(cpfd->description));

return ((rc == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES);
Expand Down

0 comments on commit 65cd834

Please sign in to comment.