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