12531c97eSMatthias Ringwald /* 22531c97eSMatthias Ringwald * Copyright (C) 2014 BlueKitchen GmbH 32531c97eSMatthias Ringwald * 42531c97eSMatthias Ringwald * Redistribution and use in source and binary forms, with or without 52531c97eSMatthias Ringwald * modification, are permitted provided that the following conditions 62531c97eSMatthias Ringwald * are met: 72531c97eSMatthias Ringwald * 82531c97eSMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 92531c97eSMatthias Ringwald * notice, this list of conditions and the following disclaimer. 102531c97eSMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 112531c97eSMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 122531c97eSMatthias Ringwald * documentation and/or other materials provided with the distribution. 132531c97eSMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 142531c97eSMatthias Ringwald * contributors may be used to endorse or promote products derived 152531c97eSMatthias Ringwald * from this software without specific prior written permission. 162531c97eSMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 172531c97eSMatthias Ringwald * personal benefit and not for any commercial purpose or for 182531c97eSMatthias Ringwald * monetary gain. 192531c97eSMatthias Ringwald * 202531c97eSMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 212531c97eSMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 222531c97eSMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23*2fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 24*2fca4dadSMilanka Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 252531c97eSMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 262531c97eSMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 272531c97eSMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 282531c97eSMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 292531c97eSMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 302531c97eSMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 312531c97eSMatthias Ringwald * SUCH DAMAGE. 322531c97eSMatthias Ringwald * 332531c97eSMatthias Ringwald * Please inquire about commercial licensing options at 342531c97eSMatthias Ringwald * contact@bluekitchen-gmbh.com 352531c97eSMatthias Ringwald * 362531c97eSMatthias Ringwald */ 372531c97eSMatthias Ringwald 382531c97eSMatthias Ringwald /* 392531c97eSMatthias Ringwald * btstack.h 402531c97eSMatthias Ringwald * 412531c97eSMatthias Ringwald * Created by Matthias Ringwald on 7/1/09. 422531c97eSMatthias Ringwald * 432531c97eSMatthias Ringwald * BTstack client API 442531c97eSMatthias Ringwald * 452531c97eSMatthias Ringwald */ 462531c97eSMatthias Ringwald 4780e33422SMatthias Ringwald #ifndef BTSTACK_CLIENT_H 4880e33422SMatthias Ringwald #define BTSTACK_CLIENT_H 492531c97eSMatthias Ringwald 502531c97eSMatthias Ringwald #include "bluetooth.h" 512531c97eSMatthias Ringwald #include "btstack_config.h" 52463a5e8dSMatthias Ringwald #include "btstack_event.h" 532531c97eSMatthias Ringwald #include "btstack_run_loop.h" 542531c97eSMatthias Ringwald #include "btstack_util.h" 552531c97eSMatthias Ringwald #include "daemon_cmds.h" 562531c97eSMatthias Ringwald #include "hci.h" 572531c97eSMatthias Ringwald #include "hci_cmd.h" 58e3f52bebSMatthias Ringwald #include "classic/spp_server.h" 592531c97eSMatthias Ringwald 602531c97eSMatthias Ringwald #include <stdint.h> 612531c97eSMatthias Ringwald 622531c97eSMatthias Ringwald #if defined __cplusplus 632531c97eSMatthias Ringwald extern "C" { 642531c97eSMatthias Ringwald #endif 652531c97eSMatthias Ringwald 662531c97eSMatthias Ringwald // Default TCP port for BTstack daemon 672531c97eSMatthias Ringwald #ifndef BTSTACK_PORT 682531c97eSMatthias Ringwald #define BTSTACK_PORT 13333 692531c97eSMatthias Ringwald #endif 702531c97eSMatthias Ringwald 712531c97eSMatthias Ringwald // UNIX domain socket for BTstack */ 722531c97eSMatthias Ringwald #ifndef BTSTACK_UNIX 732531c97eSMatthias Ringwald #define BTSTACK_UNIX "/tmp/BTstack" 742531c97eSMatthias Ringwald #endif 752531c97eSMatthias Ringwald 762531c97eSMatthias Ringwald // optional: if called before bt_open, TCP socket is used instead of local unix socket 772531c97eSMatthias Ringwald // note: address is not copied and must be valid during bt_open 782531c97eSMatthias Ringwald void bt_use_tcp(const char * address, uint16_t port); 792531c97eSMatthias Ringwald 802531c97eSMatthias Ringwald // init BTstack library 812531c97eSMatthias Ringwald int bt_open(void); 822531c97eSMatthias Ringwald 832531c97eSMatthias Ringwald // stop using BTstack library 842531c97eSMatthias Ringwald int bt_close(void); 852531c97eSMatthias Ringwald 862531c97eSMatthias Ringwald // send hci cmd packet 872531c97eSMatthias Ringwald int bt_send_cmd(const hci_cmd_t *cmd, ...); 882531c97eSMatthias Ringwald 892531c97eSMatthias Ringwald // register packet handler -- channel only valid for l2cap and rfcomm packets 902531c97eSMatthias Ringwald // @returns old packet handler 912531c97eSMatthias Ringwald btstack_packet_handler_t bt_register_packet_handler(btstack_packet_handler_t handler); 922531c97eSMatthias Ringwald 932531c97eSMatthias Ringwald void bt_send_acl(uint8_t * data, uint16_t len); 942531c97eSMatthias Ringwald 952531c97eSMatthias Ringwald void bt_send_l2cap(uint16_t local_cid, uint8_t *data, uint16_t len); 962531c97eSMatthias Ringwald void bt_send_rfcomm(uint16_t rfcom_cid, uint8_t *data, uint16_t len); 972531c97eSMatthias Ringwald 982531c97eSMatthias Ringwald #if defined __cplusplus 992531c97eSMatthias Ringwald } 1002531c97eSMatthias Ringwald #endif 1012531c97eSMatthias Ringwald 10280e33422SMatthias Ringwald #endif // BTSTACK_H 103