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
Data Structures | Macros | Typedefs | Enumerations | Functions

API to handle Bluetooth technology communications. More...

Data Structures

struct  sol_bt_device_info
 Represents a information about a remote device. More...
 
struct  sol_bt_uuid
 Representation of a Bluetooth UUID. More...
 
struct  sol_gatt_attr
 Representation of a GATT Attribute. More...
 

Macros

#define SOL_GATT_ATTR_INVALID   { .type = SOL_GATT_ATTR_TYPE_INVALID }
 Terminates the list of attributes. More...
 
#define SOL_GATT_CHARACTERISTIC_UUID_16(_uuid, _flags,...)
 Helper to the construction of a GATT Characteristic with 16-bit UUID. More...
 
#define SOL_GATT_DESCRIPTOR_UUID_16(_uuid, _flags,...)
 Helper to the construction of a GATT Descriptor with 16-bit UUID. More...
 
#define SOL_GATT_SERVICE_UUID_16(service_uuid)
 Helper to the construction of a GATT Service with 16-bit UUID. More...
 

Typedefs

typedef struct sol_bt_conn sol_bt_conn
 Represents an active connection to a Bluetooth device. More...
 
typedef struct sol_bt_device_info sol_bt_device_info
 Represents a information about a remote device. More...
 
typedef struct sol_bt_scan_pending sol_bt_scan_pending
 Represents a pending scan session. More...
 
typedef struct sol_bt_session sol_bt_session
 Represents a Bluetooth usage session. More...
 
typedef struct sol_bt_uuid sol_bt_uuid
 Representation of a Bluetooth UUID. More...
 
typedef struct sol_gatt_attr sol_gatt_attr
 Representation of a GATT Attribute. More...
 
typedef struct sol_gatt_pending sol_gatt_pending
 Represents a pending request. More...
 

Enumerations

enum  sol_bt_transport { SOL_BT_TRANSPORT_LE = 1, SOL_BT_TRANSPORT_BREDR, SOL_BT_TRANSPORT_ALL = SOL_BT_TRANSPORT_LE | SOL_BT_TRANSPORT_BREDR }
 Over which transport should a scan be performed. More...
 
enum  sol_bt_uuid_type { SOL_BT_UUID_TYPE_16 = 2, SOL_BT_UUID_TYPE_32 = 4, SOL_BT_UUID_TYPE_128 = 16 }
 Set of types of UUIDs. More...
 
enum  sol_gatt_attr_type { SOL_GATT_ATTR_TYPE_INVALID, SOL_GATT_ATTR_TYPE_SERVICE, SOL_GATT_ATTR_TYPE_CHARACTERISTIC, SOL_GATT_ATTR_TYPE_DESCRIPTOR }
 Set of types of Attributes. More...
 
enum  sol_gatt_chr_flags {
  SOL_GATT_CHR_FLAGS_BROADCAST = (1 << 0), SOL_GATT_CHR_FLAGS_READ = (1 << 1), SOL_GATT_CHR_FLAGS_WRITE_WITHOUT_RESPONSE = (1 << 2), SOL_GATT_CHR_FLAGS_WRITE = (1 << 3),
  SOL_GATT_CHR_FLAGS_NOTIFY = (1 << 4), SOL_GATT_CHR_FLAGS_INDICATE = (1 << 5), SOL_GATT_CHR_FLAGS_AUTHENTICATED_SIGNED_WRITES = (1 << 6), SOL_GATT_CHR_FLAGS_RELIABLE_WRITE = (1 << 7),
  SOL_GATT_CHR_FLAGS_WRITABLE_AUXILIARIES = (1 << 8), SOL_GATT_CHR_FLAGS_ENCRYPT_READ = (1 << 9), SOL_GATT_CHR_FLAGS_ENCRYPT_WRITE = (1 << 10), SOL_GATT_CHR_FLAGS_ENCRYPT_AUTHENTICATED_READ = (1 << 11),
  SOL_GATT_CHR_FLAGS_ENCRYPT_AUTHENTICATED_WRITE = (1 << 12)
}
 Set of flags for Charateristic attributes. More...
 
enum  sol_gatt_desc_flags {
  SOL_GATT_DESC_FLAGS_READ = (1 << 0), SOL_GATT_DESC_FLAGS_WRITE = (1 << 1), SOL_GATT_DESC_FLAGS_ENCRYPT_READ = (1 << 2), SOL_GATT_DESC_FLAGS_ENCRYPT_WRITE = (1 << 3),
  SOL_GATT_DESC_FLAGS_ENCRYPT_AUTHENTICATED_READ = (1 << 4), SOL_GATT_DESC_FLAGS_ENCRYPT_AUTHENTICATED_WRITE = (1 << 5)
}
 Set of flags for Descriptor attributes. More...
 

Functions

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. More...
 
struct sol_bt_connsol_bt_conn_ref (struct sol_bt_conn *conn)
 Increases the reference count of a connection. More...
 
void sol_bt_conn_unref (struct sol_bt_conn *conn)
 Decreases the reference count of a connection. More...
 
struct sol_bt_connsol_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. More...
 
int sol_bt_disable (struct sol_bt_session *session)
 Disables a session, returning the controller to its previous state. More...
 
int sol_bt_disconnect (struct sol_bt_conn *conn)
 Terminates a connection, or connection attempt. More...
 
struct sol_bt_sessionsol_bt_enable (void(*on_enabled)(void *data, bool powered), const void *user_data)
 Enables the local Bluetooth controller. More...
 
struct sol_bt_scan_pendingsol_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. More...
 
int sol_bt_stop_scan (struct sol_bt_scan_pending *handle)
 Stop a scanning session. More...
 
enum sol_bt_transport sol_bt_transport_from_str (const char *str)
 Converts string to a transport,. More...
 
const char * sol_bt_transport_to_str (enum sol_bt_transport transport)
 Converts a transport to a string,. More...
 
bool sol_bt_uuid_eq (const struct sol_bt_uuid *u1, const struct sol_bt_uuid *u2)
 Compare two UUIDs. More...
 
int sol_bt_uuid_from_str (struct sol_bt_uuid *uuid, const struct sol_str_slice str)
 Convert a string to a UUID. More...
 
int sol_bt_uuid_to_str (const struct sol_bt_uuid *uuid, struct sol_buffer *buffer)
 Convert a string to a UUID. More...
 
int sol_gatt_discover (struct sol_bt_conn *conn, enum sol_gatt_attr_type type, const struct sol_gatt_attr *parent, const struct sol_bt_uuid *uuid, bool(*cb)(void *user_data, struct sol_bt_conn *conn, const struct sol_gatt_attr *attr), const void *user_data)
 Discover attributes by type, restricted by UUID and parent attribute. More...
 
int sol_gatt_indicate (struct sol_bt_conn *conn, const struct sol_gatt_attr *attr)
 Sends an indication to the device represented by conn. More...
 
int sol_gatt_notify (struct sol_bt_conn *conn, const struct sol_gatt_attr *attr)
 Sends a notificatiion to the device represented by conn. More...
 
const struct sol_gatt_attrsol_gatt_pending_get_attr (const struct sol_gatt_pending *op)
 Returns the attribute referenced by a pending operation. More...
 
int sol_gatt_pending_reply (struct sol_gatt_pending *pending, int error, struct sol_buffer *buf)
 Returns a response to an asynchronous operation. More...
 
int sol_gatt_read_attr (struct sol_bt_conn *conn, struct sol_gatt_attr *attr, void(*cb)(void *user_data, bool success, const struct sol_gatt_attr *attr, const struct sol_buffer *buf), const void *user_data)
 Reads the value from a attribute. More...
 
int sol_gatt_register_attributes (struct sol_gatt_attr *attrs)
 Registers attributes into the GATT database. More...
 
int sol_gatt_subscribe (struct sol_bt_conn *conn, const struct sol_gatt_attr *attr, bool(*cb)(void *user_data, const struct sol_gatt_attr *attr, const struct sol_buffer *buffer), const void *user_data)
 Registers a callback to be called when a notification/indication is received. More...
 
int sol_gatt_unregister_attributes (struct sol_gatt_attr *attrs)
 Unregisters attributes from the GATT database. More...
 
int sol_gatt_unsubscribe (bool(*cb)(void *user_data, const struct sol_gatt_attr *attr, const struct sol_buffer *buffer), const void *user_data)
 Unregisters from receiving notifications indications. More...
 
int sol_gatt_write_attr (struct sol_bt_conn *conn, struct sol_gatt_attr *attr, struct sol_buffer *buf, void(*cb)(void *user_data, bool success, const struct sol_gatt_attr *attr), const void *user_data)
 Writes the value to a attribute. More...
 

Detailed Description

API to handle Bluetooth technology communications.

API to handle the GATT protocol.

Warning
Experimental API. Changes are expected in future releases.

Macro Definition Documentation

#define SOL_GATT_ATTR_INVALID   { .type = SOL_GATT_ATTR_TYPE_INVALID }

Terminates the list of attributes.

See Also
sol_gatt_register_attributes()
Examples:
/src/samples/bluetooth/heartbeat.c.
#define SOL_GATT_CHARACTERISTIC_UUID_16 (   _uuid,
  _flags,
  ... 
)
Value:
.uuid = { .type = SOL_BT_UUID_TYPE_16, \
.val16 = (_uuid) }, \
.flags = (_flags), \
__VA_ARGS__ }
Definition: sol-gatt.h:59
Definition: sol-bluetooth.h:63

Helper to the construction of a GATT Characteristic with 16-bit UUID.

See Also
sol_gatt_attr
Examples:
/src/samples/bluetooth/heartbeat.c.
#define SOL_GATT_DESCRIPTOR_UUID_16 (   _uuid,
  _flags,
  ... 
)
Value:
.uuid = { .type = SOL_BT_UUID_TYPE_16, \
.val16 = (_uuid) }, \
.flags = (_flags), \
__VA_ARGS__ }
Definition: sol-bluetooth.h:63
Definition: sol-gatt.h:60

Helper to the construction of a GATT Descriptor with 16-bit UUID.

See Also
sol_gatt_attr
#define SOL_GATT_SERVICE_UUID_16 (   service_uuid)
Value:
.uuid = { .type = SOL_BT_UUID_TYPE_16, \
.val16 = (service_uuid) } }
Definition: sol-gatt.h:58
Definition: sol-bluetooth.h:63

Helper to the construction of a GATT Service with 16-bit UUID.

See Also
sol_gatt_attr
Examples:
/src/samples/bluetooth/heartbeat.c.

Typedef Documentation

Represents an active connection to a Bluetooth device.

The connection is established with sol_bt_connect(), and its lifetime is managed by sol_bt_conn_ref()/sol_bt_conn_unref().

Represents a information about a remote device.

Represents a pending scan session.

Represents a pending scan session,

See Also
sol_bt_start_scan().

Represents a Bluetooth usage session.

Because Bluetooth usage may increase the power comsuption, there's a need to keep track of what is using Bluetooth in the system, and keep Bluetooth turned off if it's not used.

typedef struct sol_bt_uuid sol_bt_uuid

Representation of a Bluetooth UUID.

In Bluetooth, a UUID represents the type of an entity, for example, if a service is encountered in a remote device with the 16-bit UUID '0x111F', that service is a "HandsfreeAudioGateway".

See Also
sol_bt_uuid_type
typedef struct sol_gatt_attr sol_gatt_attr

Representation of a GATT Attribute.

Represents a pending request.

So a response to a GATT operation can be returned asynchronously, operation callbacks,

See Also
sol_gatt_attr, passes a pending operation to the user which calls sol_gatt_pending_reply() when the operation is complete.

Enumeration Type Documentation

Over which transport should a scan be performed.

Enumerator
SOL_BT_TRANSPORT_LE 

Discover devices over the Bluetooth Low Energy transport.

SOL_BT_TRANSPORT_BREDR 

Discover devices over the Bluetooth Basic Rate transport.

SOL_BT_TRANSPORT_ALL 

Discover devices over All transports.

Set of types of UUIDs.

Bluetooth services (and other entities) types are uniquely identified by UUIDs. In Bluetooth, UUIDs come in different sizes, usually the 16-bit type is reserved to be allocated by the Bluetooth SIG. The 32-bit type is also reserved, but less used. The 128-bit is free to be used by applications.

Enumerator
SOL_BT_UUID_TYPE_16 
SOL_BT_UUID_TYPE_32 
SOL_BT_UUID_TYPE_128 

Set of types of Attributes.

GATT has the concept of different types of attributes, based on their UUIDs, sol-gatt simplifies that, separating attributes into three types.

Enumerator
SOL_GATT_ATTR_TYPE_INVALID 
SOL_GATT_ATTR_TYPE_SERVICE 
SOL_GATT_ATTR_TYPE_CHARACTERISTIC 
SOL_GATT_ATTR_TYPE_DESCRIPTOR 

Set of flags for Charateristic attributes.

See the Bluetooth Core Specification, Table 3.5 and Table 3.8 for more details.

Enumerator
SOL_GATT_CHR_FLAGS_BROADCAST 

When set allows the characteristic value to be broadcast.

SOL_GATT_CHR_FLAGS_READ 

Allows the characteristic value to be read.

SOL_GATT_CHR_FLAGS_WRITE_WITHOUT_RESPONSE 

Allows the write without response procedure against the characteristic value.

SOL_GATT_CHR_FLAGS_WRITE 

Allows the characteristic value to be written.

SOL_GATT_CHR_FLAGS_NOTIFY 

Allows notifications for the characteristic value.

SOL_GATT_CHR_FLAGS_INDICATE 

Allows indications for the characteristic value.

SOL_GATT_CHR_FLAGS_AUTHENTICATED_SIGNED_WRITES 

Allows the authenticated signed write procedure against the characteristic value.

SOL_GATT_CHR_FLAGS_RELIABLE_WRITE 

Allows the reliable write procedure against the characteristic value.

SOL_GATT_CHR_FLAGS_WRITABLE_AUXILIARIES 

Allows write operation against the descriptors associated with this characteristic.

SOL_GATT_CHR_FLAGS_ENCRYPT_READ 

Only allows encrypted read operations against the characteristic value.

SOL_GATT_CHR_FLAGS_ENCRYPT_WRITE 

Only allows encrypted write operations against the characteristic value.

SOL_GATT_CHR_FLAGS_ENCRYPT_AUTHENTICATED_READ 

Only allows encrypted and authenticated read operations against the characteristic value.

SOL_GATT_CHR_FLAGS_ENCRYPT_AUTHENTICATED_WRITE 

Only allows encrypted and authenticated write operations against the characteristic value.

Set of flags for Descriptor attributes.

Enumerator
SOL_GATT_DESC_FLAGS_READ 

Allows the descriptor value to be read.

SOL_GATT_DESC_FLAGS_WRITE 

Allows the descriptor value to be written.

SOL_GATT_DESC_FLAGS_ENCRYPT_READ 

Only allows encrypted read operations against the descriptor value.

SOL_GATT_DESC_FLAGS_ENCRYPT_WRITE 

Only allows encrypted write operations against the descriptor value.

SOL_GATT_DESC_FLAGS_ENCRYPT_AUTHENTICATED_READ 

Only allows encrypted and authenticated read operations against the descriptor value.

SOL_GATT_DESC_FLAGS_ENCRYPT_AUTHENTICATED_WRITE 

Only allows encrypted and authenticated write operations against the descriptor value.

Function Documentation

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.

Parameters
connThe reference to a connection.
Returns
The network link address associated with the remote end of the connection.
Examples:
/src/samples/bluetooth/browse.c, and /src/samples/bluetooth/connect-paired.c.

Referenced by on_connect(), and on_disconnect().

struct sol_bt_conn* sol_bt_conn_ref ( struct sol_bt_conn conn)

Increases the reference count of a connection.

Parameters
connThe reference to a connection.
Returns
The same connection, with refcount increased, or NULL if invalid.
void sol_bt_conn_unref ( struct sol_bt_conn conn)

Decreases the reference count of a connection.

When the last reference is released, the connection and all the resources associated with it are released.

Parameters
connThe reference to a connection.
Examples:
/src/samples/bluetooth/browse.c.

Referenced by shutdown().

struct sol_bt_conn* sol_bt_connect ( const struct sol_network_link_addr addr,
bool(*)(void *user_data, struct sol_bt_conn *conn)  on_connect,
void(*)(void *user_data, struct sol_bt_conn *conn)  on_disconnect,
void(*)(void *user_data, int error)  on_error,
const void *  user_data 
)

Attempts to establish a connection with a remote device.

Parameters
addrThe network link address of the remote device,
See Also
sol_bt_start_scan().
Parameters
on_connectThe callback to be called when the connection is established successfully.
on_disconnectThe callback to be called when the connection is terminated, after established.
on_errorThe callback to be called when the connection cannot be established.
user_dataUser data to be passed to the connection callbacks.
Returns
a reference to a connection, so the connection attempt can be cancelled,
See Also
sol_bt_disconnect().
Examples:
/src/samples/bluetooth/browse.c, and /src/samples/bluetooth/connect-paired.c.

Referenced by found_device(), and timeout_cb().

int sol_bt_disable ( struct sol_bt_session session)

Disables a session, returning the controller to its previous state.

In case the session is not already enabled, the enabling attempt will be cancelled after this is called, otherwise the on_enabled() function provided on the call to sol_bt_enable() will be called with false powered argument value.

Parameters
sessionReference to a session.
Returns
0 on success, -errno otherwise.
Examples:
/src/samples/bluetooth/browse.c, /src/samples/bluetooth/connect-paired.c, and /src/samples/bluetooth/heartbeat.c.

Referenced by shutdown().

int sol_bt_disconnect ( struct sol_bt_conn conn)

Terminates a connection, or connection attempt.

In case the connection is not already established, the connection attempt will be cancelled after this is called, otherwise the on_disconnect() function provided on the call to sol_bt_connect() will be called.

Parameters
connThe reference to a connection.
Returns
0 on success, -errno otherwise.
Examples:
/src/samples/bluetooth/connect-paired.c.

Referenced by shutdown().

struct sol_bt_session* sol_bt_enable ( void(*)(void *data, bool powered)  on_enabled,
const void *  user_data 
)

Enables the local Bluetooth controller.

Before using any other functionality from this module, this function should be called.

In case the Bluetooth controller is already enabled, the enabled() callback will be called before this function returns.

Parameters
on_enabledFunction to be called when the controller changes state.
user_dataUser data to be provided to the on_enabled callback.
Returns
a reference to a session, used for returning the system to its previous state,
See Also
sol_bt_disable().
Examples:
/src/samples/bluetooth/browse.c, /src/samples/bluetooth/connect-paired.c, and /src/samples/bluetooth/heartbeat.c.

Referenced by startup().

struct sol_bt_scan_pending* sol_bt_start_scan ( enum sol_bt_transport  transport,
void(*)(void *user_data, const struct sol_bt_device_info *device)  on_found,
const void *  user_data 
)

Start scanning for devices.

If there are already known devices, even if not visible, they will be notified. This function is safe to be called multiple times, the discovery will be stopped when the last user calls sol_bt_stop_scan().

Parameters
transportThe transport in which to discover devices.
on_foundThe callback to be called for each found device. It may be called multiple times, when the information about the device changes.
user_dataUser data to be passed to the callback.
Returns
pointer to a pending scan session on success, NULL on error,
See Also
sol_bt_stop_scan().
Examples:
/src/samples/bluetooth/browse.c, and /src/samples/bluetooth/connect-paired.c.

Referenced by enabled().

int sol_bt_stop_scan ( struct sol_bt_scan_pending handle)

Stop a scanning session.

Parameters
handlePointer of an ongoing scanning session.
Returns
0 on success, -errno otherwise.
Examples:
/src/samples/bluetooth/browse.c, and /src/samples/bluetooth/connect-paired.c.

Referenced by found_device(), and shutdown().

enum sol_bt_transport sol_bt_transport_from_str ( const char *  str)

Converts string to a transport,.

See Also
sol_bt_transport.
Parameters
strA with the transport representation.
Returns
a pointer to a string representing the transport on success, NULL otherwise.
const char* sol_bt_transport_to_str ( enum sol_bt_transport  transport)

Converts a transport to a string,.

See Also
sol_bt_transport.
Parameters
transportA transport.
Returns
a pointer to a string representing the transport on success, NULL otherwise.
bool sol_bt_uuid_eq ( const struct sol_bt_uuid u1,
const struct sol_bt_uuid u2 
)

Compare two UUIDs.

The UUIDs are converted to their 128-bit representation, if they are of different types, and compared returning if they are equal.

Parameters
u1UUID to be compared.
u2UUID to be compared.
Returns
True if UUIDs are equal, False otherwise.
int sol_bt_uuid_from_str ( struct sol_bt_uuid uuid,
const struct sol_str_slice  str 
)

Convert a string to a UUID.

Parameters
uuidThe uuid in which to store the value.
strThe string from which to convert.
Returns
0 on success, -errno on failure.
int sol_bt_uuid_to_str ( const struct sol_bt_uuid uuid,
struct sol_buffer buffer 
)

Convert a string to a UUID.

Parameters
uuidThe uuid to convert.
bufferThe buffer in which to store the string representation.
Returns
0 on success, -errno on failure.
Examples:
/src/samples/bluetooth/browse.c.

Referenced by print_attr().

int sol_gatt_discover ( struct sol_bt_conn conn,
enum sol_gatt_attr_type  type,
const struct sol_gatt_attr parent,
const struct sol_bt_uuid uuid,
bool(*)(void *user_data, struct sol_bt_conn *conn, const struct sol_gatt_attr *attr)  cb,
const void *  user_data 
)

Discover attributes by type, restricted by UUID and parent attribute.

Discover attributes belonging to a parent attribute, for example, discover all the characteristics under a service or all the descriptors under a characteristic, matching uuid (if provided).

Parameters
connConnection to a remote device
typeIf different from SOL_GATT_ATTR_TYPE_INVALID, only consider attributes of type,
See Also
sol_gatt_attr_type.
Parameters
parentIf different from NULL, only consider attributes belonging to parent attribute.
uuidIf different from NULL, only consider attributes matching uuid.
cbCallback to be called when the conditions above are met.
user_dataUser pointer to be passed to the callback
Returns
0 on success, -errno on failure.
Examples:
/src/samples/bluetooth/browse.c.

Referenced by on_connect().

int sol_gatt_indicate ( struct sol_bt_conn conn,
const struct sol_gatt_attr attr 
)

Sends an indication to the device represented by conn.

If conn is NULL, it sends to all devices that have registered themselves via the CCC attribute.

The value to be indicated is the value retrieved by calling the read callback of the attribute.

Parameters
connConnection in which to send notificatiions/indications.
attrAttribute to update.
Returns
0 on success, -errno on failure.
int sol_gatt_notify ( struct sol_bt_conn conn,
const struct sol_gatt_attr attr 
)

Sends a notificatiion to the device represented by conn.

If conn is NULL, it sends to all devices that have registered themselves via the CCC attribute.

The value to be notified is the value retrieved by calling the read callback of the attribute.

Parameters
connConnection in which to send notificatiions/indications.
attrAttribute to update.
Returns
0 on success, -errno on failure.
Examples:
/src/samples/bluetooth/heartbeat.c.

Referenced by timeout_cb().

const struct sol_gatt_attr* sol_gatt_pending_get_attr ( const struct sol_gatt_pending op)

Returns the attribute referenced by a pending operation.

Parameters
opThe pending operation
Returns
reference to an attribute
int sol_gatt_pending_reply ( struct sol_gatt_pending pending,
int  error,
struct sol_buffer buf 
)

Returns a response to an asynchronous operation.

When a operation is performed in a attribute, the response to the operation is only returned when this function is called.

Parameters
pendingPending operation to be responded.
errorError to be returned, 0 on success.
bufPayload (can be NULL) to be returned, on success the payload ownership passes to the function.
Returns
0 on success, -errno on failure.
Examples:
/src/samples/bluetooth/heartbeat.c.

Referenced by hrs_measurement_read().

int sol_gatt_read_attr ( struct sol_bt_conn conn,
struct sol_gatt_attr attr,
void(*)(void *user_data, bool success, const struct sol_gatt_attr *attr, const struct sol_buffer *buf)  cb,
const void *  user_data 
)

Reads the value from a attribute.

This only really makes sense for Characteristics and Descriptors, the Read Long attribute procedure will be performed if it's supported.

Parameters
connConnection to a remote device
attrAttribute to be read
cbCallback to be called when the operation is finished
user_dataUser pointer to be passed to the callback
Returns
0 on success, -errno on failure.
int sol_gatt_register_attributes ( struct sol_gatt_attr attrs)

Registers attributes into the GATT database.

Parameters
attrsArray of the attributes to be registered
Returns
0 on success, -errno on failure.
Examples:
/src/samples/bluetooth/heartbeat.c.

Referenced by enabled().

int sol_gatt_subscribe ( struct sol_bt_conn conn,
const struct sol_gatt_attr attr,
bool(*)(void *user_data, const struct sol_gatt_attr *attr, const struct sol_buffer *buffer)  cb,
const void *  user_data 
)

Registers a callback to be called when a notification/indication is received.

It will also try to enable indications/nofications writing to the CCC attribute if that descriptor exists.

Parameters
connConnection to a remote device
attrAttribute which to enable Notifications/Indications
cbCallback to be called for each update, if you want the notification to be cancelled, return false.
user_dataUser pointer to be passed to the callback
Returns
0 on success, -errno on failure.
Examples:
/src/samples/bluetooth/browse.c.

Referenced by print_attr().

int sol_gatt_unregister_attributes ( struct sol_gatt_attr attrs)

Unregisters attributes from the GATT database.

Parameters
attrsArray of the attributes to be unregistered
Returns
0 on success, -errno on failure.
Examples:
/src/samples/bluetooth/heartbeat.c.

Referenced by shutdown().

int sol_gatt_unsubscribe ( bool(*)(void *user_data, const struct sol_gatt_attr *attr, const struct sol_buffer *buffer)  cb,
const void *  user_data 
)

Unregisters from receiving notifications indications.

Parameters
cbCallback previously set
user_dataUser pointer
Returns
0 on success, -errno on failure.
int sol_gatt_write_attr ( struct sol_bt_conn conn,
struct sol_gatt_attr attr,
struct sol_buffer buf,
void(*)(void *user_data, bool success, const struct sol_gatt_attr *attr)  cb,
const void *  user_data 
)

Writes the value to a attribute.

This only really makes sense for Characteristics and Descriptors, the Write Long attribute procedure will be performed if it's supported.

Parameters
connConnection to a remote device
attrAttribute to be written
bufBuffer to be written, on success the ownership passes to the function.
cbCallback to be called when the operation is finished
user_dataUser pointer to be passed to the callback
Returns
0 on success, -errno on failure.