1 | /*
|
---|
2 | * Copyright (C) 2009 by Matthias Ringwald
|
---|
3 | *
|
---|
4 | * Redistribution and use in source and binary forms, with or without
|
---|
5 | * modification, are permitted provided that the following conditions
|
---|
6 | * are met:
|
---|
7 | *
|
---|
8 | * 1. Redistributions of source code must retain the above copyright
|
---|
9 | * notice, this list of conditions and the following disclaimer.
|
---|
10 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
11 | * notice, this list of conditions and the following disclaimer in the
|
---|
12 | * documentation and/or other materials provided with the distribution.
|
---|
13 | * 3. Neither the name of the copyright holders nor the names of
|
---|
14 | * contributors may be used to endorse or promote products derived
|
---|
15 | * from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD AND CONTRIBUTORS
|
---|
18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
---|
19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
---|
20 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
|
---|
21 | * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
---|
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
---|
24 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
---|
25 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
---|
27 | * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
28 | * SUCH DAMAGE.
|
---|
29 | *
|
---|
30 | */
|
---|
31 |
|
---|
32 | /*
|
---|
33 | * btstack.h
|
---|
34 | *
|
---|
35 | * Created by Matthias Ringwald on 7/1/09.
|
---|
36 | *
|
---|
37 | * BTstack client API
|
---|
38 | *
|
---|
39 | */
|
---|
40 |
|
---|
41 | #ifndef __BTSTACK_H
|
---|
42 | #define __BTSTACK_H
|
---|
43 |
|
---|
44 | #include <btstack/hci_cmds.h>
|
---|
45 | #include <btstack/run_loop.h>
|
---|
46 | #include <btstack/utils.h>
|
---|
47 |
|
---|
48 | #include "btstack-config.h"
|
---|
49 |
|
---|
50 | #include <stdint.h>
|
---|
51 |
|
---|
52 | #if defined __cplusplus
|
---|
53 | extern "C" {
|
---|
54 | #endif
|
---|
55 |
|
---|
56 | // Default TCP port for BTstack daemon
|
---|
57 | #ifndef BTSTACK_PORT
|
---|
58 | #define BTSTACK_PORT 13333
|
---|
59 | #endif
|
---|
60 |
|
---|
61 | // UNIX domain socket for BTstack */
|
---|
62 | #ifndef BTSTACK_UNIX
|
---|
63 | #define BTSTACK_UNIX "/tmp/BTstack"
|
---|
64 | #endif
|
---|
65 |
|
---|
66 | // packet handler
|
---|
67 | typedef void (*btstack_packet_handler_t) (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
---|
68 |
|
---|
69 | // optional: if called before bt_open, TCP socket is used instead of local unix socket
|
---|
70 | // note: address is not copied and must be valid during bt_open
|
---|
71 | void bt_use_tcp(const char * address, uint16_t port);
|
---|
72 |
|
---|
73 | // init BTstack library
|
---|
74 | int bt_open(void);
|
---|
75 |
|
---|
76 | // stop using BTstack library
|
---|
77 | int bt_close(void);
|
---|
78 |
|
---|
79 | // send hci cmd packet
|
---|
80 | int bt_send_cmd(const hci_cmd_t *cmd, ...);
|
---|
81 |
|
---|
82 | // register packet handler -- channel only valid for l2cap and rfcomm packets
|
---|
83 | // @returns old packet handler
|
---|
84 | btstack_packet_handler_t bt_register_packet_handler(btstack_packet_handler_t handler);
|
---|
85 |
|
---|
86 | void bt_send_acl(uint8_t * data, uint16_t len);
|
---|
87 |
|
---|
88 | void bt_send_l2cap(uint16_t local_cid, uint8_t *data, uint16_t len);
|
---|
89 | void bt_send_rfcomm(uint16_t rfcom_cid, uint8_t *data, uint16_t len);
|
---|
90 |
|
---|
91 | #if defined __cplusplus
|
---|
92 | }
|
---|
93 | #endif
|
---|
94 |
|
---|
95 | #endif // __BTSTACK_H
|
---|