xref: /btstack/src/btstack_control.h (revision af3c1ffe4cfe13a87f9b14ce6dfb14e882ab3b69)
1*af3c1ffeSMatthias Ringwald /*
2*af3c1ffeSMatthias Ringwald  * Copyright (C) 2014 BlueKitchen GmbH
3*af3c1ffeSMatthias Ringwald  *
4*af3c1ffeSMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
5*af3c1ffeSMatthias Ringwald  * modification, are permitted provided that the following conditions
6*af3c1ffeSMatthias Ringwald  * are met:
7*af3c1ffeSMatthias Ringwald  *
8*af3c1ffeSMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
9*af3c1ffeSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
10*af3c1ffeSMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
11*af3c1ffeSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
12*af3c1ffeSMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
13*af3c1ffeSMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
14*af3c1ffeSMatthias Ringwald  *    contributors may be used to endorse or promote products derived
15*af3c1ffeSMatthias Ringwald  *    from this software without specific prior written permission.
16*af3c1ffeSMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
17*af3c1ffeSMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
18*af3c1ffeSMatthias Ringwald  *    monetary gain.
19*af3c1ffeSMatthias Ringwald  *
20*af3c1ffeSMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21*af3c1ffeSMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22*af3c1ffeSMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23*af3c1ffeSMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
24*af3c1ffeSMatthias Ringwald  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25*af3c1ffeSMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26*af3c1ffeSMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27*af3c1ffeSMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28*af3c1ffeSMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29*af3c1ffeSMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30*af3c1ffeSMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31*af3c1ffeSMatthias Ringwald  * SUCH DAMAGE.
32*af3c1ffeSMatthias Ringwald  *
33*af3c1ffeSMatthias Ringwald  * Please inquire about commercial licensing options at
34*af3c1ffeSMatthias Ringwald  * [email protected]
35*af3c1ffeSMatthias Ringwald  *
36*af3c1ffeSMatthias Ringwald  */
37*af3c1ffeSMatthias Ringwald 
38*af3c1ffeSMatthias Ringwald /*
39*af3c1ffeSMatthias Ringwald  *  bt_control.h
40*af3c1ffeSMatthias Ringwald  *
41*af3c1ffeSMatthias Ringwald  *  BT Control API -- allows BT Daemon to initialize and control differnt hardware
42*af3c1ffeSMatthias Ringwald  *
43*af3c1ffeSMatthias Ringwald  *  Created by Matthias Ringwald on 5/19/09.
44*af3c1ffeSMatthias Ringwald  *
45*af3c1ffeSMatthias Ringwald  */
46*af3c1ffeSMatthias Ringwald 
47*af3c1ffeSMatthias Ringwald #ifndef __BT_CONTROL_H
48*af3c1ffeSMatthias Ringwald #define __BT_CONTROL_H
49*af3c1ffeSMatthias Ringwald 
50*af3c1ffeSMatthias Ringwald #include <stdint.h>
51*af3c1ffeSMatthias Ringwald #include "utils.h"
52*af3c1ffeSMatthias Ringwald 
53*af3c1ffeSMatthias Ringwald #if defined __cplusplus
54*af3c1ffeSMatthias Ringwald extern "C" {
55*af3c1ffeSMatthias Ringwald #endif
56*af3c1ffeSMatthias Ringwald 
57*af3c1ffeSMatthias Ringwald typedef enum {
58*af3c1ffeSMatthias Ringwald     POWER_WILL_SLEEP = 1,
59*af3c1ffeSMatthias Ringwald     POWER_WILL_WAKE_UP
60*af3c1ffeSMatthias Ringwald } POWER_NOTIFICATION_t;
61*af3c1ffeSMatthias Ringwald 
62*af3c1ffeSMatthias Ringwald typedef struct {
63*af3c1ffeSMatthias Ringwald     int          (*on)   (void *config);  // <-- turn BT module on and configure
64*af3c1ffeSMatthias Ringwald     int          (*off)  (void *config);  // <-- turn BT module off
65*af3c1ffeSMatthias Ringwald     int          (*sleep)(void *config);  // <-- put BT module to sleep    - only to be called after ON
66*af3c1ffeSMatthias Ringwald     int          (*wake) (void *config);  // <-- wake BT module from sleep - only to be called after SLEEP
67*af3c1ffeSMatthias Ringwald     int          (*valid)(void *config);  // <-- test if hardware can be supported
68*af3c1ffeSMatthias Ringwald     const char * (*name) (void *config);  // <-- return hardware name
69*af3c1ffeSMatthias Ringwald 
70*af3c1ffeSMatthias Ringwald     /** support for UART baud rate changes - cmd has to be stored in hci_cmd_buffer
71*af3c1ffeSMatthias Ringwald      * @return have command
72*af3c1ffeSMatthias Ringwald      */
73*af3c1ffeSMatthias Ringwald     int          (*baudrate_cmd)(void * config, uint32_t baudrate, uint8_t *hci_cmd_buffer);
74*af3c1ffeSMatthias Ringwald 
75*af3c1ffeSMatthias Ringwald     /** support custom init sequences after RESET command - cmd has to be stored in hci_cmd_buffer
76*af3c1ffeSMatthias Ringwald       * @return have command
77*af3c1ffeSMatthias Ringwald       */
78*af3c1ffeSMatthias Ringwald     int          (*next_cmd)(void *config, uint8_t * hci_cmd_buffer);
79*af3c1ffeSMatthias Ringwald 
80*af3c1ffeSMatthias Ringwald     void         (*register_for_power_notifications)(void (*cb)(POWER_NOTIFICATION_t event));
81*af3c1ffeSMatthias Ringwald 
82*af3c1ffeSMatthias Ringwald     void         (*hw_error)(void);
83*af3c1ffeSMatthias Ringwald 
84*af3c1ffeSMatthias Ringwald     /** support for vendor-specific way to set BD ADDR - cmd has to be stored in hci_cmd_buffer
85*af3c1ffeSMatthias Ringwald      * @return have command
86*af3c1ffeSMatthias Ringwald      */
87*af3c1ffeSMatthias Ringwald     int          (*set_bd_addr_cmd)(void * config, bd_addr_t addr, uint8_t *hci_cmd_buffer);
88*af3c1ffeSMatthias Ringwald 
89*af3c1ffeSMatthias Ringwald } bt_control_t;
90*af3c1ffeSMatthias Ringwald 
91*af3c1ffeSMatthias Ringwald #if defined __cplusplus
92*af3c1ffeSMatthias Ringwald }
93*af3c1ffeSMatthias Ringwald #endif
94*af3c1ffeSMatthias Ringwald 
95*af3c1ffeSMatthias Ringwald #endif // __BT_CONTROL_H
96