Skip to content

Commit 4c34e95

Browse files
Przemyslaw Bidaaescolar
authored andcommitted
net: openthread: Add implementation of TCAT advertisement.
Adds implementation of tcat advertisement API. Signed-off-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
1 parent 54d9fe3 commit 4c34e95

File tree

1 file changed

+50
-4
lines changed
  • modules/openthread/platform

1 file changed

+50
-4
lines changed

modules/openthread/platform/ble.c

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
#include <zephyr/net/openthread.h>
2424

2525
/* OpenThread BLE driver API */
26+
#include <openthread/error.h>
2627
#include <openthread/platform/ble.h>
28+
#include <openthread/tcat.h>
2729

2830
/* Zephyr Logging */
2931

@@ -100,13 +102,17 @@ static struct bt_conn_cb conn_callbacks = {.connected = connected,
100102
.le_param_req = le_param_req,
101103
.le_param_updated = le_param_updated};
102104

103-
static const struct bt_data ad[] = {
105+
static uint8_t service_data[OT_TCAT_ADVERTISEMENT_MAX_LEN] = {0};
106+
static const uint8_t service_data_size = ARRAY_SIZE(service_data);
107+
108+
static struct bt_data ad[] = {
104109
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
105-
BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN),
110+
BT_DATA(BT_DATA_SVC_DATA16, service_data, service_data_size),
106111
};
107112

108-
static const struct bt_data sd[] = {
113+
static struct bt_data sd[] = {
109114
BT_DATA_BYTES(BT_DATA_UUID16_ALL, BT_UUID_16_ENCODE(TOBLE_SERVICE_UUID)),
115+
BT_DATA(BT_DATA_SVC_DATA16, service_data, service_data_size),
110116
};
111117

112118
/* Zephyr BLE Message Queue and Thread */
@@ -388,12 +394,52 @@ static void bt_ready(int err)
388394
k_sem_give(&ot_plat_ble_init_semaphore); /* BLE stack up an running */
389395
}
390396

397+
void otPlatBleGetLinkCapabilities(otInstance *aInstance,
398+
otBleLinkCapabilities *aBleLinkCapabilities)
399+
{
400+
ARG_UNUSED(aInstance);
401+
402+
aBleLinkCapabilities->mGattNotifications = 1;
403+
aBleLinkCapabilities->mL2CapDirect = 0;
404+
aBleLinkCapabilities->mRsv = 0;
405+
}
406+
407+
bool otPlatBleSupportsMultiRadio(otInstance *aInstance)
408+
{
409+
OT_UNUSED_VARIABLE(aInstance);
410+
411+
return false;
412+
}
413+
414+
otError otPlatBleGetAdvertisementBuffer(otInstance *aInstance, uint8_t **aAdvertisementBuffer)
415+
{
416+
ARG_UNUSED(aInstance);
417+
418+
*aAdvertisementBuffer = service_data;
419+
420+
return OT_ERROR_NONE;
421+
}
422+
423+
otError otPlatBleGapAdvSetData(otInstance *aInstance, uint8_t *aAdvertisementData,
424+
uint16_t aAdvertisementLen)
425+
{
426+
ARG_UNUSED(aInstance);
427+
428+
if (aAdvertisementLen > OT_TCAT_ADVERTISEMENT_MAX_LEN || aAdvertisementData == NULL) {
429+
LOG_ERR("Invalid TCAT Advertisement parameters advlen: %d", aAdvertisementLen);
430+
return OT_ERROR_INVALID_ARGS;
431+
}
432+
433+
ad[1].data_len = (uint8_t)aAdvertisementLen;
434+
sd[1].data_len = (uint8_t)aAdvertisementLen;
435+
return OT_ERROR_NONE;
436+
}
437+
391438
otError otPlatBleGapAdvStart(otInstance *aInstance, uint16_t aInterval)
392439
{
393440
ARG_UNUSED(aInstance);
394441
ARG_UNUSED(aInterval);
395442

396-
/* TO DO advertisement format change */
397443
int err = bt_le_adv_start(BT_LE_ADV_CONN, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));
398444

399445
if (err != 0 && err != -EALREADY) {

0 commit comments

Comments
 (0)