Skip to content

Commit

Permalink
Expose correct UUID length
Browse files Browse the repository at this point in the history
  • Loading branch information
thegecko committed May 7, 2023
1 parent d6a1a11 commit 2f25429
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/peripheral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Napi::Value Peripheral::GetServices(const Napi::CallbackInfo &info) {
}

Napi::String uuid =
Napi::String::New(env, service.uuid.value, SIMPLEBLE_UUID_STR_LEN);
Napi::String::New(env, service.uuid.value, SIMPLEBLE_UUID_STR_LEN_TS);

Napi::Uint8Array data = Napi::Uint8Array::New(env, service.data_length);
for (size_t i = 0; i < service.data_length; i++) {
Expand All @@ -197,7 +197,7 @@ Napi::Value Peripheral::GetServices(const Napi::CallbackInfo &info) {
for (size_t j = 0; j < characteristic.descriptor_count; j++) {
descriptors[j] =
Napi::String::New(env, characteristic.descriptors[j].uuid.value,
SIMPLEBLE_UUID_STR_LEN);
SIMPLEBLE_UUID_STR_LEN_TS);
}

obj.Set("uuid", characteristic.uuid.value);
Expand Down
2 changes: 2 additions & 0 deletions lib/peripheral.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <napi.h>
#include <simpleble_c/peripheral.h>

#define SIMPLEBLE_UUID_STR_LEN_TS SIMPLEBLE_UUID_STR_LEN - 1 // remove null terminator

class Peripheral : public Napi::ObjectWrap<Peripheral> {
public:
static Napi::Object Init(Napi::Env env, Napi::Object exports);
Expand Down

0 comments on commit 2f25429

Please sign in to comment.