Skip to content

Add (optional) company ID argument to BLE.setManufacturerData(....) #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 5, 2019

Conversation

konikoni428
Copy link
Contributor

issue

ArduinoBLE referense sample code

  byte data[5] = { 0x01, 0x02, 0x03, 0x04, 0x05};
  BLE.setManufacturerData(data, 5);

Result of code execution
0x0201 -> companyId
0x03, 0x04, 0x05 -> manufacturerData

I think it ’s very confusing.

change

BLE.setManufacturerData(uint8_ uint8_t manufacturerData[], int manufacturerDataLength)

BLE.setManufacturerData(const uint16_t companyId, const uint8_t manufacturerData[], int manufacturerDataLength)

use

  uint8_t data[5] = { 0x01, 0x02, 0x03, 0x04, 0x05};
  BLE.setManufacturerData(0x1234, data, 5);

0x1234 -> companyId
0x01, 0x02, 0x03, 0x04, 0x05 -> manufacturerData

konikoni428 and others added 3 commits September 3, 2019 17:58
fix format

Co-Authored-By: per1234 <[email protected]>
fix format

Co-Authored-By: per1234 <[email protected]>
Copy link
Contributor

@sandeepmistry sandeepmistry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @konikoni428,

Thanks for submitting this pull request!

It looks fine, but it would be great it we could have both versions of the API for backwards compatibility.

@@ -43,7 +43,7 @@ class BLELocalDevice {

void setAdvertisedServiceUuid(const char* advertisedServiceUuid);
void setAdvertisedService(const BLEService& service);
void setManufacturerData(const uint8_t manufacturerData[], int manufacturerDataLength);
void setManufacturerData(const uint16_t companyId, const uint8_t manufacturerData[], int manufacturerDataLength);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to maintain backwards compatibility here and support both the newer and older API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pointing out the problem.
Please check new code.

Copy link
Contributor

@sandeepmistry sandeepmistry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@konikoni428 thanks for updating, the latest changes look good!

@sandeepmistry sandeepmistry changed the title add setManufacturerData argument Add (optional) company ID argument to BLE.setManufacturerData(....) Sep 5, 2019
@sandeepmistry sandeepmistry merged commit b6a66a4 into arduino-libraries:master Sep 5, 2019
@sandeepmistry
Copy link
Contributor

@SimonePDA we'll have to update the following page accordingly: https://www.arduino.cc/en/Reference/ArduinoBLEBLEsetManufacturerData

There's a new syntax to be added:

BLE.setManufacturerData(companyId, data, length)
  • companyId - (optional) 16-bit company id of manufacturer data (expected to be included in data array if not provided)

cparata added a commit to cparata/ArduinoBLE that referenced this pull request Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants