Device SDK API Reference
SDK Version 0.1.6
The Blecon SDK is available on GitHub
Overview
Macros
Name | Description |
---|---|
Enumerations
Name | Description |
---|---|
Return codes. | |
Modem modes. | |
Request errors. | |
Data Structures
Name | Description |
---|---|
Callbacks structure to populate by user. | |
Functions
Name | Description |
---|---|
Create new internal modem instance. | |
Create new external modem instance. | |
Set-up modem. | |
Set callbacks. | |
Set callbacks. | |
Set application-related data. | |
Identify the device to surrounding hotspots. | |
Request a connection to the Blecon infrastructure. | |
Cancel or close the current connection. | |
Send a request to the integration. | |
Get the error regarding the last request. | |
Get the response to the sent request. | |
Get the device's URL. | |
Get the device's ID in UUID form. |
Macros
#define BLECON_REQUEST_LOCAL_ERROR_CODE_NS
Value
#define BLECON_REQUEST_REMOTE_ERROR_CODE_NS
Value
Enumerations
enum blecon_ret_t
Return codes.
Values
Value | Description |
---|---|
blecon_ok | OK. |
blecon_error_exceeds_mtu | Message exceeds MTU. |
blecon_error_invalid_state | This method cannot be called in the current state. |
blecon_error_buffer_too_small | Data doesn't fit in the buffer. |
blecon_error_serialization | Serialization error (external modem) |
blecon_error_transport_error | Transport error (external modem) |
enum blecon_mode_t
Modem modes.
Values
Value | Description |
---|---|
blecon_mode_high_performance | High Performance mode. |
blecon_mode_balanced | Balanced mode. |
blecon_mode_ultra_low_power | Low Power mode. |
enum blecon_request_error_t
Request errors.
Values
Value | Description |
---|---|
blecon_request_ok | OK. |
blecon_request_error_timeout | Request timed out. |
blecon_request_error_security_error | The connection failed due to a security error. |
blecon_request_error_disconnected | The link was disconnected before the request completed. |
blecon_request_error_handler_not_set | The network's handler is not set. |
blecon_request_error_handler_timeout | The network's handler timed out. |
blecon_request_error_handler_failed | The network's handler failed. |
blecon_request_error_network_not_set | The device is attached to a Blecon network. |
enum blecon_modem_info_type_t
Values
Value | Description |
---|---|
blecon_modem_info_type_internal | |
blecon_modem_info_type_external |
Data Structures
struct blecon_modem_callbacks_t
Callbacks structure to populate by user.
Members
Type | Name | Description |
---|---|---|
on_connection | Called when a connection has been established. | |
on_response | Called when a response is available. | |
on_error | Called when a request didn't complete successfully. |
struct blecon_modem_info_t
Members
Type | Name | Description |
---|---|---|
type | ||
firmware_version |
Functions
blecon_int_modem_new()
Create new internal modem instance.
Parameters
Parameter | Description |
---|---|
event_loop | a platform-specific event loop instance |
bluetooth | a platform-specific bluetooth instance |
crypto | a platform-specific crypto instance |
nvm | a platform-specific nvm instance |
nfc | a platform-specific nfc instance |
Returns
a pointer to a struct blecon_modem_t instance
blecon_ext_modem_new()
Create new external modem instance.
Parameters
Parameter | Description |
---|---|
event_loop | a platform-specific event loop instance |
transport | a platform-specific transport instance |
Returns
a pointer to a struct blecon_modem_t instance
blecon_setup()
Set-up modem.
Parameters
Parameter | Description |
---|---|
modem | the modem instance to set-up |
Returns
enum blecon_ret_t blecon_ok on success, or an error code on failure
blecon_set_callbacks()
Set callbacks.
Parameters
Parameter | Description |
---|---|
modem | the modem instance |
callbacks | a struct blecon_modem_callbacks_t structure containing the user's callbacks |
blecon_get_info()
Set callbacks.
Parameters
Parameter | Description |
---|---|
modem | the modem instance |
info | a pointer to a struct blecon_modem_info_t structure which is populated on success |
Returns
enum blecon_ret_t blecon_ok on success, or an error code on failure
blecon_set_application_data()
Set application-related data.
Parameters
Parameter | Description |
---|---|
modem | the modem instance |
application_model_id | the device's specific model id encoded as a UUID (16 bytes long) |
application_schema_version | the device's schema version |
Returns
enum blecon_ret_t blecon_ok on success, or an error code on failure
blecon_identify()
Identify the device to surrounding hotspots.
Parameters
Parameter | Description |
---|---|
modem | the modem instance |
Returns
enum blecon_ret_t blecon_ok on success, or an error code on failure
blecon_request_connection()
Request a connection to the Blecon infrastructure.
Parameters
Parameter | Description |
---|---|
modem | the modem instance |
Returns
enum blecon_ret_t blecon_ok on success, or an error code on failure
blecon_close_connection()
Cancel or close the current connection.
Parameters
Parameter | Description |
---|---|
modem | the modem instance |
Returns
enum blecon_ret_t blecon_ok on success, or an error code on failure
blecon_send_request()
Send a request to the integration.
Parameters
Parameter | Description |
---|---|
modem | the modem instance |
data | the data to send to the integration |
sz | the size of the data buffer |
Returns
enum blecon_ret_t blecon_ok on success, or an error code on failure
blecon_get_error()
Get the error regarding the last request.
Parameters
Parameter | Description |
---|---|
modem | the modem instance |
error | a pointer where the error code can be stored |
Returns
enum blecon_ret_t blecon_ok on success, or an error code on failure
blecon_get_response()
Get the response to the sent request.
Parameters
Parameter | Description |
---|---|
modem | the modem instance |
data | where to store the data sent by the integration |
sz | pointer to the maximum size that can be stored in data, updated to the actual stored size on success |
Returns
enum blecon_ret_t blecon_ok on success, or an error code on failure
blecon_get_url()
Get the device's URL.
Parameters
Parameter | Description |
---|---|
modem | the modem instance |
url | a char array where to store the url (0-terminated) |
max_sz | the maximum size of the array (including space for 0 terminator) |
Returns
enum blecon_ret_t blecon_ok on success, or an error code on failure
blecon_get_identity()
Get the device's ID in UUID form.
Parameters
Parameter | Description |
---|---|
modem | the modem instance |
uuid | a 16-byte array where to store the uuid |
Returns
enum blecon_ret_t blecon_ok on success, or an error code on failure
Last updated