bt 2.0.0.0
BT Click Driver

API for configuring and manipulating BT Click driver. More...

Topics

 BT Device Settings
 Settings for BT Click driver.
 
 BT MikroBUS Map
 MikroBUS pin mapping of BT Click driver.
 

Functions

void bt_cfg_setup (bt_cfg_t *cfg)
 BT configuration object setup function.
 
err_t bt_init (bt_t *ctx, bt_cfg_t *cfg)
 BT initialization function.
 
err_t bt_default_cfg (bt_t *ctx)
 BT default configuration function.
 
err_t bt_generic_write (bt_t *ctx, char *data_buf, uint16_t len)
 BT data writing function.
 
err_t bt_generic_read (bt_t *ctx, char *data_buf, uint16_t max_len)
 BT data reading function.
 
void bt_set_an_pin (bt_t *ctx, uint8_t state)
 BT set AN pin function.
 
void bt_set_rst_pin (bt_t *ctx, uint8_t state)
 BT set RST pin function.
 
void bt_set_cts_pin (bt_t *ctx, uint8_t state)
 BT set CTS pin function.
 
void bt_set_bt0_pin (bt_t *ctx, uint8_t state)
 BT set BT0 pin function.
 
uint8_t bt_get_rts_pin (bt_t *ctx)
 BT get RTS pin function.
 
err_t bt_send_package (bt_t *ctx, bt_package_t pkg)
 BT send package function.
 
err_t bt_read_package (bt_t *ctx, bt_package_t *pkg)
 BT read package function.
 
err_t bt_set_local_name (bt_t *ctx, char *name)
 BT set local name function.
 
err_t bt_set_bondable_mode (bt_t *ctx, uint8_t mode)
 BT set bondable mode function.
 
err_t bt_delete_bondings (bt_t *ctx)
 BT delete bondings function.
 
err_t bt_set_class_of_device (bt_t *ctx, uint32_t cod)
 BT set class of device function.
 
err_t bt_set_gap_mode (bt_t *ctx, uint8_t connectable, uint8_t discoverable, uint8_t limited)
 BT set gap mode function.
 
err_t bt_rfcomm_start_server (bt_t *ctx, uint8_t sdp_id, uint8_t stream_dest)
 BT rfcomm start server function.
 
err_t bt_rfcomm_stop_server (bt_t *ctx, uint8_t sdp_id)
 BT rfcomm stop server function.
 
err_t bt_factory_reset (bt_t *ctx)
 BT factory reset function.
 
err_t bt_system_reset (bt_t *ctx, uint8_t mode)
 BT system reset function.
 
err_t bt_hardware_config_gpio (bt_t *ctx, uint8_t port, uint16_t pin_index, uint8_t mode, uint8_t pullup)
 BT hardware config gpio function.
 
err_t bt_hardware_read_gpio (bt_t *ctx, uint8_t port, uint16_t mask, uint16_t *port_data)
 BT hardware read gpio function.
 
err_t bt_hardware_write_gpio (bt_t *ctx, uint8_t port, uint16_t mask, uint16_t port_data)
 BT hardware write gpio function.
 
err_t bt_endpoint_send_data (bt_t *ctx, uint8_t *endpoint, char *msg)
 BT endpoint send data function.
 

Detailed Description

API for configuring and manipulating BT Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ bt_cfg_setup()

void bt_cfg_setup ( bt_cfg_t * cfg)

BT configuration object setup function.

This function initializes click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See bt_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ bt_default_cfg()

err_t bt_default_cfg ( bt_t * ctx)

BT default configuration function.

This function executes a default configuration of BT click board.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ bt_delete_bondings()

err_t bt_delete_bondings ( bt_t * ctx)

BT delete bondings function.

This function deletes all bondings.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bt_endpoint_send_data()

err_t bt_endpoint_send_data ( bt_t * ctx,
uint8_t * endpoint,
char * msg )

BT endpoint send data function.

This function sends data to the defined endpoint.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
[in,out]endpoint: The pointer to index of the endpoint to which the data will be sent. It will be overwritten by the endpoint index value of the response to this command.
[in]msg: Data to be sent.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bt_factory_reset()

err_t bt_factory_reset ( bt_t * ctx)

BT factory reset function.

This function resets the device to factory settings.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bt_generic_read()

err_t bt_generic_read ( bt_t * ctx,
char * data_buf,
uint16_t max_len )

BT data reading function.

This function reads a desired number of data bytes by using UART serial interface.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
[out]data_buf: Output read data.
[in]max_len: Number of bytes to be read.
Returns
  • >0 - Number of data bytes read,
  • <=0 - Error/Empty Ring buffer.
See #err_t definition for detailed explanation.
Note
None.

◆ bt_generic_write()

err_t bt_generic_write ( bt_t * ctx,
char * data_buf,
uint16_t len )

BT data writing function.

This function writes a desired number of data bytes by using UART serial interface.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
[in]data_buf: Data buffer for sending.
[in]len: Number of bytes for sending.
Returns
  • >=0 - Success,
  • <0 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bt_get_rts_pin()

uint8_t bt_get_rts_pin ( bt_t * ctx)

BT get RTS pin function.

This function returns the RTS pin logic state.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
Returns
Pin logic state.
Note
None.

◆ bt_hardware_config_gpio()

err_t bt_hardware_config_gpio ( bt_t * ctx,
uint8_t port,
uint16_t pin_index,
uint8_t mode,
uint8_t pullup )

BT hardware config gpio function.

This function configures the GPIO pins.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
[in]port:
  • 0 - PORT A,
  • 1 - PORT B.
[in]pin_index: The index of the GPIO pin on the port which this function affects.
[in]mode:
  • 0 - Input,
  • 1 - Output,
  • 2 - Function,
  • 3 - Analog.
[in]pullup:
  • 0 - Float,
  • 1 - Pull-up,
  • 2 - Pull-down.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bt_hardware_read_gpio()

err_t bt_hardware_read_gpio ( bt_t * ctx,
uint8_t port,
uint16_t mask,
uint16_t * port_data )

BT hardware read gpio function.

This function reads the state of a desired GPIO pins.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
[in]port:
  • 0 - PORT A,
  • 1 - PORT B.
[in]mask: Bitmask of which pins on the port should be read.
[in]port_data: Port data read.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bt_hardware_write_gpio()

err_t bt_hardware_write_gpio ( bt_t * ctx,
uint8_t port,
uint16_t mask,
uint16_t port_data )

BT hardware write gpio function.

This function sets the state of a desired GPIO pins.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
[in]port:
  • 0 - PORT A,
  • 1 - PORT B.
[in]mask: Bitmask which determines the pins this function is used to set.
[in]port_data: Bitmask of which pins to set high and which pins to set low (1 - high, 0 - low).
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bt_init()

err_t bt_init ( bt_t * ctx,
bt_cfg_t * cfg )

BT initialization function.

This function initializes all necessary pins and peripherals used for this click board.

Parameters
[out]ctx: Click context object. See bt_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See bt_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bt_read_package()

err_t bt_read_package ( bt_t * ctx,
bt_package_t * pkg )

BT read package function.

This function waits for the command or event type of message to arrive and then reads the complete message and stores it to pkg structure.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
[out]pkg: Pointer to structure where the read data is being stored. See bt_package_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bt_rfcomm_start_server()

err_t bt_rfcomm_start_server ( bt_t * ctx,
uint8_t sdp_id,
uint8_t stream_dest )

BT rfcomm start server function.

This function starts the RFCOMM server as defined in the SDP-entry.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
[in]sdp_id: ID of the SDP entry [ Default: 0x02 ].
[in]stream_dest: Streaming destination [ Default: 0x00 ].
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bt_rfcomm_stop_server()

err_t bt_rfcomm_stop_server ( bt_t * ctx,
uint8_t sdp_id )

BT rfcomm stop server function.

This function stops the RFCOMM server.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
[in]sdp_id: ID of the SDP entry [ Default: 0x02 ].
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bt_send_package()

err_t bt_send_package ( bt_t * ctx,
bt_package_t pkg )

BT send package function.

This function sends a data package to the click board.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
[in]pkg: Data package to be written. See bt_package_t object definition for detailed explanation.
Returns
  • >=0 - Success,
  • <0 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bt_set_an_pin()

void bt_set_an_pin ( bt_t * ctx,
uint8_t state )

BT set AN pin function.

This function sets the AN pin logic state.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
[in]state: Pin logic state.
Returns
None.
Note
None.

◆ bt_set_bondable_mode()

err_t bt_set_bondable_mode ( bt_t * ctx,
uint8_t mode )

BT set bondable mode function.

This function sets the bondable mode of the device.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
[in]mode:
  • 0 - Not accepted,
  • 1 - Allowed.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bt_set_bt0_pin()

void bt_set_bt0_pin ( bt_t * ctx,
uint8_t state )

BT set BT0 pin function.

This function sets the BT0 pin logic state.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
[in]state: Pin logic state.
Returns
None.
Note
None.

◆ bt_set_class_of_device()

err_t bt_set_class_of_device ( bt_t * ctx,
uint32_t cod )

BT set class of device function.

This function sets the class of the device.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
[in]cod: Class of the device.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bt_set_cts_pin()

void bt_set_cts_pin ( bt_t * ctx,
uint8_t state )

BT set CTS pin function.

This function sets the CTS pin logic state.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
[in]state: Pin logic state.
Returns
None.
Note
None.

◆ bt_set_gap_mode()

err_t bt_set_gap_mode ( bt_t * ctx,
uint8_t connectable,
uint8_t discoverable,
uint8_t limited )

BT set gap mode function.

This function sets the GAP mode.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
[in]connectable:
  • 0 - Not connectable,
  • 1 - Connectable.
[in]discoverable:
  • 0 - Not discoverable,
  • 1 - Discoverable.
[in]limited:
  • 0 - Limited,
  • 1 - Not limited.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bt_set_local_name()

err_t bt_set_local_name ( bt_t * ctx,
char * name )

BT set local name function.

This function sets the local name of the device.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
[in]name: Local device name ( up to 30 characters ).
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bt_set_rst_pin()

void bt_set_rst_pin ( bt_t * ctx,
uint8_t state )

BT set RST pin function.

This function sets the RST pin logic state.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
[in]state: Pin logic state.
Returns
None.
Note
None.

◆ bt_system_reset()

err_t bt_system_reset ( bt_t * ctx,
uint8_t mode )

BT system reset function.

This function resets the device.

Parameters
[in]ctx: Click context object. See bt_t object definition for detailed explanation.
[in]mode:
  • 0 - Normal reset,
  • 1 - Boot to DFU.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.