KKopyscinski commented on code in PR #1691: URL: https://github.com/apache/mynewt-nimble/pull/1691#discussion_r1576090216
########## nimble/host/audio/services/bass/include/services/bass/ble_audio_svc_bass.h: ########## @@ -0,0 +1,450 @@ +/** + * 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_SVC_BASS_ +#define H_BLE_AUDIO_SVC_BASS_ + +#include <stdint.h> +#include "audio/ble_audio.h" +#include "syscfg/syscfg.h" + +/** + * @file ble_audio_svc_bass.h + * + * @brief Bluetooth LE Audio BAS Service + * + * This header file provides the public API for interacting with the BASS package. + * + * @defgroup ble_audio_svc_bass Bluetooth LE Audio BASS package + * @ingroup bt_host + * @{ + * + * This package implements BASS service. Receiver states can be modified with setter functions + * or GATT writes to Control Point characteristic. Operations on Control Point like Add Source or + * Modify Source can be accepted or rejected by application by registering accept function callback. + * Accessing Control Point characteristic, or Successful modification or Receiver State will lead to + * emission of one of BLE_SVC_AUDIO_BASS events. + * + */ + +/** BLE AUDIO BASS Maximum Subgroup Number */ +#define BLE_SVC_AUDIO_BASS_SUB_NUM_MAX \ + MYNEWT_VAL(BLE_SVC_AUDIO_BASS_SUB_NUM_MAX) + +/** BLE AUDIO BASS characteristic UUID */ +#define BLE_SVC_AUDIO_BASS_UUID16 0x184F + +/** BLE AUDIO BASS Control Point characteristic UUID */ +#define BLE_SVC_AUDIO_BASS_CHR_UUID16_BASS_CP 0x2BC7 + +/** BLE AUDIO BASS Broadcast Receiver State characteristic UUID */ +#define BLE_SVC_AUDIO_BASS_CHR_UUID16_BROADCAST_RECEIVE_STATE 0x2BC8 + +/** Value of not assigned Source ID of Receiver State */ +#define BLE_SVC_AUDIO_BASS_RECEIVE_STATE_SRC_ID_NONE 0xFF + +/** BLE AUDIO BASS Add Source operation OP code */ +#define BLE_SVC_AUDIO_BASS_OPERATION_ADD_SOURCE 0x01 + +/** BLE AUDIO BASS Modify Source operation OP code */ +#define BLE_SVC_AUDIO_BASS_OPERATION_MODIFY_SOURCE 0x02 + +/** BLE AUDIO BASS Remove Source operation OP code */ +#define BLE_SVC_AUDIO_BASS_OPERATION_REMOVE_SOURCE 0x03 + +/** BLE AUDIO BASS Error: OP Code not supported */ +#define BLE_SVC_AUDIO_BASS_ERR_OPCODE_NOT_SUPPORTED 0x80 + +/** BLE AUDIO BASS Error: Invalid Source ID */ +#define BLE_SVC_AUDIO_BASS_ERR_INVALID_SOURCE_ID 0x81 + +/** BLE AUDIO BASS Encryption States */ +enum ble_svc_audio_bass_big_enc { + /** BLE AUDIO BASS BIG Encryption: Not Encrypted */ + BLE_SVC_AUDIO_BASS_BIG_ENC_NOT_ENCRYPTED, + + /** BLE AUDIO BASS BIG Encryption: Broadcast Code Required */ + BLE_SVC_AUDIO_BASS_BIG_ENC_BROADCAST_CODE_REQ, + + /** BLE AUDIO BASS BIG Encryption: Decrypting */ + BLE_SVC_AUDIO_BASS_BIG_ENC_DECRYPTING, + + /** BLE AUDIO BASS BIG Encryption: Bad Code */ + BLE_SVC_AUDIO_BASS_BIG_ENC_BAD_CODE +}; + +/** BLE AUDIO BASS PA Sync parameters, valid fo Modify Source operation */ +enum ble_svc_audio_bass_pa_sync { + /** BLE AUDIO BASS PA Sync: Do not synchronize to PA */ + BLE_SVC_AUDIO_BASS_PA_SYNC_DO_NOT_SYNC, + + /** BLE AUDIO BASS PA Sync: Synchronize to PA – PAST available */ + BLE_SVC_AUDIO_BASS_PA_SYNC_SYNC_PAST_AVAILABLE, + + /** BLE AUDIO BASS PA Sync: Synchronize to PA – PAST not available */ + BLE_SVC_AUDIO_BASS_PA_SYNC_SYNC_PAST_NOT_AVAILABLE, + + /** + * BLE AUDIO BASS PA Sync: reserved for future use. + * This shall be always last value in this enum + */ + BLE_SVC_AUDIO_BASS_PA_SYNC_RFU +}; + +/** BLE AUDIO BASS Broadcast Receiver: PA Sync States */ +enum ble_svc_audio_bass_pa_sync_state { + /** BLE AUDIO BASS PA Sync State: Not synchronized to PA */ + BLE_SVC_AUDIO_BASS_PA_SYNC_STATE_NOT_SYNCED, + + /** BLE AUDIO BASS PA Sync State: SyncInfo Request */ + BLE_SVC_AUDIO_BASS_PA_SYNC_STATE_SYNC_INFO_REQ, + + /** BLE AUDIO BASS PA Sync State: Synchronized to PA */ + BLE_SVC_AUDIO_BASS_PA_SYNC_STATE_SYNCED, + + /** BLE AUDIO BASS PA Sync State: Failed to synchronize to PAA */ + BLE_SVC_AUDIO_BASS_PA_SYNC_STATE_SYNCED_FAILED, + + /** BLE AUDIO BASS PA Sync State: No PAST */ + BLE_SVC_AUDIO_BASS_PA_SYNC_STATE_NO_PAST +}; + +/** BLE AUDIO BASS Broadcast Receiver State: Subgroup entry */ +struct ble_svc_audio_bass_subgroup { + /** BLE AUDIO BASS Subgroup entry: Bis Synchronization State */ + uint32_t bis_sync_state; + + /** BLE AUDIO BASS Subgroup entry: Metadata length */ + uint8_t metadata_length; + + /** BLE AUDIO BASS Subgroup entry: Metadata */ + uint8_t *metadata; +}; + +/** BLE AUDIO BASS Broadcast Receiver State */ +struct ble_svc_audio_bass_receiver_state { + /** BLE AUDIO BASS Broadcast Receiver State: Source ID */ + uint8_t source_id; + + /** BLE AUDIO BASS Broadcast Receiver State: Source BLE Address */ + ble_addr_t source_addr; + + /** BLE AUDIO BASS Broadcast Receiver State: Source Advertising SID */ + uint8_t source_adv_sid; + + /** BLE AUDIO BASS Broadcast Receiver State: Broadcast ID */ + uint32_t broadcast_id; + + /** BLE AUDIO BASS Broadcast Receiver State: PA Sync state */ + enum ble_svc_audio_bass_pa_sync_state pa_sync_state; + + /** BLE AUDIO BASS Broadcast Receiver State: BIG Encryption */ + enum ble_svc_audio_bass_big_enc big_encryption; + + /** + * BLE AUDIO BASS Broadcast Receiver State: Bad Code. + * On GATT Read access, this value is ignored if big_encryption + * is not set to BLE_SVC_AUDIO_BASS_BIG_ENC_BAD_CODE + */ + uint8_t bad_code[BLE_AUDIO_BROADCAST_CODE_SIZE]; Review Comment: these are set from data received on control point - we cant make these const -- 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