LCOV - code coverage report
Current view: top level - zephyr/bluetooth/classic - hfp_ag.h Hit Total Coverage
Test: new.info Lines: 26 30 86.7 %
Date: 2024-12-22 00:14:23

          Line data    Source code
       1           1 : /** @file
       2             :  *  @brief Handsfree Profile Audio Gateway handling.
       3             :  */
       4             : 
       5             : /*
       6             :  * Copyright (c) 2015-2016 Intel Corporation
       7             :  * Copyright 2023-2024 NXP
       8             :  *
       9             :  * SPDX-License-Identifier: Apache-2.0
      10             :  */
      11             : #ifndef ZEPHYR_INCLUDE_BLUETOOTH_HFP_AG_H_
      12             : #define ZEPHYR_INCLUDE_BLUETOOTH_HFP_AG_H_
      13             : 
      14             : /**
      15             :  * @brief Hands Free Profile - Audio Gateway (HFP-AG)
      16             :  * @defgroup bt_hfp_ag Hands Free Profile - Audio Gateway (HFP-AG)
      17             :  * @ingroup bluetooth
      18             :  * @{
      19             :  */
      20             : 
      21             : #include <zephyr/bluetooth/bluetooth.h>
      22             : 
      23             : #ifdef __cplusplus
      24             : extern "C" {
      25             : #endif
      26             : 
      27             : /* HFP AG Indicators */
      28           0 : enum bt_hfp_ag_indicator {
      29             :         BT_HFP_AG_SERVICE_IND = 0,    /* Service availability indicator */
      30             :         BT_HFP_AG_CALL_IND = 1,       /* call status indicator */
      31             :         BT_HFP_AG_CALL_SETUP_IND = 2, /* Call set up status indicator */
      32             :         BT_HFP_AG_CALL_HELD_IND = 3,  /* Call hold status indicator */
      33             :         BT_HFP_AG_SIGNAL_IND = 4,    /* Signal strength indicator */
      34             :         BT_HFP_AG_ROAM_IND = 5,       /* Roaming status indicator */
      35             :         BT_HFP_AG_BATTERY_IND = 6,    /* Battery change indicator */
      36             :         BT_HFP_AG_IND_MAX             /* Indicator MAX value */
      37             : };
      38             : 
      39             : /* HFP CODEC */
      40           0 : #define BT_HFP_AG_CODEC_CVSD    0x01
      41           0 : #define BT_HFP_AG_CODEC_MSBC    0x02
      42           0 : #define BT_HFP_AG_CODEC_LC3_SWB 0x03
      43             : 
      44             : struct bt_hfp_ag;
      45             : 
      46             : /** @brief HFP profile AG application callback */
      47           1 : struct bt_hfp_ag_cb {
      48             :         /** HF AG connected callback to application
      49             :          *
      50             :          *  If this callback is provided it will be called whenever the
      51             :          *  AG connection completes.
      52             :          *
      53             :          *  @param ag HFP AG object.
      54             :          */
      55           1 :         void (*connected)(struct bt_hfp_ag *ag);
      56             :         /** HF disconnected callback to application
      57             :          *
      58             :          *  If this callback is provided it will be called whenever the
      59             :          *  connection gets disconnected, including when a connection gets
      60             :          *  rejected or cancelled or any error in SLC establishment.
      61             :          *
      62             :          *  @param ag HFP AG object.
      63             :          */
      64           1 :         void (*disconnected)(struct bt_hfp_ag *ag);
      65             :         /** HF SCO/eSCO connected Callback
      66             :          *
      67             :          *  If this callback is provided it will be called whenever the
      68             :          *  SCO/eSCO connection completes.
      69             :          *
      70             :          *  @param ag HFP AG object.
      71             :          *  @param sco_conn SCO/eSCO Connection object.
      72             :          */
      73           1 :         void (*sco_connected)(struct bt_hfp_ag *ag, struct bt_conn *sco_conn);
      74             :         /** HF SCO/eSCO disconnected Callback
      75             :          *
      76             :          *  If this callback is provided it will be called whenever the
      77             :          *  SCO/eSCO connection gets disconnected.
      78             :          *
      79             :          *  @param ag HFP AG object.
      80             :          *  @param sco_conn SCO/eSCO Connection object.
      81             :          */
      82           1 :         void (*sco_disconnected)(struct bt_hfp_ag *ag);
      83             : 
      84             :         /** HF memory dialing request Callback
      85             :          *
      86             :          *  If this callback is provided it will be called whenever a
      87             :          *  new call is requested with memory dialing from HFP unit.
      88             :          *  Get the phone number according to the given AG memory location.
      89             :          *
      90             :          *  @param ag HFP AG object.
      91             :          *  @param location AG memory location
      92             :          *  @param number Dailing number
      93             :          *
      94             :          *  @return 0 in case of success or negative value in case of error.
      95             :          */
      96           1 :         int (*memory_dial)(struct bt_hfp_ag *ag, const char *location, char **number);
      97             : 
      98             :         /** HF outgoing Callback
      99             :          *
     100             :          *  If this callback is provided it will be called whenever a
     101             :          *  new call is outgoing.
     102             :          *
     103             :          *  @param ag HFP AG object.
     104             :          *  @param number Dailing number
     105             :          */
     106           1 :         void (*outgoing)(struct bt_hfp_ag *ag, const char *number);
     107             : 
     108             :         /** HF incoming Callback
     109             :          *
     110             :          *  If this callback is provided it will be called whenever a
     111             :          *  new call is incoming.
     112             :          *
     113             :          *  @param ag HFP AG object.
     114             :          *  @param number Incoming number
     115             :          */
     116           1 :         void (*incoming)(struct bt_hfp_ag *ag, const char *number);
     117             : 
     118             :         /** HF ringing Callback
     119             :          *
     120             :          *  If this callback is provided it will be called whenever the
     121             :          *  call is in the ringing
     122             :          *
     123             :          *  @param ag HFP AG object.
     124             :          *  @param in_bond true - in-bond ringing, false - No in-bond ringing
     125             :          */
     126           1 :         void (*ringing)(struct bt_hfp_ag *ag, bool in_band);
     127             : 
     128             :         /** HF call accept Callback
     129             :          *
     130             :          *  If this callback is provided it will be called whenever the
     131             :          *  call is accepted.
     132             :          *
     133             :          *  @param ag HFP AG object.
     134             :          */
     135           1 :         void (*accept)(struct bt_hfp_ag *ag);
     136             : 
     137             :         /** HF call reject Callback
     138             :          *
     139             :          *  If this callback is provided it will be called whenever the
     140             :          *  call is rejected.
     141             :          *
     142             :          *  @param ag HFP AG object.
     143             :          */
     144           1 :         void (*reject)(struct bt_hfp_ag *ag);
     145             : 
     146             :         /** HF call terminate Callback
     147             :          *
     148             :          *  If this callback is provided it will be called whenever the
     149             :          *  call is terminated.
     150             :          *
     151             :          *  @param ag HFP AG object.
     152             :          */
     153           1 :         void (*terminate)(struct bt_hfp_ag *ag);
     154             : 
     155             :         /** Supported codec Ids callback
     156             :          *
     157             :          *  If this callback is provided it will be called whenever the
     158             :          *  supported codec ids are updated.
     159             :          *
     160             :          *  @param ag HFP AG object.
     161             :          */
     162           1 :         void (*codec)(struct bt_hfp_ag *ag, uint32_t ids);
     163             : };
     164             : 
     165             : /** @brief Register HFP AG profile
     166             :  *
     167             :  *  Register Handsfree profile AG callbacks to monitor the state and get the
     168             :  *  required HFP details to display.
     169             :  *
     170             :  *  @param cb callback structure.
     171             :  *
     172             :  *  @return 0 in case of success or negative value in case of error.
     173             :  */
     174           1 : int bt_hfp_ag_register(struct bt_hfp_ag_cb *cb);
     175             : 
     176             : /** @brief Create the hfp ag session
     177             :  *
     178             :  *  Create the hfp ag session
     179             :  *
     180             :  *  @param conn ACL connection object.
     181             :  *  @param ag Created HFP AG object.
     182             :  *  @param channel Peer rfcomm channel to be connected.
     183             :  *
     184             :  *  @return 0 in case of success or negative value in case of error.
     185             :  */
     186           1 : int bt_hfp_ag_connect(struct bt_conn *conn, struct bt_hfp_ag **ag, uint8_t channel);
     187             : 
     188             : /** @brief Disconnect the hfp ag session
     189             :  *
     190             :  *  Disconnect the hfp ag session
     191             :  *
     192             :  *  @param ag HFP AG object.
     193             :  *
     194             :  *  @return 0 in case of success or negative value in case of error.
     195             :  */
     196           1 : int bt_hfp_ag_disconnect(struct bt_hfp_ag *ag);
     197             : 
     198             : /** @brief Notify HFP Unit of an incoming call
     199             :  *
     200             :  *  Notify HFP Unit of an incoming call.
     201             :  *
     202             :  *  @param ag HFP AG object.
     203             :  *  @param number Dailing number.
     204             :  *
     205             :  *  @return 0 in case of success or negative value in case of error.
     206             :  */
     207           1 : int bt_hfp_ag_remote_incoming(struct bt_hfp_ag *ag, const char *number);
     208             : 
     209             : /** @brief Reject the incoming call
     210             :  *
     211             :  *  Reject the incoming call.
     212             :  *
     213             :  *  @param ag HFP AG object.
     214             :  *
     215             :  *  @return 0 in case of success or negative value in case of error.
     216             :  */
     217           1 : int bt_hfp_ag_reject(struct bt_hfp_ag *ag);
     218             : 
     219             : /** @brief Accept the incoming call
     220             :  *
     221             :  *  Accept the incoming call.
     222             :  *
     223             :  *  @param ag HFP AG object.
     224             :  *
     225             :  *  @return 0 in case of success or negative value in case of error.
     226             :  */
     227           1 : int bt_hfp_ag_accept(struct bt_hfp_ag *ag);
     228             : 
     229             : /** @brief Terminate the active/hold call
     230             :  *
     231             :  *  Terminate the active/hold call.
     232             :  *
     233             :  *  @param ag HFP AG object.
     234             :  *
     235             :  *  @return 0 in case of success or negative value in case of error.
     236             :  */
     237           1 : int bt_hfp_ag_terminate(struct bt_hfp_ag *ag);
     238             : 
     239             : /** @brief Dial a call
     240             :  *
     241             :  *  Dial a call.
     242             :  *
     243             :  *  @param ag HFP AG object.
     244             :  *  @param number Dailing number.
     245             :  *
     246             :  *  @return 0 in case of success or negative value in case of error.
     247             :  */
     248           1 : int bt_hfp_ag_outgoing(struct bt_hfp_ag *ag, const char *number);
     249             : 
     250             : /** @brief Notify HFP Unit that the remote starts ringing
     251             :  *
     252             :  *  Notify HFP Unit that the remote starts ringing.
     253             :  *
     254             :  *  @param ag HFP AG object.
     255             :  *
     256             :  *  @return 0 in case of success or negative value in case of error.
     257             :  */
     258           1 : int bt_hfp_ag_remote_ringing(struct bt_hfp_ag *ag);
     259             : 
     260             : /** @brief Notify HFP Unit that the remote rejects the call
     261             :  *
     262             :  *  Notify HFP Unit that the remote rejects the call.
     263             :  *
     264             :  *  @param ag HFP AG object.
     265             :  *
     266             :  *  @return 0 in case of success or negative value in case of error.
     267             :  */
     268           1 : int bt_hfp_ag_remote_reject(struct bt_hfp_ag *ag);
     269             : 
     270             : /** @brief Notify HFP Unit that the remote accepts the call
     271             :  *
     272             :  *  Notify HFP Unit that the remote accepts the call.
     273             :  *
     274             :  *  @param ag HFP AG object.
     275             :  *
     276             :  *  @return 0 in case of success or negative value in case of error.
     277             :  */
     278           1 : int bt_hfp_ag_remote_accept(struct bt_hfp_ag *ag);
     279             : 
     280             : /** @brief Notify HFP Unit that the remote terminates the active/hold call
     281             :  *
     282             :  *  Notify HFP Unit that the remote terminates the active/hold call.
     283             :  *
     284             :  *  @param ag HFP AG object.
     285             :  *
     286             :  *  @return 0 in case of success or negative value in case of error.
     287             :  */
     288           1 : int bt_hfp_ag_remote_terminate(struct bt_hfp_ag *ag);
     289             : 
     290             : #ifdef __cplusplus
     291             : }
     292             : #endif
     293             : 
     294             : /**
     295             :  * @}
     296             :  */
     297             : 
     298             : #endif /* ZEPHYR_INCLUDE_BLUETOOTH_HFP_HF_H_ */

Generated by: LCOV version 1.14