Skip to content

Commit

Permalink
Adding Rotating Device Id to BLE & DNS-SD discovery (project-chip#4210)
Browse files Browse the repository at this point in the history
* RotatingId: version0

* RotatingId: version1

* RotatingId: version0

* RotatingId: version1

* Fix Darwin host build (project-chip#3990)

#### Problem

Some conversions to use PacketBufferHandle (project-chip#3909) broke Darwin builds,
which aren't currently run in CI.

#### Summary of Changes

Fix src/platform/Darwin/BleConnectionDelegateImpl.mm to match the API
change in project-chip#3909.

* Add '-Wextra' to compiler flags (project-chip#3902)

* Implement Level Control Cluster (project-chip#3806)

* New seekbar in Android CHIPTool
* Sample usage in lighting-app/nrfconnect

Signed-off-by: Markus Becker <markus.becker@tridonic.com>

* Fix Rendezvous over BLE after recent changes (project-chip#4012)

PR project-chip#3704 introduced a change that the BLE transport in
RendezvousSession is only initialized when PeerAddress
in RendezvousParams is of type BLE. However, PeerAddress
isn't initialized anywhere. As a result Rendezvous over BLE
stopped working between Android CHIPTool and accessories.

Btw, remove an assert related to the storage delegate
as it seems an optional member of the device controller.

* [thread] fix invalid configuration of active dataset (project-chip#4008)

* Fix data loss or crash in TCPEndPoint with LwIP (project-chip#4022)

* Fix data loss or crash in TCPEndPoint with LwIP

#### Problem

Under the configuration CHIP_SYSTEM_CONFIG_USE_LWIP, in some cases where
the data size exceeds the TCP window size, TCPEndPoint can either die or
lose data when accounting of un-acked data falls out of sync.

#### Summary of Changes

Imported fix from Weave:

* This change removes separate accounting of the unsent
  data position and replaces it with simple counting of
  sent-but-not-acked data and a skip-loop at the start
  of DriveSending().

Fixes project-chip#4013 - Data loss or crash in TCPEndPoint with LwIP

* Restyled by clang-format

Co-authored-by: Restyled.io <commits@restyled.io>

* Update lighting-app gen/ folder with ZAP generated content (project-chip#4010)

* Fix segmentation fault error in response echo message (project-chip#3984)

* Add back Android default build coverage & fix the build (project-chip#3966)

mDNS doesn't build with no device layer. Remove it from the build and
add back the coverage that would catch this that was lost in project-chip#3340.

* Update all-clusters-app gen/ folder with ZAP generated content (project-chip#3963)

* Move src/inet/tests to auto-test-driver generation (project-chip#3997)

* Rename TestUtils to UnitTestRegistration. (project-chip#4021)

Looking to remove usage of 'Utils' unless we have really no choice.
'UnitTestRegistration' seems clearer in what it does compared to
'TestUtils'.

* Update src/lib/core/tests to auto-test-driver generation (project-chip#3991)

* Cleanup zap chip-helper.js (project-chip#3973)

* Cleanup zap chip-helper.js

* Restyled by clang-format

Co-authored-by: Restyled.io <commits@restyled.io>

* Move src/transport/tests to auto-test-driver generation (project-chip#3999)

* Move src/transport/tests to auto-test-driver generation

* Add relevant libraries (and more test-capable libs) to nrf.

* Refactor inet test helpers (to not include actual inet tests), try to make qemu allow better linkage but still failed for transport tests so disabled for now

* Added more tests on esp32 qemu

* Restyle fixes

* Fix cast errors in InetCommon

* Disable raw tests from zephyr: somehow they fail running out of endpoints

* Disable DNS test on zephyr

* Remove inet endpoint test from zephyr

* Remove inet endpoint test from zephyr - fix again

* Modify gitignore

* Restyle fixes

* Use CHIPDeviceController instead of CHIPDeviceController_deprecated (project-chip#3979)

* Implement the missing part of Exchange Header in Transport layer (project-chip#4017)

* Implement the missing part of Exchange Header in Transport layer

* Revert comment 'if' back to 'iff'("if and only if")

* Remove duplicated send flag defines and put ExchangeMgr/ExchangeConte… (project-chip#3994)

* Remove duplicated send flag defines and put ExchangeMgr/ExchangeContext under the same namespace as CRMP

* Rename kSendFlag_Default to kSendFlag_None

* Move src/lib/asn1/tests and src/ble/tests to auto-test-driver generation (project-chip#3998)

* Move src/lib/asn1/tests and src/ble/tests to auto-test-driver generation

* Remove one more unused file

* Attempt to enable asn1 and ble tests in esp32 - see if they pass or not

* Fix merge error

* Update include header for ASN1 test

* Include  ASN1 in libCHIP

* Some conversions to use PacketBufferHandle (project-chip#4011)

* Some conversions to use PacketBufferHandle

#### Problem

Code should use `PacketBufferHandle` rather than `PacketBuffer *`.

#### Summary of Changes

- Converts remaining receive path in //src/inet and //src/transport.
- Converts most of //src/ble.
- Introduces Handle versions of the `AddToEnd`/`DetachTail` pair.

Part of issue project-chip#2707 - Figure out a way to express PacketBuffer ownership in the type system

* Restyled by clang-format

* review

* revive BtpEngine::Clear[TR]xPacket()
* simplify conditional
* (void) message.DetachTail() → message.FreeHead()
* remove ExchangeContext::kSendFlag_RetainBuffer
* missed pBuf.IsNull()
* DetachHead() → PopTail()
* typos

Co-authored-by: Restyled.io <commits@restyled.io>

* Move src/system/tests to auto-test-driver generation (project-chip#4000)

* Move src/system/tests to auto-test-driver generation

* Remove a TCP/IP init call that was killing qemu

* Remove explicit "all" target from root build file (project-chip#3967)

The "all" target exists implicitly and contains everything. We don't
need to specify one, and it's misleading to do so specifying deps has no
effect.

* Make src/setup_payload compile with -Werror=conversion (project-chip#4032)

* Add SSID and password to chip-tool pairing (project-chip#4054)

* Get temperature-measurement and all-clusters-app to use examples/common/chip-app-server (project-chip#4039)

#### Problem

PR project-chip#3704 introduced a change where a `PeerAddress` is now required in order to start `RendezvousSession`.
Sadly the multiple code paths bootstrapping `RendezvousSession` has not been updated.

PR project-chip#4012 add a fix for some of the `examples/` but not for the `all-clusters-app` nor the `temperature-measurement-app`.

To avoid such situation, this PR merge `examples/common/chip-app-server` and the custom code from `all-clusters-app` and `temperature-measurement-app`.

One of the more discutable change of this PR (imo) is the code that moves the custom `Echo` mechanism from the `all-clusters-app` to `chip-app-server`. I was hoping to get rid of it before doing this change but the `all-clusters-app` and the `temperature-measurement-app` are broken since project-chip#3704 and this PR should fix that.
Also I have a PR (mostly) ready once project-chip#3979 lands to get rid of this `Echo` specific code and replace it by a manufacturer specific `ping` command.

 #### Summary of Changes
 * Remove `EchoServer.cpp`, `RendezvousDeviceDelegate.cpp` and `include/RendezvousDeviceDelegate.h` from `all-clusters-app`
 * Remove `ResponseServer.cpp`, `RendezvousDeviceDelegate.cpp` and `include/RendezvousDeviceDelegate.h` from `temperature-measurement-app`
 * Introduce `chip-app-server/include/AppDelegate.h` in order to keep the behavior the `all-clusters-app` that turns on/off leds on different events. Maybe it should be converted to some types of `ChipDeviceEvent` or `CHIPCallback` at some point.
 * Fix `chip-app-server` to accomodate for the specifics of `all-clusters-app`

* Add all Thread ULA addresses to the lwip interface (project-chip#4053)

ULA prefixes will used for CHIP network so we need to add all these
addresses to the interface.

* Remove src/lib/message. (project-chip#4055)

* Remove src/lib/message.

Updated messaging implementation lives in src/messaging and the
src/lib/message is not currently compiled or linked in.

This saves us from looking at this code when some refactoring is needed
(e.g. the SystemPacketBuffer changes).

* Remove one more unused file

* [ChipTool] Add Payload Parse Command (project-chip#3696)

* [ChipTool] Add Payload Parse Command

* [ChipTool] Add Payload Parse Command

* [ChipTool] Restyle issues resolved

* Restyled by whitespace

* Resolve build errors caused by Command.h schema change

Co-authored-by: lijayaku <lijayaku@amazon.com>
Co-authored-by: Restyled.io <commits@restyled.io>

* rename ParseCommand to QRCodeParseCommand

* adding AdditionalDataParseCommand version 0

* Adding parsing logic + logging

* adding another parsing method

* Basic Parsing is DONE

* fixing memory issue

* removing some logs

* removing more logs

* minor update

* Add RotatingDeviceId to DNS-SD

* fix compilation problem

* fix minor diffs

* cleanup rotating id in ble

* fix dns

* nits

* fix compilation

* Revert "fix minor diffs"

This reverts commit 88fb69c.

* nits

* nit fixes

* update allocation

* update allocation

* refactoring

* revert settings.json

* fix styling

* Update README file

* adding a build flag to bypass advertising the additional data field

* fix styling

* fixing README style

* Fixing nits + added description about the additional data

* fixed minor comment

* remove ParseCommand

* removing unused headers + nits

* Fixing Additional data TLV Tags

* Fix Styling

* removed unnecessary logging tag

* fixing writing rotating id

* fixing minor styles

* adding check for rotating id tag

* restyling

* update AdditionalDataPayloadParser to work on vector of bytes

* restyling

* Nit fix

* Renaming QRCode command to SetupPayload command

* update parse command for additional data

* change compile flags

* update some comments

* fixing parsing/generating the additional data payload

* changing the additional parser APIs

* restyling

* reverting pigweed repo changes

* rename CHIP_ENABLE_ADDITIONAL_ADVERTISING

* removing logging tag

* adding extra validation in parser

* adding docs to the additional data payload parser

* Update ReadME.md

Co-authored-by: Kevin Schoedel <67607049+kpschoedel@users.noreply.github.com>
Co-authored-by: Vivien Nicolas <vnicolas@apple.com>
Co-authored-by: Markus Becker <Markus.Becker@tridonic.com>
Co-authored-by: Damian Królik <66667989+Damian-Nordic@users.noreply.github.com>
Co-authored-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
Co-authored-by: Restyled.io <commits@restyled.io>
Co-authored-by: Yufeng Wang <44623591+yufengwangca@users.noreply.github.com>
Co-authored-by: Michael Spang <spang@google.com>
Co-authored-by: Andrei Litvin <andrei@andy314.com>
Co-authored-by: jepenven-silabs <67962328+jepenven-silabs@users.noreply.github.com>
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
Co-authored-by: Jiacheng Guo <gjc@google.com>
Co-authored-by: Liju Jayakumar <26148162+lijujayakumar@users.noreply.github.com>
Co-authored-by: lijayaku <lijayaku@amazon.com>
  • Loading branch information
15 people committed Jan 8, 2021
1 parent 7ab493b commit 3d59f3f
Show file tree
Hide file tree
Showing 18 changed files with 436 additions and 30 deletions.
3 changes: 2 additions & 1 deletion examples/chip-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ executable("chip-tool") {
"commands/common/Command.cpp",
"commands/common/Commands.cpp",
"commands/pairing/PairingCommand.cpp",
"commands/payload/ParseCommand.cpp",
"commands/payload/AdditionalDataParseCommand.cpp",
"commands/payload/SetupPayloadParseCommand.cpp",
"config/PersistentStorage.cpp",
"main.cpp",
]
Expand Down
17 changes: 12 additions & 5 deletions examples/chip-tool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,25 @@ with the target cluster name and the target command name
### How to parse a setup code

To parse a setup code, run the built executable with the `payload` cluster name
and the `parse` command
and the `parse-setup-payload` command

$ chip-tool payload parse code
$ chip-tool payload parse-setup-payload code

#### QR Code

$ chip-tool payload parse "CH:#####"
$ chip-tool payload parse-setup-payload "CH:#####"

#### QR Code with optional Vendor Info

$ chip-tool chip-tool payload parse "CH:#####"
$ chip-tool chip-tool payload parse-setup-payload "CH:#####"

#### Manual Setup Code

$ chip-tool payload parse :#####"
$ chip-tool payload parse-setup-payload :#####"

# Using the Client for Additional Data Payload

To parse an additional data payload, run the built executable with the `payload`
cluster name and the `parse-additional-data-payload` command

$ chip-tool payload parse-additional-data-payload "#####"
48 changes: 48 additions & 0 deletions examples/chip-tool/commands/payload/AdditionalDataParseCommand.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2020 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#include "AdditionalDataParseCommand.h"
#include <setup_payload/AdditionalDataPayload.h>
#include <setup_payload/AdditionalDataPayloadParser.h>
#include <string>

using namespace ::chip;
using namespace ::chip::SetupPayload;

CHIP_ERROR AdditionalDataParseCommand::Run(PersistentStorage & storage, NodeId localId, NodeId remoteId)
{
std::vector<uint8_t> payloadData;
AdditionalDataPayload resultPayload;
CHIP_ERROR err = CHIP_NO_ERROR;
std::string payloadString(mPayload);

// Decode input payload
size_t len = payloadString.length();

for (size_t i = 0; i < len; i += 2)
{
auto str = payloadString.substr(i, 2);
uint8_t x = (uint8_t) stoi(str, 0, 16);
payloadData.push_back(x);
}
err = AdditionalDataPayloadParser(payloadData.data(), (uint32_t) payloadData.size()).populatePayload(resultPayload);
SuccessOrExit(err);
ChipLogProgress(chipTool, "AdditionalDataParseCommand, RotatingDeviceId=%s", resultPayload.rotatingDeviceId.c_str());
exit:
return err;
}
31 changes: 31 additions & 0 deletions examples/chip-tool/commands/payload/AdditionalDataParseCommand.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2020 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#pragma once

#include "../common/Command.h"

class AdditionalDataParseCommand : public Command
{
public:
AdditionalDataParseCommand() : Command("parse-additional-data-payload") { AddArgument("payload", &mPayload); }
CHIP_ERROR Run(PersistentStorage & storage, NodeId localId, NodeId remoteId) override;

private:
char * mPayload;
};
7 changes: 3 additions & 4 deletions examples/chip-tool/commands/payload/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@

#pragma once

#include "ParseCommand.h"
#include "AdditionalDataParseCommand.h"
#include "SetupPayloadParseCommand.h"

void registerCommandsPayload(Commands & commands)
{
const char * clusterName = "Payload";
commands_list clusterCommands = {
make_unique<ParseCommand>(),
};
commands_list clusterCommands = { make_unique<SetupPayloadParseCommand>(), make_unique<AdditionalDataParseCommand>() };

commands.Register(clusterName, clusterCommands);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
*
*/

#include "ParseCommand.h"
#include "SetupPayloadParseCommand.h"
#include <setup_payload/ManualSetupPayloadParser.h>
#include <setup_payload/QRCodeSetupPayloadParser.h>
#include <setup_payload/SetupPayload.h>

using namespace ::chip;

CHIP_ERROR ParseCommand::Run(PersistentStorage & storage, NodeId localId, NodeId remoteId)
CHIP_ERROR SetupPayloadParseCommand::Run(PersistentStorage & storage, NodeId localId, NodeId remoteId)
{
std::string codeString(mCode);
SetupPayload payload;
Expand All @@ -38,7 +38,7 @@ CHIP_ERROR ParseCommand::Run(PersistentStorage & storage, NodeId localId, NodeId
return err;
}

CHIP_ERROR ParseCommand::Print(chip::SetupPayload payload)
CHIP_ERROR SetupPayloadParseCommand::Print(chip::SetupPayload payload)
{
std::string serialNumber;
std::vector<OptionalQRCodeInfo> optionalVendorData;
Expand Down Expand Up @@ -80,7 +80,7 @@ CHIP_ERROR ParseCommand::Print(chip::SetupPayload payload)
return err;
}

CHIP_ERROR ParseCommand::Parse(std::string codeString, chip::SetupPayload & payload)
CHIP_ERROR SetupPayloadParseCommand::Parse(std::string codeString, chip::SetupPayload & payload)
{

CHIP_ERROR err = CHIP_NO_ERROR;
Expand All @@ -98,7 +98,7 @@ CHIP_ERROR ParseCommand::Parse(std::string codeString, chip::SetupPayload & payl
return err;
}

bool ParseCommand::IsQRCode(std::string codeString)
bool SetupPayloadParseCommand::IsQRCode(std::string codeString)
{
return codeString.rfind(QRCODE_PREFIX) == 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#include "../common/Command.h"
#include <setup_payload/SetupPayload.h>

class ParseCommand : public Command
class SetupPayloadParseCommand : public Command
{
public:
ParseCommand() : Command("parse") { AddArgument("code", &mCode); }
SetupPayloadParseCommand() : Command("parse-setup-payload") { AddArgument("payload", &mCode); }
CHIP_ERROR Run(PersistentStorage & storage, NodeId localId, NodeId remoteId) override;

private:
Expand Down
12 changes: 8 additions & 4 deletions src/ble/BleLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ const ChipBleUUID BleLayer::CHIP_BLE_CHAR_2_ID = { { // 18EE2EF5-263D-4559-959F-
0x18, 0xEE, 0x2E, 0xF5, 0x26, 0x3D, 0x45, 0x59, 0x95, 0x9F, 0x4F, 0x9C, 0x42,
0x9F, 0x9D, 0x12 } };

const ChipBleUUID BleLayer::CHIP_BLE_CHAR_3_ID = { { // 64630238-8772-45F2-B87D-748A83218F04
0x64, 0x63, 0x02, 0x38, 0x87, 0x72, 0x45, 0xF2, 0xB8, 0x7D, 0x74, 0x8A, 0x83,
0x21, 0x8F, 0x04 } };

void BleLayerObject::Release()
{
// Decrement the ref count. When it reaches zero, NULL out the pointer to the chip::System::Layer
Expand Down Expand Up @@ -600,7 +604,7 @@ bool BleLayer::HandleSubscribeReceived(BLE_CONNECTION_OBJECT connObj, const Chip
return false;
}

if (UUIDsMatch(&CHIP_BLE_CHAR_2_ID, charId))
if (UUIDsMatch(&CHIP_BLE_CHAR_2_ID, charId) || UUIDsMatch(&CHIP_BLE_CHAR_3_ID, charId))
{
// Find end point already associated with BLE connection, if any.
BLEEndPoint * endPoint = sBLEEndPointPool.Find(connObj);
Expand All @@ -625,7 +629,7 @@ bool BleLayer::HandleSubscribeComplete(BLE_CONNECTION_OBJECT connObj, const Chip
return false;
}

if (UUIDsMatch(&CHIP_BLE_CHAR_2_ID, charId))
if (UUIDsMatch(&CHIP_BLE_CHAR_2_ID, charId) || UUIDsMatch(&CHIP_BLE_CHAR_3_ID, charId))
{
BLEEndPoint * endPoint = sBLEEndPointPool.Find(connObj);

Expand All @@ -649,7 +653,7 @@ bool BleLayer::HandleUnsubscribeReceived(BLE_CONNECTION_OBJECT connObj, const Ch
return false;
}

if (UUIDsMatch(&CHIP_BLE_CHAR_2_ID, charId))
if (UUIDsMatch(&CHIP_BLE_CHAR_2_ID, charId) || UUIDsMatch(&CHIP_BLE_CHAR_3_ID, charId))
{
// Find end point already associated with BLE connection, if any.
BLEEndPoint * endPoint = sBLEEndPointPool.Find(connObj);
Expand All @@ -674,7 +678,7 @@ bool BleLayer::HandleUnsubscribeComplete(BLE_CONNECTION_OBJECT connObj, const Ch
return false;
}

if (UUIDsMatch(&CHIP_BLE_CHAR_2_ID, charId))
if (UUIDsMatch(&CHIP_BLE_CHAR_2_ID, charId) || UUIDsMatch(&CHIP_BLE_CHAR_3_ID, charId))
{
// Find end point already associated with BLE connection, if any.
BLEEndPoint * endPoint = sBLEEndPointPool.Find(connObj);
Expand Down
2 changes: 2 additions & 0 deletions src/ble/BleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ class DLL_EXPORT BleLayer
static const ChipBleUUID CHIP_BLE_CHAR_1_ID;
// UUID of CHIP service characteristic used for peripheral indications.
static const ChipBleUUID CHIP_BLE_CHAR_2_ID;
// UUID of CHIP service characteristic used for additional data
static const ChipBleUUID CHIP_BLE_CHAR_3_ID;

BleConnectionDelegate * mConnectionDelegate;
BlePlatformDelegate * mPlatformDelegate;
Expand Down
9 changes: 9 additions & 0 deletions src/include/platform/CHIPDeviceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -937,3 +937,12 @@
#ifndef CHIP_DEVICE_CONFIG_FIRMWARE_BUILD_TIME
#define CHIP_DEVICE_CONFIG_FIRMWARE_BUILD_TIME __TIME__
#endif

/**
* CHIP_ROTATING_DEVICE_ID
*
* Sample Rotating Device Id.
*/
#ifndef CHIP_ROTATING_DEVICE_ID
#define CHIP_ROTATING_DEVICE_ID "1122334455667788"
#endif
24 changes: 15 additions & 9 deletions src/lib/mdns/DiscoveryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ CHIP_ERROR DiscoveryManager::PublishUnprovisionedDevice(chip::Inet::IPAddressTyp
char discriminatorBuf[5]; // hex representation of 16-bit discriminator
char vendorProductBuf[10]; // "FFFF+FFFF"
// TODO: The text entry will be updated in the spec, update accordingly.
TextEntry entries[2] = {
{ "D", nullptr, 0 },
{ "VP", nullptr, 0 },
};

#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING
TextEntry entries[3] = { { "D", nullptr, 0 }, { "VP", nullptr, 0 }, { "RI", nullptr, 0 } };
#else
TextEntry entries[2] = { { "D", nullptr, 0 }, { "VP", nullptr, 0 } };
#endif
VerifyOrExit(mMdnsInitialized, error = CHIP_ERROR_INCORRECT_STATE);
ChipLogProgress(Discovery, "setup mdns service");
SuccessOrExit(error = chip::DeviceLayer::ConfigurationMgr().GetSetupDiscriminator(discriminator));
Expand All @@ -185,10 +185,16 @@ CHIP_ERROR DiscoveryManager::PublishUnprovisionedDevice(chip::Inet::IPAddressTyp
SuccessOrExit(error = chip::DeviceLayer::ConfigurationMgr().GetProductId(productID));
snprintf(discriminatorBuf, sizeof(discriminatorBuf), "%04X", discriminator);
snprintf(vendorProductBuf, sizeof(vendorProductBuf), "%04X+%04X", vendorID, productID);
entries[0].mData = reinterpret_cast<const uint8_t *>(discriminatorBuf);
entries[0].mDataSize = strnlen(discriminatorBuf, sizeof(discriminatorBuf));
entries[1].mData = reinterpret_cast<const uint8_t *>(vendorProductBuf);
entries[1].mDataSize = strnlen(discriminatorBuf, sizeof(vendorProductBuf));
entries[0].mData = reinterpret_cast<const uint8_t *>(discriminatorBuf);
entries[0].mDataSize = strnlen(discriminatorBuf, sizeof(discriminatorBuf));
entries[1].mData = reinterpret_cast<const uint8_t *>(vendorProductBuf);
entries[1].mDataSize = strnlen(discriminatorBuf, sizeof(vendorProductBuf));

#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING
// Rotating Device ID
entries[2].mData = reinterpret_cast<const uint8_t *>(CHIP_ROTATING_DEVICE_ID);
entries[2].mDataSize = strnlen(CHIP_ROTATING_DEVICE_ID, sizeof(CHIP_ROTATING_DEVICE_ID));
#endif
service.mTextEntryies = entries;
service.mTextEntrySize = sizeof(entries) / sizeof(TextEntry);
service.mPort = CHIP_PORT;
Expand Down
9 changes: 9 additions & 0 deletions src/platform/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ if (chip_device_platform != "none") {

# By pass provision and secure session
chip_bypass_rendezvous = false

# Enable including the additional data in the advertisement packets
chip_enable_additional_data_advertising = true
}

buildconfig_header("platform_buildconfig") {
Expand Down Expand Up @@ -79,6 +82,12 @@ if (chip_device_platform != "none") {
defines += [ "CHIP_BYPASS_RENDEZVOUS=1" ]
}

if (chip_enable_additional_data_advertising) {
defines += [ "CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING=1" ]
} else {
defines += [ "CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING=0" ]
}

if (chip_device_platform == "darwin") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_DARWIN=1",
Expand Down
Loading

0 comments on commit 3d59f3f

Please sign in to comment.