Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sol-bluetooth.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Soletta (TM) Project
3  *
4  * Copyright (C) 2016 Intel Corporation. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #pragma once
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
52 #include <sol-network.h>
53 
66 };
67 
77 typedef struct sol_bt_uuid {
79  union {
80  uint16_t val16;
81  uint32_t val32;
82  uint8_t val128[16];
83  uint8_t val[0];
84  };
85 } sol_bt_uuid;
86 
95 int sol_bt_uuid_from_str(struct sol_bt_uuid *uuid, const struct sol_str_slice str);
96 
105 int sol_bt_uuid_to_str(const struct sol_bt_uuid *uuid, struct sol_buffer *buffer);
106 
118 bool sol_bt_uuid_eq(const struct sol_bt_uuid *u1, const struct sol_bt_uuid *u2);
119 
127 struct sol_bt_conn;
128 typedef struct sol_bt_conn sol_bt_conn;
129 
137 struct sol_bt_conn *sol_bt_conn_ref(struct sol_bt_conn *conn);
138 
147 void sol_bt_conn_unref(struct sol_bt_conn *conn);
148 
158  const struct sol_bt_conn *conn);
159 
176 struct sol_bt_conn *sol_bt_connect(const struct sol_network_link_addr *addr,
177  bool (*on_connect)(void *user_data, struct sol_bt_conn *conn),
178  void (*on_disconnect)(void *user_data, struct sol_bt_conn *conn),
179  void (*on_error)(void *user_data, int error),
180  const void *user_data);
181 
194 int sol_bt_disconnect(struct sol_bt_conn *conn);
195 
204 struct sol_bt_session;
206 
223  void (*on_enabled)(void *data, bool powered),
224  const void *user_data);
225 
239 
243 typedef struct sol_bt_device_info {
255  char *name;
259  int16_t rssi;
263  bool paired;
267  bool connected;
271  bool in_range;
273 
284 };
285 
294 const char *sol_bt_transport_to_str(enum sol_bt_transport transport);
295 
304 enum sol_bt_transport sol_bt_transport_from_str(const char *str);
305 
312 struct sol_bt_scan_pending;
314 
332  enum sol_bt_transport transport,
333  void (*on_found)(void *user_data, const struct sol_bt_device_info *device),
334  const void *user_data);
335 
343 int sol_bt_stop_scan(struct sol_bt_scan_pending *handle);
344 
349 #ifdef __cplusplus
350 }
351 #endif
void sol_bt_conn_unref(struct sol_bt_conn *conn)
Decreases the reference count of a connection.
Representation of a Bluetooth UUID.
Definition: sol-bluetooth.h:77
bool in_range
Whether the devices is currently in range.
Definition: sol-bluetooth.h:271
enum sol_bt_transport sol_bt_transport_from_str(const char *str)
Converts string to a transport,.
struct sol_bt_conn sol_bt_conn
Represents an active connection to a Bluetooth device.
Definition: sol-bluetooth.h:128
int16_t rssi
Received signal strength, measured in dBm.
Definition: sol-bluetooth.h:259
Discover devices over the Bluetooth Low Energy transport.
Definition: sol-bluetooth.h:279
static bool on_connect(void *user_data, struct sol_bt_conn *conn)
Definition: browse.c:91
uint8_t val128[16]
Definition: sol-bluetooth.h:82
const char * sol_bt_transport_to_str(enum sol_bt_transport transport)
Converts a transport to a string,.
int sol_bt_uuid_to_str(const struct sol_bt_uuid *uuid, struct sol_buffer *buffer)
Convert a string to a UUID.
uint32_t val32
Definition: sol-bluetooth.h:81
static void on_error(void *user_data, int error)
Definition: browse.c:39
sol_bt_uuid_type
Set of types of UUIDs.
Definition: sol-bluetooth.h:62
Represents a information about a remote device.
Definition: sol-bluetooth.h:243
struct sol_bt_scan_pending sol_bt_scan_pending
Represents a pending scan session.
Definition: sol-bluetooth.h:313
struct sol_bt_scan_pending * sol_bt_start_scan(enum sol_bt_transport transport, void(*on_found)(void *user_data, const struct sol_bt_device_info *device), const void *user_data)
Start scanning for devices.
String slice type.
Definition: sol-str-slice.h:84
Definition: sol-bluetooth.h:63
struct sol_bt_device_info sol_bt_device_info
Represents a information about a remote device.
uint16_t val16
Definition: sol-bluetooth.h:80
char * name
Friendly name of the device.
Definition: sol-bluetooth.h:255
Discover devices over All transports.
Definition: sol-bluetooth.h:283
int sol_bt_disconnect(struct sol_bt_conn *conn)
Terminates a connection, or connection attempt.
Discover devices over the Bluetooth Basic Rate transport.
Definition: sol-bluetooth.h:281
struct sol_bt_session sol_bt_session
Represents a Bluetooth usage session.
Definition: sol-bluetooth.h:205
struct sol_bt_conn * sol_bt_conn_ref(struct sol_bt_conn *conn)
Increases the reference count of a connection.
bool connected
Whether the device is connected.
Definition: sol-bluetooth.h:267
int sol_bt_uuid_from_str(struct sol_bt_uuid *uuid, const struct sol_str_slice str)
Convert a string to a UUID.
uint8_t val[0]
Definition: sol-bluetooth.h:83
sol_bt_transport
Over which transport should a scan be performed.
Definition: sol-bluetooth.h:277
struct sol_bt_conn * sol_bt_connect(const struct sol_network_link_addr *addr, bool(*on_connect)(void *user_data, struct sol_bt_conn *conn), void(*on_disconnect)(void *user_data, struct sol_bt_conn *conn), void(*on_error)(void *user_data, int error), const void *user_data)
Attempts to establish a connection with a remote device.
static void on_disconnect(void *user_data, struct sol_bt_conn *conn)
Definition: browse.c:107
int sol_bt_stop_scan(struct sol_bt_scan_pending *handle)
Stop a scanning session.
Definition: sol-bluetooth.h:65
bool sol_bt_uuid_eq(const struct sol_bt_uuid *u1, const struct sol_bt_uuid *u2)
Compare two UUIDs.
struct sol_bt_session * sol_bt_enable(void(*on_enabled)(void *data, bool powered), const void *user_data)
Enables the local Bluetooth controller.
Definition: sol-bluetooth.h:64
bool paired
Whether the device is paired.
Definition: sol-bluetooth.h:263
int sol_bt_disable(struct sol_bt_session *session)
Disables a session, returning the controller to its previous state.
Soletta vector is an array that grows dynamically.
Definition: sol-vector.h:58
enum sol_bt_uuid_type type
Definition: sol-bluetooth.h:78
A sol_buffer is a dynamic array, that can be resized if needed.
Definition: sol-buffer.h:130
static struct sol_bt_session * session
Definition: browse.c:31
struct sol_vector uuids
Vector of service UUIDs discovered, may be empty.
Definition: sol-bluetooth.h:251
struct sol_bt_uuid sol_bt_uuid
Representation of a Bluetooth UUID.
These are routines that Soletta provides for handling network link interfaces, making it possible to ...
const struct sol_network_link_addr * sol_bt_conn_get_addr(const struct sol_bt_conn *conn)
Returns the network address of the remote device.