|
23 | 23 | #include <zephyr/net/openthread.h>
|
24 | 24 |
|
25 | 25 | /* OpenThread BLE driver API */
|
| 26 | +#include <openthread/error.h> |
26 | 27 | #include <openthread/platform/ble.h>
|
| 28 | +#include <openthread/tcat.h> |
27 | 29 |
|
28 | 30 | /* Zephyr Logging */
|
29 | 31 |
|
@@ -100,13 +102,17 @@ static struct bt_conn_cb conn_callbacks = {.connected = connected,
|
100 | 102 | .le_param_req = le_param_req,
|
101 | 103 | .le_param_updated = le_param_updated};
|
102 | 104 |
|
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[] = { |
104 | 109 | 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), |
106 | 111 | };
|
107 | 112 |
|
108 |
| -static const struct bt_data sd[] = { |
| 113 | +static struct bt_data sd[] = { |
109 | 114 | 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), |
110 | 116 | };
|
111 | 117 |
|
112 | 118 | /* Zephyr BLE Message Queue and Thread */
|
@@ -388,12 +394,52 @@ static void bt_ready(int err)
|
388 | 394 | k_sem_give(&ot_plat_ble_init_semaphore); /* BLE stack up an running */
|
389 | 395 | }
|
390 | 396 |
|
| 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 | + |
391 | 438 | otError otPlatBleGapAdvStart(otInstance *aInstance, uint16_t aInterval)
|
392 | 439 | {
|
393 | 440 | ARG_UNUSED(aInstance);
|
394 | 441 | ARG_UNUSED(aInterval);
|
395 | 442 |
|
396 |
| - /* TO DO advertisement format change */ |
397 | 443 | int err = bt_le_adv_start(BT_LE_ADV_CONN, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));
|
398 | 444 |
|
399 | 445 | if (err != 0 && err != -EALREADY) {
|
|
0 commit comments