hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * BlueALSA - rfcomm.h
 * Copyright (c) 2016-2018 Arkadiusz Bokowy
 *
 * This file is a part of bluez-alsa.
 *
 * This project is licensed under the terms of the MIT license.
 *
 */
 
#ifndef BLUEALSA_RFCOMM_H_
#define BLUEALSA_RFCOMM_H_
 
#include "at.h"
#include "hfp.h"
#include "transport.h"
 
/* Number of retries during the SLC stage. */
#define RFCOMM_SLC_RETRIES 10
/* Timeout for the command acknowledgment. */
#define RFCOMM_SLC_TIMEOUT 1000
 
/**
 * Structure used for RFCOMM state synchronization. */
struct rfcomm_conn {
 
   /* service level connection state */
   enum hfp_state state;
   enum hfp_state state_prev;
 
   /* handler used for sync response dispatching */
   const struct rfcomm_handler *handler;
 
   /* number of failed communication attempts */
   int retries;
 
   /* 0-based indicators index */
   enum hfp_ind hfp_ind_map[20];
 
   /* variables used for AG<->HF sync */
   uint8_t spk_gain;
   uint8_t mic_gain;
 
   /* associated transport */
   struct ba_transport *t;
 
};
 
/**
 * Callback function used for RFCOMM AT message dispatching. */
typedef int rfcomm_callback(struct rfcomm_conn *c, const struct bt_at *at);
 
/**
 * AT message dispatching handler. */
struct rfcomm_handler {
   enum bt_at_type type;
   const char *command;
   rfcomm_callback *callback;
};
 
void *rfcomm_thread(void *arg);
 
#endif