rymanluk commented on code in PR #1708: URL: https://github.com/apache/mynewt-nimble/pull/1708#discussion_r1505867672
########## nimble/host/audio/src/ble_audio.c: ########## @@ -0,0 +1,524 @@ +/* + * 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 <string.h> +#include <stddef.h> + +#include "host/ble_hs.h" +#include "host/audio/ble_audio.h" + +#include "ble_audio_priv.h" + +static struct ble_gap_event_listener ble_audio_gap_event_listener; +static SLIST_HEAD(, ble_audio_event_listener) ble_audio_event_listener_list = + SLIST_HEAD_INITIALIZER(ble_audio_event_listener_list); + +struct ble_audio_adv_parse_bcst_announcement_data { + struct ble_audio_event event; + struct ble_audio_bcst_public pub; + struct ble_audio_bcst_name name; + bool success; +}; + +static int +ble_audio_adv_parse_bcst_announcement(const struct ble_hs_adv_field *field, + void *user_data) +{ + struct ble_audio_adv_parse_bcst_announcement_data *data = user_data; + struct ble_audio_event_bcst_announcement *event; + const uint8_t value_len = field->length - sizeof(field->length); + ble_uuid16_t uuid16 = BLE_UUID16_INIT(0); + uint8_t offset = 0; + + event = &data->event.bcst_announcement; + + switch (field->type) { + case BLE_HS_ADV_TYPE_SVC_DATA_UUID16: + if (value_len < 2) { + break; + } + + uuid16.value = get_le16(&field->value[offset]); + offset += 2; + + switch (uuid16.value) { + case BLE_BROADCAST_AUDIO_ANNOUNCEMENT_SVC_UUID: + if ((value_len - offset) < 3) { + /* Stop parsing */ Review Comment: agree with @KKopyscinski -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
