rn4871 2.0.0.0
Public function

Functions

void rn4871_cfg_setup (rn4871_cfg_t *cfg)
 Config Object Initialization function.
 
RN4871_RETVAL rn4871_init (rn4871_t *ctx, rn4871_cfg_t *cfg)
 Initialization function.
 
void rn4871_reset (rn4871_t *ctx)
 Hardware reset function.
 
void rn4871_generic_write (rn4871_t *ctx, char *data_buf, uint16_t len)
 Generic write function.
 
int32_t rn4871_generic_read (rn4871_t *ctx, char *data_buf, uint16_t max_len)
 Generic read function.
 
uint8_t rn4871_int_get (rn4871_t *ctx)
 Get interrupt state function.
 
void rn4871_rst_set (rn4871_t *ctx, uint8_t pin_state)
 Set states of RST pin to desired state.
 
void rn4871_cs_set (rn4871_t *ctx, uint8_t pin_state)
 Set states of CS pin to desired state.
 
void rn4871_uart_write (rn4871_t *ctx, uint8_t *wr_buf)
 UART write function.
 
void rn4871_initialize (rn4871_t *ctx, char *p_addr)
 Initialization RN4871 module.
 
void rn4871_connect (rn4871_t *ctx, char *p_addr)
 Connecting to slave device.
 
void rn4871_send (rn4871_t *ctx, uint8_t msg_type, uint16_t data_type, uint8_t id, uint8_t *payload)
 Send message function.
 
void rn4871_disconnect (rn4871_t *ctx)
 Disconnecting from slave device.
 
void rn4871_receive (rn4871_t *ctx, char tmp)
 Receiving character function.
 
uint8_t rn4871_read (rn4871_t *ctx, uint8_t *process_buffer)
 Reading received message.
 

Detailed Description

Function Documentation

◆ rn4871_cfg_setup()

void rn4871_cfg_setup ( rn4871_cfg_t * cfg)

Config Object Initialization function.

Parameters
cfgClick configuration structure.

@description This function initializes click configuration structure to init state.

Note
All used pins will be set to unconnected state.

◆ rn4871_connect()

void rn4871_connect ( rn4871_t * ctx,
char * p_addr )

Connecting to slave device.

Parameters
ctxClick object.
dev_addrPointer to the memory location where slave device with be stored

@description The function connects to slave device with desired register address by secures the connection and entering data stream mode.

◆ rn4871_cs_set()

void rn4871_cs_set ( rn4871_t * ctx,
uint8_t pin_state )

Set states of CS pin to desired state.

Parameters
ctxClick object.
pin_stateState of pin to be set.

@description The function set states of CS pin desired state.

◆ rn4871_disconnect()

void rn4871_disconnect ( rn4871_t * ctx)

Disconnecting from slave device.

Parameters
ctxClick object.

@description The function disconnects from slave device by enters CMD mode and kills connection.

◆ rn4871_generic_read()

int32_t rn4871_generic_read ( rn4871_t * ctx,
char * data_buf,
uint16_t max_len )

Generic read function.

Parameters
ctxClick object.
data_bufBuffer to be write.
max_lenLength of data to be read.
Returns
number of read bytes

@description This function read buffer of maximum length

◆ rn4871_generic_write()

void rn4871_generic_write ( rn4871_t * ctx,
char * data_buf,
uint16_t len )

Generic write function.

Parameters
ctxClick object.
data_bufBuffer to be write.
lenLength of data to be write.

@description This function write buffer of specific length

◆ rn4871_init()

RN4871_RETVAL rn4871_init ( rn4871_t * ctx,
rn4871_cfg_t * cfg )

Initialization function.

Parameters
ctxClick object.
cfgClick configuration structure.

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

◆ rn4871_initialize()

void rn4871_initialize ( rn4871_t * ctx,
char * p_addr )

Initialization RN4871 module.

Parameters
ctxClick object.
dev_addrPointer to the memory location where dev_addr be stored

@description The function initializes RN4871 Bluetooth� 4.2 low energy module by resets the RN4871 module, disable I2C communications pins, reboots the device for change to take effect, enters CMD mode again, and sets the address of the device.

◆ rn4871_int_get()

uint8_t rn4871_int_get ( rn4871_t * ctx)

Get interrupt state function.

Parameters
ctxClick object.
Returns
interrupt state ( 0 : not active, 1 : active )

@description The function gets interrupt state by return status of INT pin.

◆ rn4871_read()

uint8_t rn4871_read ( rn4871_t * ctx,
uint8_t * process_buffer )

Reading received message.

Parameters
ctxClick object.
process_bufferBuffer for storing received message
Returns
1 if whole and properly formated message was received and stored; 0 if not

@description This function gets message from 'void rn4871_receive function if flag was set This function replaces '*' (character with end of string) with '0x00' and stores received message to process_buffer

◆ rn4871_receive()

void rn4871_receive ( rn4871_t * ctx,
char tmp )

Receiving character function.

Parameters
ctxClick object.
tmpReceived character

@description The function receives character by waits for '#' - character to start parsing message, waits for '*' - character to stop parsing message and sets flag if whole and properly formated message is received.

◆ rn4871_reset()

void rn4871_reset ( rn4871_t * ctx)

Hardware reset function.

Parameters
ctxClick object.

@description The function Hardware reset - resets the RN4871 Bluetooth� 4.2 low energy module by cleared to '0' RST state pin, wait for 100 ms, set to '1' RST state pin and wait for 200 ms.

Note
Delay is 300 ms.

◆ rn4871_rst_set()

void rn4871_rst_set ( rn4871_t * ctx,
uint8_t pin_state )

Set states of RST pin to desired state.

Parameters
ctxClick object.
pin_stateState of pin to be set.

@description The function set states of RST desired state.

◆ rn4871_send()

void rn4871_send ( rn4871_t * ctx,
uint8_t msg_type,
uint16_t data_type,
uint8_t id,
uint8_t * payload )

Send message function.

Parameters
ctxClick object.
msg_type8-bit message type ( e.g. message - 'M' = 0x4D )
data_type16-bit data type ( e.g. sensor 1 - S1 = 0x5331 )
dev_id8-bit device id ( e.g. slave - 'S' = 0x53 )
tx_dataPointer to the memory location where the text data is stored

@description The function sends message to slave device.

◆ rn4871_uart_write()

void rn4871_uart_write ( rn4871_t * ctx,
uint8_t * wr_buf )

UART write function.

Parameters
ctxClick object.
tx_dataTx buffer

@description This function is for UART writing