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