Skip to content

Commit

Permalink
implementation of Auracast package
Browse files Browse the repository at this point in the history
This is simplified wrapper for Broadcast, that allows to create
Broadcast advertisements with sane defaults for advertising parameters.
Application still needs to build BASE configuration to use it.
  • Loading branch information
KKopyscinski committed Oct 25, 2023
1 parent 1e5dd8d commit 4aee232
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 0 deletions.
30 changes: 30 additions & 0 deletions nimble/host/services/auracast/pkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#

pkg.name: nimble/host/services/auracast
pkg.description: Implements Auracast service
pkg.author: "Apache Mynewt <dev@mynewt.apache.org>"
pkg.homepage: "http://mynewt.apache.org/"
pkg.keywords:
- ble
- bluetooth
- auracast
- nimble

pkg.deps:
- nimble/host
83 changes: 83 additions & 0 deletions nimble/host/services/auracast/src/ble_svc_auracast.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 "syscfg/syscfg.h"

#include "host/ble_hs.h"
#include "host/ble_audio_broadcast.h"
#include "services/auracast/ble_svc_auracast.h"

int
ble_svc_auracast_create(const struct ble_svc_auracast_create_params *params,
struct ble_broadcast_base_config *config_out,
ble_audio_broadcast_destroy_fn *destroy_cb,
void *args,
ble_gap_event_fn *gap_cb)
{
struct ble_broadcast_create_params create_params;
struct ble_gap_periodic_adv_params periodic_params = { 0 };
struct ble_gap_ext_adv_params extended_params = {
.scannable = 0,
.connectable = 0,
.primary_phy = BLE_HCI_LE_PHY_1M,
};
static uint8_t own_addr_type;
int rc;

rc = ble_hs_id_infer_auto(0, &own_addr_type);
if (rc != 0) {
return rc;
}

extended_params.own_addr_type = own_addr_type;
extended_params.sid = params->adv_instance;
extended_params.secondary_phy = MYNEWT_VAL(BLE_PHY_2M) ?
BLE_HCI_LE_PHY_2M : BLE_HCI_LE_PHY_1M;

create_params.base = params->base;
create_params.extended_params = &extended_params;
create_params.periodic_params = &periodic_params;
create_params.name = params->name;
create_params.adv_instance = params->adv_instance;
create_params.big_params = params->big_params;
create_params.svc_data = NULL;
create_params.svc_data_len = 0;

return ble_audio_broadcast_create(&create_params, config_out,
destroy_cb, args, gap_cb);
}

int
ble_svc_auracast_terminate(const struct ble_broadcast_base_config *base_config)
{
return ble_audio_broadcast_destroy(base_config);
}

int
ble_svc_auracast_start(const struct ble_broadcast_base_config *base_config)
{

return ble_audio_broadcast_start(base_config, NULL, NULL);
}

int
ble_svc_auracast_stop(const struct ble_broadcast_base_config *base_config)
{
return ble_audio_broadcast_stop(base_config);
}
21 changes: 21 additions & 0 deletions nimble/host/services/auracast/syscfg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#

syscfg.restrictions:
- BLE_PERIODIC_ADV: 1

0 comments on commit 4aee232

Please sign in to comment.