Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
KKopyscinski merged PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
KKopyscinski commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1398821542 ## nimble/host/services/auracast/src/ble_svc_auracast.c: ## @@ -0,0 +1,102 @@ +/* + * 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_gap.h" +#include "host/ble_hs.h" +#include "host/ble_audio_broadcast.h" +#include "services/auracast/ble_svc_auracast.h" + +static uint8_t +adv_instance_find_free(void) +{ +uint8_t i; + +for (i = 1; i <= MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES); i++) { +if (!ble_gap_adv_configured_instance(i)) { +return i; +} +} + +return 0; +} + +int +ble_svc_auracast_create(const struct ble_svc_auracast_create_params *params, +uint8_t *adv_instance, Review Comment: auracast_instance (change name) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
KKopyscinski commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1396975974 ## nimble/host/services/auracast/syscfg.yml: ## @@ -0,0 +1,27 @@ +# +# 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.defs: + BLE_SVC_AURACAST_ADV_INSTANCE: +description: > + Defines which advertising instance is used for Auracast. +value: 42 + +syscfg.restrictions: + - BLE_PERIODIC_ADV: 1 Review Comment: I removed this all together, added 7abb8e66a5d672d94d2dde33ff294a8809e9abde to fetch non-configured advertising instance and Auracast will report back what was found. Maybe this commit should be moved to another PR -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
KKopyscinski commented on PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#issuecomment-1814330084 Added sample application for broadcast, fixed minor bug in ble_iso.c. Build check (all apps) is failing, seems to me app tries to be built with ll, but was designed for two core boards (nRF53, net core running ble-hci) I'm not sure how this should be resolved, maybe some config changes? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
KKopyscinski commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1395604096 ## nimble/host/services/auracast/src/ble_svc_auracast.c: ## @@ -0,0 +1,88 @@ +/* + * 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_gap.h" +#include "host/ble_hs.h" +#include "host/ble_audio_broadcast.h" +#include "services/auracast/ble_svc_auracast.h" + +#define AURACAST_ADV_INSTANCE \ + MYNEWT_VAL(BLE_SVC_AURACAST_ADV_INSTANCE) < 0 ?\ + (MYNEWT_VAL(BLE_MESH) ? MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES) - 1 : \ + MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES)) : \ + MYNEWT_VAL(BLE_SVC_AURACAST_ADV_INSTANCE) + +int +ble_svc_auracast_create(const struct ble_svc_auracast_create_params *params, +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, +}; +uint8_t own_addr_type; +int rc; + +rc = ble_hs_id_infer_auto(0, _addr_type); +if (rc != 0) { +return rc; +} + +extended_params.own_addr_type = own_addr_type; +extended_params.sid = AURACAST_ADV_INSTANCE; +extended_params.secondary_phy = MYNEWT_VAL(BLE_PHY_2M) ? +BLE_HCI_LE_PHY_2M : BLE_HCI_LE_PHY_1M; Review Comment: done, added check if requested PHY is supported ## nimble/host/services/auracast/src/ble_svc_auracast.c: ## @@ -0,0 +1,88 @@ +/* + * 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_gap.h" +#include "host/ble_hs.h" +#include "host/ble_audio_broadcast.h" +#include "services/auracast/ble_svc_auracast.h" + +#define AURACAST_ADV_INSTANCE \ + MYNEWT_VAL(BLE_SVC_AURACAST_ADV_INSTANCE) < 0 ?\ + (MYNEWT_VAL(BLE_MESH) ? MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES) - 1 : \ + MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES)) : \ + MYNEWT_VAL(BLE_SVC_AURACAST_ADV_INSTANCE) + +int +ble_svc_auracast_create(const struct ble_svc_auracast_create_params *params, +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, +}; +uint8_t own_addr_type; +int rc; + +rc = ble_hs_id_infer_auto(0, _addr_type); +if (rc != 0) { +return rc; +} + +extended_params.own_addr_type = own_addr_type; +extended_params.sid = AURACAST_ADV_INSTANCE; Review Comment: done ## nimble/host/services/auracast/src/ble_svc_auracast.c: ## @@ -0,0 +1,88 @@ +/* + * 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
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
KKopyscinski commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1395603739 ## nimble/host/services/auracast/syscfg.yml: ## @@ -0,0 +1,27 @@ +# +# 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.defs: + BLE_SVC_AURACAST_ADV_INSTANCE: +description: > + Defines which advertising instance is used for Auracast. +value: 42 Review Comment: done -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
KKopyscinski commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1390774624 ## nimble/host/services/auracast/syscfg.yml: ## @@ -0,0 +1,27 @@ +# +# 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.defs: + BLE_SVC_AURACAST_ADV_INSTANCE: +description: > + Defines which advertising instance is used for Auracast. +value: 42 Review Comment: as discussed offline, I'd change it to start index of first auracast (BIG). When user creates more, new BIG will occupy instance. add restriction that additional instances are > 1 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
andrzej-kaczmarek commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1389274586 ## nimble/host/services/auracast/syscfg.yml: ## @@ -0,0 +1,27 @@ +# +# 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.defs: + BLE_SVC_AURACAST_ADV_INSTANCE: +description: > + Defines which advertising instance is used for Auracast. +value: 42 Review Comment: I don't think this should be a syscfg value. app has to call `ble_svc_auracast_create` anyway so it can also include adv instance. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
andrzej-kaczmarek commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1389275854 ## nimble/host/services/auracast/src/ble_svc_auracast.c: ## @@ -0,0 +1,88 @@ +/* + * 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_gap.h" +#include "host/ble_hs.h" +#include "host/ble_audio_broadcast.h" +#include "services/auracast/ble_svc_auracast.h" + +#define AURACAST_ADV_INSTANCE \ + MYNEWT_VAL(BLE_SVC_AURACAST_ADV_INSTANCE) < 0 ?\ + (MYNEWT_VAL(BLE_MESH) ? MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES) - 1 : \ + MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES)) : \ + MYNEWT_VAL(BLE_SVC_AURACAST_ADV_INSTANCE) + +int +ble_svc_auracast_create(const struct ble_svc_auracast_create_params *params, +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, +}; +uint8_t own_addr_type; +int rc; + +rc = ble_hs_id_infer_auto(0, _addr_type); +if (rc != 0) { +return rc; +} + +extended_params.own_addr_type = own_addr_type; +extended_params.sid = AURACAST_ADV_INSTANCE; +extended_params.secondary_phy = MYNEWT_VAL(BLE_PHY_2M) ? +BLE_HCI_LE_PHY_2M : BLE_HCI_LE_PHY_1M; Review Comment: this should be also a parameter ## nimble/host/services/auracast/src/ble_svc_auracast.c: ## @@ -0,0 +1,88 @@ +/* + * 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_gap.h" +#include "host/ble_hs.h" +#include "host/ble_audio_broadcast.h" +#include "services/auracast/ble_svc_auracast.h" + +#define AURACAST_ADV_INSTANCE \ + MYNEWT_VAL(BLE_SVC_AURACAST_ADV_INSTANCE) < 0 ?\ + (MYNEWT_VAL(BLE_MESH) ? MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES) - 1 : \ + MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES)) : \ + MYNEWT_VAL(BLE_SVC_AURACAST_ADV_INSTANCE) + +int +ble_svc_auracast_create(const struct ble_svc_auracast_create_params *params, +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, +}; +uint8_t own_addr_type; +int rc; + +rc = ble_hs_id_infer_auto(0, _addr_type); +if (rc != 0) { +return rc; +} + +extended_params.own_addr_type = own_addr_type; +extended_params.sid = AURACAST_ADV_INSTANCE; Review Comment: this should be parameter -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org For queries about this service, please contact Infrastructure at:
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
andrzej-kaczmarek commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1389274821 ## nimble/host/services/auracast/syscfg.yml: ## @@ -0,0 +1,27 @@ +# +# 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.defs: + BLE_SVC_AURACAST_ADV_INSTANCE: +description: > + Defines which advertising instance is used for Auracast. +value: 42 + +syscfg.restrictions: + - BLE_PERIODIC_ADV: 1 Review Comment: this likely doesn't work as expected -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
KKopyscinski commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1384505312 ## nimble/host/include/host/ble_audio_broadcast.h: ## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +#ifndef H_BLE_AUDIO_BROADCAST_ +#define H_BLE_AUDIO_BROADCAST_ + +#include +#include "host/ble_gap.h" +#include "host/ble_iso.h" +#include "host/ble_audio_common.h" + +struct ble_broadcast_create_params { +/** Broadcast Audio Source Endpoint */ +struct ble_audio_base *base; + +/** Parameters used to configure Extended advertising */ +struct ble_gap_ext_adv_params *extended_params; + +/** Parameters used to configure Periodic advertising */ +struct ble_gap_periodic_adv_params *periodic_params; + +/** Broadcast name - null terminated. + * Set NULL to not include in advertising. + * Length must be in range of 4 to 32 chars. + */ +const char *name; + +/** Advertising instance */ +uint8_t adv_instance; + +/** BIG parameters */ +struct ble_iso_big_params *big_params; + +/** Additional data to include in Extended Advertising */ +uint8_t *svc_data; + +/** Additional data length */ +uint16_t svc_data_len; +}; + +struct ble_broadcast_update_params { +/** Broadcast name - null terminated. + * Set NULL to not include in advertising + */ +const char *name; + +/** Advertising instance */ +uint8_t adv_instance; + +/** Additional data to include in Extended Advertising */ +uint8_t *svc_data; + +/** Additional data length */ +uint16_t svc_data_len; + +/** Broadcast ID */ +uint32_t broadcast_id; +}; + +typedef int ble_audio_broadcast_destroy_fn(struct ble_audio_base *base, + void *args); + +/** + * @brief Create Broadcast Audio Source Endpoint and configure advertising + * instance + * + * This function configures advertising instance for extended and periodic + * advertisements to be ready for broadcast with BASE configuration. + * + * @param[in] paramsPointer to a `ble_broadcast_base_params` + * structure that defines BASE, extended + * advertising and periodic advertising + * configuration. + * @param[in] destroy_cbOptional callback to be invoked on + * `ble_audio_broadcast_destroy` call. + * @param[in] args Optional arguments to be passed to `destroy_cb` + * @param[in] gap_cbGAP event callback to be associated with BASE + * advertisement. + * + * @return 0 on success; + * A non-zero value on failure. + */ +int ble_audio_broadcast_create(const struct ble_broadcast_create_params + *params, + ble_audio_broadcast_destroy_fn *destroy_cb, + void *args, + ble_gap_event_fn *gap_cb); + +/** + * @brief Start advertisements for given BASE configuration + * + * This function starts BASE advertisement by enabling extended, periodic + * and BIGInfo advertisements for this instance. + * + * @param[in] adv_instance Advertising instance used by broadcast. + * @param[in] cbPointer to an ISO event handler. + * @param[in] cb_argArguments to an ISO event handler. + * + * @return 0 on success; + * A non-zero value on failure. + */ +int ble_audio_broadcast_start(uint8_t adv_instance, + ble_iso_event_fn *cb, void *cb_arg); + +/** + * @brief Stop advertisements for given BASE configuration + * + * This function stops BASE advertisement by disabling extended and periodic + * advertising. Advertising instance is still configured and ready for resume. + * + * @param[in] adv_instance Advertising instance used by broadcast. + * + * @return 0 on success; + * A non-zero value on failure. + */ +int ble_audio_broadcast_stop(uint8_t
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
rymanluk commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1384500722 ## porting/examples/linux/include/syscfg/syscfg.h: ## @@ -771,6 +783,14 @@ #define MYNEWT_VAL_BLE_L2CAP_SIG_MAX_PROCS (1) #endif +#ifndef MYNEWT_VAL_BLE_MAX_BIG +#define MYNEWT_VAL_BLE_MAX_BIG (MYNEWT_VAL_BLE_MULTI_ADV_INSTANCES) +#endif + +#ifndef MYNEWT_VAL_BLE_MAX_BIS +#define MYNEWT_VAL_BLE_MAX_BIS (4) Review Comment: total should be fine. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
rymanluk commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1384498428 ## nimble/host/include/host/ble_audio_broadcast.h: ## @@ -0,0 +1,271 @@ +/* + * 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. + */ + +#ifndef H_BLE_AUDIO_BROADCAST_ +#define H_BLE_AUDIO_BROADCAST_ + +#include +#include "host/ble_gap.h" +#include "host/ble_iso.h" +#include "host/ble_audio_common.h" + +struct ble_broadcast_create_params { +/** BASE to broadcast */ +struct ble_audio_base *base; + +/** Parameters used to configure Extended advertising */ +struct ble_gap_ext_adv_params *extended_params; + +/** Parameters used to configure Periodic advertising */ +struct ble_gap_periodic_adv_params *periodic_params; + +/** Broadcast name - null terminated. + * Set NULL to not include in advertising + */ +const char *name; + +/** Advertising instance */ +uint8_t adv_instance; + +/** BIG parameters */ +struct ble_iso_big_params *big_params; + +/** Additional data to include in Extended Advertising */ +uint8_t *svc_data; + +/** Additional data length */ +uint16_t svc_data_len; +}; + +struct ble_broadcast_update_params { +/** Broadcast name - null terminated. + * Set NULL to not include in advertising + */ +const char *name; + +/** Advertising instance */ +uint8_t adv_instance; + +/** Additional data to include in Extended Advertising */ +uint8_t *svc_data; + +/** Additional data length */ +uint16_t svc_data_len; + +/** Broadcast ID */ +uint32_t broadcast_id; +}; + +typedef int ble_audio_broadcast_destroy_fn(struct ble_audio_base *base, + void *args); + +/** BASE configuration describing broadcast advertisement */ +struct ble_broadcast_base_config { +/** Advertising instance used by broadcast */ +uint8_t adv_instance; + +/** Pointer to BASE configuration */ +struct ble_audio_base *base; + +/** BIG parameters */ +struct ble_iso_big_params *big_params; + +/** + * Optional callback associated with broadcasting instance, called on + * destroying broadcast + */ +ble_audio_broadcast_destroy_fn *destroy_cb; + +/** Pointer to args for `destroy_cb` */ +void *args; +}; + +/** + * @brief Create Broadcast Audio Source Endpoint and configure advertising + * instance + * + * This function configures advertising instance for extended and periodic + * advertisements to be ready for broadcast with BASE configuration. + * + * @param[in] paramsPointer to a `ble_broadcast_base_params` + * structure that defines BASE, extended + * advertising and periodic advertising + * configuration. + * @param[out] config_out Pointer to a `ble_broadcast_base_config` + * structure to return configuration of created + * BASE advertisement. + * @param[in] destroy_cbOptional callback to be called when BASE + * advertisement is destroyed. + * @param[in] args Optional arguments to be passed to `destroy_cb` + * @param[in] gap_cbGAP event callback to be associated with BASE + * advertisement. + * + * @return 0 on success; + * A non-zero value on failure. + */ +int ble_audio_broadcast_create(const struct ble_broadcast_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); + +/** + * @brief Start advertisements for given BASE configuration + * + * This function starts BASE advertisement on by enabling extended and periodic + * advertising and creates BASE for this instance. + * + * @param[in] base_config Pointer to a `ble_broadcast_base_config` + * struct that shall be
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
rymanluk commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1384493371 ## nimble/host/include/host/ble_audio_broadcast.h: ## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +#ifndef H_BLE_AUDIO_BROADCAST_ +#define H_BLE_AUDIO_BROADCAST_ + +#include +#include "host/ble_gap.h" +#include "host/ble_iso.h" +#include "host/ble_audio_common.h" + +struct ble_broadcast_create_params { +/** Broadcast Audio Source Endpoint */ +struct ble_audio_base *base; + +/** Parameters used to configure Extended advertising */ +struct ble_gap_ext_adv_params *extended_params; + +/** Parameters used to configure Periodic advertising */ +struct ble_gap_periodic_adv_params *periodic_params; + +/** Broadcast name - null terminated. + * Set NULL to not include in advertising. + * Length must be in range of 4 to 32 chars. + */ +const char *name; + +/** Advertising instance */ +uint8_t adv_instance; + +/** BIG parameters */ +struct ble_iso_big_params *big_params; + +/** Additional data to include in Extended Advertising */ +uint8_t *svc_data; + +/** Additional data length */ +uint16_t svc_data_len; +}; + +struct ble_broadcast_update_params { +/** Broadcast name - null terminated. + * Set NULL to not include in advertising + */ +const char *name; + +/** Advertising instance */ +uint8_t adv_instance; + +/** Additional data to include in Extended Advertising */ +uint8_t *svc_data; + +/** Additional data length */ +uint16_t svc_data_len; + +/** Broadcast ID */ +uint32_t broadcast_id; +}; + +typedef int ble_audio_broadcast_destroy_fn(struct ble_audio_base *base, + void *args); + +/** + * @brief Create Broadcast Audio Source Endpoint and configure advertising + * instance + * + * This function configures advertising instance for extended and periodic + * advertisements to be ready for broadcast with BASE configuration. + * + * @param[in] paramsPointer to a `ble_broadcast_base_params` + * structure that defines BASE, extended + * advertising and periodic advertising + * configuration. + * @param[in] destroy_cbOptional callback to be invoked on + * `ble_audio_broadcast_destroy` call. + * @param[in] args Optional arguments to be passed to `destroy_cb` + * @param[in] gap_cbGAP event callback to be associated with BASE + * advertisement. + * + * @return 0 on success; + * A non-zero value on failure. + */ +int ble_audio_broadcast_create(const struct ble_broadcast_create_params + *params, + ble_audio_broadcast_destroy_fn *destroy_cb, + void *args, + ble_gap_event_fn *gap_cb); + +/** + * @brief Start advertisements for given BASE configuration + * + * This function starts BASE advertisement by enabling extended, periodic + * and BIGInfo advertisements for this instance. + * + * @param[in] adv_instance Advertising instance used by broadcast. + * @param[in] cbPointer to an ISO event handler. + * @param[in] cb_argArguments to an ISO event handler. + * + * @return 0 on success; + * A non-zero value on failure. + */ +int ble_audio_broadcast_start(uint8_t adv_instance, + ble_iso_event_fn *cb, void *cb_arg); + +/** + * @brief Stop advertisements for given BASE configuration + * + * This function stops BASE advertisement by disabling extended and periodic + * advertising. Advertising instance is still configured and ready for resume. + * + * @param[in] adv_instance Advertising instance used by broadcast. + * + * @return 0 on success; + * A non-zero value on failure. + */ +int ble_audio_broadcast_stop(uint8_t adv_instance); +
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
rymanluk commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1384493371 ## nimble/host/include/host/ble_audio_broadcast.h: ## @@ -0,0 +1,245 @@ +/* + * 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. + */ + +#ifndef H_BLE_AUDIO_BROADCAST_ +#define H_BLE_AUDIO_BROADCAST_ + +#include +#include "host/ble_gap.h" +#include "host/ble_iso.h" +#include "host/ble_audio_common.h" + +struct ble_broadcast_create_params { +/** Broadcast Audio Source Endpoint */ +struct ble_audio_base *base; + +/** Parameters used to configure Extended advertising */ +struct ble_gap_ext_adv_params *extended_params; + +/** Parameters used to configure Periodic advertising */ +struct ble_gap_periodic_adv_params *periodic_params; + +/** Broadcast name - null terminated. + * Set NULL to not include in advertising. + * Length must be in range of 4 to 32 chars. + */ +const char *name; + +/** Advertising instance */ +uint8_t adv_instance; + +/** BIG parameters */ +struct ble_iso_big_params *big_params; + +/** Additional data to include in Extended Advertising */ +uint8_t *svc_data; + +/** Additional data length */ +uint16_t svc_data_len; +}; + +struct ble_broadcast_update_params { +/** Broadcast name - null terminated. + * Set NULL to not include in advertising + */ +const char *name; + +/** Advertising instance */ +uint8_t adv_instance; + +/** Additional data to include in Extended Advertising */ +uint8_t *svc_data; + +/** Additional data length */ +uint16_t svc_data_len; + +/** Broadcast ID */ +uint32_t broadcast_id; +}; + +typedef int ble_audio_broadcast_destroy_fn(struct ble_audio_base *base, + void *args); + +/** + * @brief Create Broadcast Audio Source Endpoint and configure advertising + * instance + * + * This function configures advertising instance for extended and periodic + * advertisements to be ready for broadcast with BASE configuration. + * + * @param[in] paramsPointer to a `ble_broadcast_base_params` + * structure that defines BASE, extended + * advertising and periodic advertising + * configuration. + * @param[in] destroy_cbOptional callback to be invoked on + * `ble_audio_broadcast_destroy` call. + * @param[in] args Optional arguments to be passed to `destroy_cb` + * @param[in] gap_cbGAP event callback to be associated with BASE + * advertisement. + * + * @return 0 on success; + * A non-zero value on failure. + */ +int ble_audio_broadcast_create(const struct ble_broadcast_create_params + *params, + ble_audio_broadcast_destroy_fn *destroy_cb, + void *args, + ble_gap_event_fn *gap_cb); + +/** + * @brief Start advertisements for given BASE configuration + * + * This function starts BASE advertisement by enabling extended, periodic + * and BIGInfo advertisements for this instance. + * + * @param[in] adv_instance Advertising instance used by broadcast. + * @param[in] cbPointer to an ISO event handler. + * @param[in] cb_argArguments to an ISO event handler. + * + * @return 0 on success; + * A non-zero value on failure. + */ +int ble_audio_broadcast_start(uint8_t adv_instance, + ble_iso_event_fn *cb, void *cb_arg); + +/** + * @brief Stop advertisements for given BASE configuration + * + * This function stops BASE advertisement by disabling extended and periodic + * advertising. Advertising instance is still configured and ready for resume. + * + * @param[in] adv_instance Advertising instance used by broadcast. + * + * @return 0 on success; + * A non-zero value on failure. + */ +int ble_audio_broadcast_stop(uint8_t adv_instance); +
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
KKopyscinski commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1383214799 ## nimble/host/include/host/ble_audio_common.h: ## @@ -0,0 +1,179 @@ +/* + * 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. + */ + +#ifndef H_BLE_AUDIO_COMMON_ +#define H_BLE_AUDIO_COMMON_ + +#include "stdint.h" +#include "os/queue.h" + +#define BLE_BROADCAST_AUDIO_ANNOUNCEMENT_SVC_UUID 0x1852 + +#define BLE_AUDIO_SAMPLING_RATE_8000_HZ 0x00 +#define BLE_AUDIO_SAMPLING_RATE_11025_HZ 0x01 +#define BLE_AUDIO_SAMPLING_RATE_16000_HZ 0x02 +#define BLE_AUDIO_SAMPLING_RATE_22050_HZ 0x03 +#define BLE_AUDIO_SAMPLING_RATE_24000_HZ 0x04 +#define BLE_AUDIO_SAMPLING_RATE_32000_HZ 0x05 +#define BLE_AUDIO_SAMPLING_RATE_44100_HZ 0x06 +#define BLE_AUDIO_SAMPLING_RATE_48000_HZ 0x07 +#define BLE_AUDIO_SAMPLING_RATE_88200_HZ 0x08 +#define BLE_AUDIO_SAMPLING_RATE_96000_HZ 0x09 +#define BLE_AUDIO_SAMPLING_RATE_176400_HZ 0x0A +#define BLE_AUDIO_SAMPLING_RATE_192000_HZ 0x0B +#define BLE_AUDIO_SAMPLING_RATE_384000_HZ 0x0C + +#define BLE_AUDIO_SELECTED_FRAME_DURATION_7_5_MS 0x00 +#define BLE_AUDIO_SELECTED_FRAME_DURATION_10_MS 0x01 + +#define BLE_AUDIO_LOCATION_FRONT_LEFT BIT(0) +#define BLE_AUDIO_LOCATION_FRONT_RIGHTBIT(1) +#define BLE_AUDIO_LOCATION_FRONT_CENTER BIT(2) +#define BLE_AUDIO_LOCATION_LOW_FREQ_EFFECTS_1 BIT(3) +#define BLE_AUDIO_LOCATION_BACK_LEFT BIT(4) +#define BLE_AUDIO_LOCATION_FRONT_LEFT_CENTER BIT(5) +#define BLE_AUDIO_LOCATION_FRONT_RIGHT_CENTER BIT(6) +#define BLE_AUDIO_LOCATION_BACK_CENTERBIT(7) +#define BLE_AUDIO_LOCATION_LOW_FREQ_EFFECTS_2 BIT(8) +#define BLE_AUDIO_LOCATION_SIDE_LEFT BIT(9) +#define BLE_AUDIO_LOCATION_SIDE_RIGHT BIT(10) +#define BLE_AUDIO_LOCATION_TOP_FRONT_LEFT BIT(11) +#define BLE_AUDIO_LOCATION_TOP_FRONT_RIGHTBIT(12) +#define BLE_AUDIO_LOCATION_TOP_FRONT_CENTER BIT(13) +#define BLE_AUDIO_LOCATION_TOP_CENTER BIT(14) +#define BLE_AUDIO_LOCATION_TOP_BACK_LEFT BIT(15) +#define BLE_AUDIO_LOCATION_TOP_BACK_RIGHT BIT(16) +#define BLE_AUDIO_LOCATION_TOP_SIDE_LEFT BIT(17) +#define BLE_AUDIO_LOCATION_TOP_SIDE_RIGHT BIT(18) +#define BLE_AUDIO_LOCATION_TOP_BACK_CENTERBIT(19) +#define BLE_AUDIO_LOCATION_BOTTOM_FRONT_CENTERBIT(20) +#define BLE_AUDIO_LOCATION_BOTTOM_FRONT_LEFT BIT(21) +#define BLE_AUDIO_LOCATION_BOTTOM_FRONT_RIGHT BIT(22) +#define BLE_AUDIO_LOCATION_LEFT_SURROUND BIT(23) +#define BLE_AUDIO_LOCATION_RIGHT_SURROUND BIT(24) + +#define BLE_AUDIO_CODEC_SAMPLING_FREQ_TYPE0x01 +#define BLE_AUDIO_CODEC_FRAME_DURATION_TYPE 0x02 +#define BLE_AUDIO_CODEC_AUDIO_CHANNEL_ALLOCATION_TYPE 0x03 +#define BLE_AUDIO_CODEC_OCTETS_PER_CODEC_FRAME_TYPE 0x04 +#define BLE_AUDIO_CODEC_FRAME_BLOCKS_PER_SDU_TYPE 0x05 + +/** + * @brief Helper macro used to build LTV array of Codec_Specific_Configuration. + * + * @param _sampling_freq Sampling_Frequency - single octet value + * @param _frame_duration Frame_Duration - single octet value + * @param _audio_channel_alloc Audio_Channel_Allocation - + * four octet value + * @param _octets_per_codec_frame Octets_Per_Codec_Frame - + *
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
KKopyscinski commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1382997418 ## nimble/host/include/host/ble_audio_broadcast.h: ## @@ -0,0 +1,271 @@ +/* + * 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. + */ + +#ifndef H_BLE_AUDIO_BROADCAST_ +#define H_BLE_AUDIO_BROADCAST_ + +#include +#include "host/ble_gap.h" +#include "host/ble_iso.h" +#include "host/ble_audio_common.h" + +struct ble_broadcast_create_params { +/** BASE to broadcast */ +struct ble_audio_base *base; + +/** Parameters used to configure Extended advertising */ +struct ble_gap_ext_adv_params *extended_params; + +/** Parameters used to configure Periodic advertising */ +struct ble_gap_periodic_adv_params *periodic_params; + +/** Broadcast name - null terminated. + * Set NULL to not include in advertising + */ +const char *name; + +/** Advertising instance */ +uint8_t adv_instance; + +/** BIG parameters */ +struct ble_iso_big_params *big_params; + +/** Additional data to include in Extended Advertising */ +uint8_t *svc_data; + +/** Additional data length */ +uint16_t svc_data_len; +}; + +struct ble_broadcast_update_params { +/** Broadcast name - null terminated. + * Set NULL to not include in advertising + */ +const char *name; + +/** Advertising instance */ +uint8_t adv_instance; + +/** Additional data to include in Extended Advertising */ +uint8_t *svc_data; + +/** Additional data length */ +uint16_t svc_data_len; + +/** Broadcast ID */ +uint32_t broadcast_id; +}; + +typedef int ble_audio_broadcast_destroy_fn(struct ble_audio_base *base, + void *args); + +/** BASE configuration describing broadcast advertisement */ +struct ble_broadcast_base_config { +/** Advertising instance used by broadcast */ +uint8_t adv_instance; + +/** Pointer to BASE configuration */ +struct ble_audio_base *base; + +/** BIG parameters */ +struct ble_iso_big_params *big_params; + +/** + * Optional callback associated with broadcasting instance, called on + * destroying broadcast + */ +ble_audio_broadcast_destroy_fn *destroy_cb; + +/** Pointer to args for `destroy_cb` */ +void *args; +}; + +/** + * @brief Create Broadcast Audio Source Endpoint and configure advertising + * instance + * + * This function configures advertising instance for extended and periodic + * advertisements to be ready for broadcast with BASE configuration. + * + * @param[in] paramsPointer to a `ble_broadcast_base_params` + * structure that defines BASE, extended + * advertising and periodic advertising + * configuration. + * @param[out] config_out Pointer to a `ble_broadcast_base_config` + * structure to return configuration of created + * BASE advertisement. + * @param[in] destroy_cbOptional callback to be called when BASE + * advertisement is destroyed. + * @param[in] args Optional arguments to be passed to `destroy_cb` + * @param[in] gap_cbGAP event callback to be associated with BASE + * advertisement. + * + * @return 0 on success; + * A non-zero value on failure. + */ +int ble_audio_broadcast_create(const struct ble_broadcast_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); + +/** + * @brief Start advertisements for given BASE configuration + * + * This function starts BASE advertisement on by enabling extended and periodic + * advertising and creates BASE for this instance. + * + * @param[in] base_config Pointer to a `ble_broadcast_base_config` + * struct that shall be
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
KKopyscinski commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1382984104 ## nimble/host/include/host/ble_audio_broadcast.h: ## @@ -0,0 +1,271 @@ +/* + * 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. + */ + +#ifndef H_BLE_AUDIO_BROADCAST_ +#define H_BLE_AUDIO_BROADCAST_ + +#include +#include "host/ble_gap.h" +#include "host/ble_iso.h" +#include "host/ble_audio_common.h" + +struct ble_broadcast_create_params { +/** BASE to broadcast */ +struct ble_audio_base *base; + +/** Parameters used to configure Extended advertising */ +struct ble_gap_ext_adv_params *extended_params; + +/** Parameters used to configure Periodic advertising */ +struct ble_gap_periodic_adv_params *periodic_params; + +/** Broadcast name - null terminated. + * Set NULL to not include in advertising + */ +const char *name; + +/** Advertising instance */ +uint8_t adv_instance; + +/** BIG parameters */ +struct ble_iso_big_params *big_params; + +/** Additional data to include in Extended Advertising */ +uint8_t *svc_data; + +/** Additional data length */ +uint16_t svc_data_len; +}; + +struct ble_broadcast_update_params { +/** Broadcast name - null terminated. + * Set NULL to not include in advertising + */ +const char *name; + +/** Advertising instance */ +uint8_t adv_instance; + +/** Additional data to include in Extended Advertising */ +uint8_t *svc_data; + +/** Additional data length */ +uint16_t svc_data_len; + +/** Broadcast ID */ +uint32_t broadcast_id; +}; + +typedef int ble_audio_broadcast_destroy_fn(struct ble_audio_base *base, + void *args); + +/** BASE configuration describing broadcast advertisement */ +struct ble_broadcast_base_config { +/** Advertising instance used by broadcast */ +uint8_t adv_instance; + +/** Pointer to BASE configuration */ +struct ble_audio_base *base; + +/** BIG parameters */ +struct ble_iso_big_params *big_params; + +/** + * Optional callback associated with broadcasting instance, called on + * destroying broadcast + */ +ble_audio_broadcast_destroy_fn *destroy_cb; + +/** Pointer to args for `destroy_cb` */ +void *args; +}; + +/** + * @brief Create Broadcast Audio Source Endpoint and configure advertising + * instance + * + * This function configures advertising instance for extended and periodic + * advertisements to be ready for broadcast with BASE configuration. + * + * @param[in] paramsPointer to a `ble_broadcast_base_params` + * structure that defines BASE, extended + * advertising and periodic advertising + * configuration. + * @param[out] config_out Pointer to a `ble_broadcast_base_config` + * structure to return configuration of created + * BASE advertisement. + * @param[in] destroy_cbOptional callback to be called when BASE + * advertisement is destroyed. + * @param[in] args Optional arguments to be passed to `destroy_cb` Review Comment: Anything you need, it's a void pointer, app will cast it back to type it needs. Intention is, that for applications using dynamic memory allocation (like mempool) for BASE, BIG subgroups, BISes etc. this could be used as a pointer to to these things, and then app can free these resources. You can see that in `btshell_broadcast_destroy_fn` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
KKopyscinski commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1382973344 ## nimble/host/src/ble_iso.c: ## @@ -0,0 +1,369 @@ +/* + * 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 +#include "syscfg/syscfg.h" + +#if MYNEWT_VAL(BLE_ISO) + +#include "os/os_mbuf.h" +#include "host/ble_hs_log.h" +#include "host/ble_hs.h" +#include "host/ble_iso.h" +#include "nimble/hci_common.h" +#include "sys/queue.h" +#include "ble_hs_hci_priv.h" + +struct ble_iso_big { +SLIST_ENTRY(ble_iso_big) next; +uint8_t id; +uint16_t max_pdu; +uint8_t num_bis; +uint16_t conn_handles[MYNEWT_VAL(BLE_MAX_BIS)]; + +ble_iso_event_fn *cb; +void *cb_arg; +}; + +static SLIST_HEAD(, ble_iso_big) ble_iso_bigs; +static struct os_mempool ble_iso_big_pool; +static os_membuf_t ble_iso_big_mem[ +OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_MAX_BIG), sizeof (struct ble_iso_big))]; + +static struct ble_iso_big * +ble_iso_big_alloc(uint16_t adv_handle) Review Comment: yes :) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
kolodgrz commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1382918409 ## nimble/host/include/host/ble_audio_broadcast.h: ## @@ -0,0 +1,271 @@ +/* + * 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. + */ + +#ifndef H_BLE_AUDIO_BROADCAST_ +#define H_BLE_AUDIO_BROADCAST_ + +#include +#include "host/ble_gap.h" +#include "host/ble_iso.h" +#include "host/ble_audio_common.h" + +struct ble_broadcast_create_params { +/** BASE to broadcast */ +struct ble_audio_base *base; + +/** Parameters used to configure Extended advertising */ +struct ble_gap_ext_adv_params *extended_params; + +/** Parameters used to configure Periodic advertising */ +struct ble_gap_periodic_adv_params *periodic_params; + +/** Broadcast name - null terminated. + * Set NULL to not include in advertising + */ +const char *name; + +/** Advertising instance */ +uint8_t adv_instance; + +/** BIG parameters */ +struct ble_iso_big_params *big_params; + +/** Additional data to include in Extended Advertising */ +uint8_t *svc_data; + +/** Additional data length */ +uint16_t svc_data_len; +}; + +struct ble_broadcast_update_params { +/** Broadcast name - null terminated. + * Set NULL to not include in advertising + */ +const char *name; + +/** Advertising instance */ +uint8_t adv_instance; + +/** Additional data to include in Extended Advertising */ +uint8_t *svc_data; + +/** Additional data length */ +uint16_t svc_data_len; + +/** Broadcast ID */ +uint32_t broadcast_id; +}; + +typedef int ble_audio_broadcast_destroy_fn(struct ble_audio_base *base, + void *args); + +/** BASE configuration describing broadcast advertisement */ +struct ble_broadcast_base_config { +/** Advertising instance used by broadcast */ +uint8_t adv_instance; + +/** Pointer to BASE configuration */ +struct ble_audio_base *base; + +/** BIG parameters */ +struct ble_iso_big_params *big_params; + +/** + * Optional callback associated with broadcasting instance, called on + * destroying broadcast + */ +ble_audio_broadcast_destroy_fn *destroy_cb; + +/** Pointer to args for `destroy_cb` */ +void *args; +}; + +/** + * @brief Create Broadcast Audio Source Endpoint and configure advertising + * instance + * + * This function configures advertising instance for extended and periodic + * advertisements to be ready for broadcast with BASE configuration. + * + * @param[in] paramsPointer to a `ble_broadcast_base_params` + * structure that defines BASE, extended + * advertising and periodic advertising + * configuration. + * @param[out] config_out Pointer to a `ble_broadcast_base_config` + * structure to return configuration of created + * BASE advertisement. + * @param[in] destroy_cbOptional callback to be called when BASE + * advertisement is destroyed. + * @param[in] args Optional arguments to be passed to `destroy_cb` Review Comment: I mean args for destroy_cb :) ## nimble/host/include/host/ble_audio_broadcast.h: ## @@ -0,0 +1,271 @@ +/* + * 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
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
kolodgrz commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1382916529 ## nimble/host/src/ble_iso.c: ## @@ -0,0 +1,369 @@ +/* + * 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 +#include "syscfg/syscfg.h" + +#if MYNEWT_VAL(BLE_ISO) + +#include "os/os_mbuf.h" +#include "host/ble_hs_log.h" +#include "host/ble_hs.h" +#include "host/ble_iso.h" +#include "nimble/hci_common.h" +#include "sys/queue.h" +#include "ble_hs_hci_priv.h" + +struct ble_iso_big { +SLIST_ENTRY(ble_iso_big) next; +uint8_t id; +uint16_t max_pdu; +uint8_t num_bis; +uint16_t conn_handles[MYNEWT_VAL(BLE_MAX_BIS)]; + +ble_iso_event_fn *cb; +void *cb_arg; +}; + +static SLIST_HEAD(, ble_iso_big) ble_iso_bigs; +static struct os_mempool ble_iso_big_pool; +static os_membuf_t ble_iso_big_mem[ +OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_MAX_BIG), sizeof (struct ble_iso_big))]; + +static struct ble_iso_big * +ble_iso_big_alloc(uint16_t adv_handle) +{ +struct ble_iso_big *new_big; +struct ble_iso_big *big; + +if (adv_handle >= BLE_ADV_INSTANCES) { +BLE_HS_LOG_ERROR("Invalid advertising instance"); +return NULL; +} + +if (!ble_gap_ext_adv_active(adv_handle)) { +BLE_HS_LOG_ERROR("Instance not active"); +return NULL; +} + +new_big = os_memblock_get(_iso_big_pool); +if (new_big == NULL) { +BLE_HS_LOG_ERROR("No more memory in pool"); +/* Out of memory. */ +return NULL; +} + +memset(new_big, 0, sizeof *new_big); + +SLIST_FOREACH(big, _iso_bigs, next) { +if (big->id == adv_handle) { +BLE_HS_LOG_ERROR("Advertising instance (%d) already in use", + adv_handle); +return NULL; +} +} + +new_big->id = adv_handle; + +if (SLIST_EMPTY(_iso_bigs)) { +SLIST_INSERT_HEAD(_iso_bigs, new_big, next); +} else { +SLIST_INSERT_AFTER(big, new_big, next); +} + +return new_big; +} + +static struct ble_iso_big * +ble_iso_big_find_by_id(uint8_t big_id) +{ +struct ble_iso_big *big; + +SLIST_FOREACH(big, _iso_bigs, next) { +if (big->id == big_id) { +return big; +} +} + +return NULL; +} + +static int +ble_iso_big_free(struct ble_iso_big *big) +{ +SLIST_REMOVE(_iso_bigs, big, ble_iso_big, next); +os_memblock_put(_iso_big_pool, big); +return 0; +} + +int +ble_iso_create_big(const struct ble_iso_create_big_params *create_params, + const struct ble_iso_big_params *big_params) +{ +struct ble_hci_le_create_big_cp cp = { 0 }; +struct ble_iso_big *big; + +big = ble_iso_big_alloc(create_params->adv_handle); +if (big == NULL) { +return BLE_HS_ENOENT; +} + +big->cb = create_params->cb; +big->cb_arg = create_params->cb_arg; + +cp.big_handle = create_params->adv_handle; + +cp.adv_handle = create_params->adv_handle; +if (create_params->bis_cnt > MYNEWT_VAL(BLE_MAX_BIS)) { +return BLE_HS_EINVAL; +} + +cp.num_bis = create_params->bis_cnt; +put_le24(cp.sdu_interval, big_params->sdu_interval); +cp.max_sdu = big_params->max_sdu; +cp.max_transport_latency = big_params->max_transport_latency; +cp.rtn = big_params->rtn; +cp.phy = big_params->phy; +cp.packing = big_params->packing; +cp.framing = big_params->framing; +cp.encryption = big_params->encryption; +if (big_params->encryption) { +memcpy(cp.broadcast_code, big_params->broadcast_code, 16); +} + +return ble_hs_hci_cmd_tx(BLE_HCI_OP(BLE_HCI_OGF_LE, +BLE_HCI_OCF_LE_CREATE_BIG), + , sizeof(cp),NULL, 0); +} + +int +ble_iso_terminate_big(uint8_t big_id) +{ +struct ble_hci_le_terminate_big_cp cp; +struct ble_iso_big *big; +int rc; + +big = ble_iso_big_find_by_id(big_id); +if (big == NULL) { +BLE_HS_LOG_ERROR("No BIG with id=%d\n", big_id); +return BLE_HS_ENOENT; +} + +cp.big_handle = big->id; +cp.reason = BLE_ERR_CONN_TERM_LOCAL; + +rc = ble_hs_hci_cmd_tx(BLE_HCI_OP(BLE_HCI_OGF_LE, +
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
kolodgrz commented on code in PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#discussion_r1382910427 ## nimble/host/src/ble_iso.c: ## @@ -0,0 +1,369 @@ +/* + * 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 +#include "syscfg/syscfg.h" + +#if MYNEWT_VAL(BLE_ISO) + +#include "os/os_mbuf.h" +#include "host/ble_hs_log.h" +#include "host/ble_hs.h" +#include "host/ble_iso.h" +#include "nimble/hci_common.h" +#include "sys/queue.h" +#include "ble_hs_hci_priv.h" + +struct ble_iso_big { +SLIST_ENTRY(ble_iso_big) next; +uint8_t id; +uint16_t max_pdu; +uint8_t num_bis; +uint16_t conn_handles[MYNEWT_VAL(BLE_MAX_BIS)]; + +ble_iso_event_fn *cb; +void *cb_arg; +}; + +static SLIST_HEAD(, ble_iso_big) ble_iso_bigs; +static struct os_mempool ble_iso_big_pool; +static os_membuf_t ble_iso_big_mem[ +OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_MAX_BIG), sizeof (struct ble_iso_big))]; + +static struct ble_iso_big * +ble_iso_big_alloc(uint16_t adv_handle) Review Comment: Advertising handle shouldn't be 8bit ? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] nimble/host: Initial Broadcast Source implementation [mynewt-nimble]
KKopyscinski commented on PR #1619: URL: https://github.com/apache/mynewt-nimble/pull/1619#issuecomment-1794284307 > Initial Broadcast Source Implementation ? Changed in commit messages and PR title -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org