mesh: Add support for meshd to use RAW channel
[platform/upstream/bluez.git] / mesh / mesh-io.h
1 /*
2  *
3  *  BlueZ - Bluetooth protocol stack for Linux
4  *
5  *  Copyright (C) 2018  Intel Corporation. All rights reserved.
6  *
7  *
8  *  This library is free software; you can redistribute it and/or
9  *  modify it under the terms of the GNU Lesser General Public
10  *  License as published by the Free Software Foundation; either
11  *  version 2.1 of the License, or (at your option) any later version.
12  *
13  *  This library is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  *  Lesser General Public License for more details.
17  *
18  */
19
20 struct mesh_io;
21
22 #define MESH_IO_TX_COUNT_UNLIMITED      0
23
24 enum mesh_io_type {
25         MESH_IO_TYPE_NONE = 0,
26         MESH_IO_TYPE_GENERIC
27 };
28
29 enum mesh_io_timing_type {
30         MESH_IO_TIMING_TYPE_GENERAL = 1,
31         MESH_IO_TIMING_TYPE_POLL,
32         MESH_IO_TIMING_TYPE_POLL_RSP
33 };
34
35 struct mesh_io_recv_info {
36         const uint8_t *addr;
37         uint32_t instant;
38         uint8_t chan;
39         int8_t rssi;
40 };
41
42 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
43 struct mesh_io_opts {
44         int index;
45         bool use_raw;
46 };
47 #endif
48
49 struct mesh_io_send_info {
50         enum mesh_io_timing_type type;
51         union {
52                 struct {
53                         uint16_t interval;
54                         uint8_t cnt;
55                         uint8_t min_delay;
56                         uint8_t max_delay;
57                 } gen;
58
59                 struct {
60                         uint16_t scan_duration;
61                         uint8_t scan_delay;
62                         uint8_t filter_ids[2];
63                         uint8_t min_delay;
64                         uint8_t max_delay;
65                 } poll;
66
67                 struct {
68                         uint32_t instant;
69                         uint8_t delay;
70                 } poll_rsp;
71
72         } u;
73 };
74
75 struct mesh_io_caps {
76         uint8_t max_num_filters;
77         uint8_t window_accuracy;
78 };
79
80 typedef void (*mesh_io_recv_func_t)(void *user_data,
81                                         struct mesh_io_recv_info *info,
82                                         const uint8_t *data, uint16_t len);
83
84 typedef void (*mesh_io_recv_ext_func_t)(void *user_data,
85                                         struct mesh_io_recv_info *info,
86                                         const uint8_t *data, uint16_t len,
87                                         const uint8_t *addr);
88
89 typedef void (*mesh_io_ready_func_t)(void *user_data, bool result);
90
91 struct mesh_io *mesh_io_new(enum mesh_io_type type, void *opts,
92                                 mesh_io_ready_func_t cb, void *user_data);
93 void mesh_io_destroy(struct mesh_io *io);
94
95 bool mesh_io_get_caps(struct mesh_io *io, struct mesh_io_caps *caps);
96
97 bool mesh_io_register_recv_cb(struct mesh_io *io, const uint8_t *filter,
98                                         uint8_t len, mesh_io_recv_func_t cb,
99                                         void *user_data);
100
101 bool mesh_io_deregister_recv_cb(struct mesh_io *io, const uint8_t *filter,
102                                                                 uint8_t len);
103
104 bool mesh_io_send(struct mesh_io *io, struct mesh_io_send_info *info,
105                                         const uint8_t *data, uint16_t len);
106 bool mesh_io_send_cancel(struct mesh_io *io, const uint8_t *pattern,
107                                                                 uint8_t len);