9
#include <drivers/bluetooth/bluetooth.h>
10
#include <drivers/bluetooth/btm/btm112.h>
11
#include <embox/unit.h>
13
EMBOX_UNIT_INIT(btm112_init);
15
CALLBACK_INIT(nxt_bt_rx_handle_t, bt_rx);
17
typedef int (*string_handler)(int len, void *data);
25
static const char *stamp[] = {
31
static int irq_hnd_wait_conn(int len, void *data);
32
static int irq_hnd_wait_lrlf(int len, void *data);
33
static int irq_hnd_wait_disconn(int len, void *data);
35
static string_handler str_hnds[] = {
41
static int rs_comm = 0;
44
static int set_state(int state_num) {
48
CALLBACK_REG(__bt_rx, str_hnds[state_num]);
53
static int general_handler(int cnt, void *data) {
54
uint8_t *buff = (uint8_t *) data;
57
if (*buff == stamp[rs_comm][rs_pos]) {
62
if (stamp[rs_comm][rs_pos] == 0) {
71
static int irq_hnd_wait_conn(int len, void *data) {
72
if (general_handler(len, data)) {
79
static int irq_hnd_wait_lrlf(int len, void *data) {
80
if (general_handler(len, data)) {
81
set_state(DISCONNECT_WAIT);
91
static int irq_hnd_wait_disconn(int len, void *data) {
92
if (general_handler(len, data)) {
93
set_state(CONNECT_WAIT);
98
CALLBACK(bt_rx)(len, data);
102
static int btm112_init(void) {
103
bluetooth_hw_hard_reset();
104
CALLBACK_REG(__bt_rx, irq_hnd_wait_conn);