lr4 2.0.0.0
Public function

Functions

void lr4_cfg_setup (lr4_cfg_t *cfg)
 Config Object Initialization function.
 
LR4_RETVAL lr4_init (lr4_t *ctx, lr4_cfg_t *cfg)
 Initialization function.
 
int32_t lr4_generic_read (lr4_t *ctx, char *data_buf, uint16_t max_len)
 Generic read function.
 
void lr4_generic_write (lr4_t *ctx, char *data_buf, uint16_t len)
 Generic write function.
 
void lr4_hard_reset (lr4_t *ctx)
 Hardware reset function.
 
void lr4_wake_up (lr4_t *ctx, uint8_t state)
 Wake Up function.
 
void lr4_set_ind_handler (lr4_t *ctx, lr4_ind_hdl_t hdl)
 Set indication handler function.
 
uint8_t lr4_command (lr4_t *ctx, lr4_message_t *msg, lr4_message_t *rsp)
 Command function.
 
uint8_t lr4_read_message_process (lr4_t *ctx)
 Process function.
 
LR4_RETVAL lr4_soft_reset (lr4_t *ctx)
 Software reset function.
 
LR4_RETVAL lr4_factory_reset (lr4_t *ctx)
 Factory reset function.
 
LR4_RETVAL lr4_write_eeprom (lr4_t *ctx, uint8_t address, uint8_t n_bytes, uint8_t *data_in)
 EEPROM write function.
 
LR4_RETVAL lr4_read_eeprom (lr4_t *ctx, uint8_t address, uint8_t n_bytes, uint8_t *data_out)
 EEPROM read function.
 
LR4_RETVAL lr4_get_fw_version (lr4_t *ctx, uint32_t *fw_version)
 Get FW Version function.
 
LR4_RETVAL lr4_get_serial_no (lr4_t *ctx, uint32_t *serial_no)
 Get Serial Number function.
 
LR4_RETVAL lr4_get_dev_eui (lr4_t *ctx, uint8_t *dev_eui)
 Get DevEUI function.
 
LR4_RETVAL lr4_join_network (lr4_t *ctx, uint8_t mode)
 Join Network function.
 
LR4_RETVAL lr4_get_status (lr4_t *ctx, uint8_t status_mode)
 Get Status function.
 
LR4_RETVAL lr4_set_key (lr4_t *ctx, uint8_t *key_data, uint8_t key_mode)
 Set Key function.
 
LR4_RETVAL lr4_tx_message (lr4_t *ctx, lr4_tx_msg_t *tx_msg)
 Radio frame Transmission function.
 
LR4_RETVAL lr4_set_next_tx_data_rate (lr4_t *ctx, uint8_t data_rate)
 Set Next Data Rate function.
 
LR4_RETVAL lr4_set_battery_level (lr4_t *ctx, uint8_t battery_level)
 Set Battery Level function.
 
LR4_RETVAL lr4_get_battery_level (lr4_t *ctx)
 Get Battery Level function.
 
LR4_RETVAL lr4_set_counter (lr4_t *ctx, uint32_t cnt, uint8_t cnt_mode)
 Set Counter function.
 
LR4_RETVAL lr4_get_counter (lr4_t *ctx, uint32_t *cnt, uint8_t cnt_mode)
 Get Counter function.
 
LR4_RETVAL lr4_set_channel (lr4_t *ctx, uint8_t index, uint32_t freq, uint8_t data_rate_range, uint8_t status)
 Set Channel function.
 
uint8_t lr4_chk_sum (lr4_message_t *cmd)
 Check sum function.
 

Detailed Description

Function Documentation

◆ lr4_cfg_setup()

void lr4_cfg_setup ( lr4_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.

◆ lr4_chk_sum()

uint8_t lr4_chk_sum ( lr4_message_t * cmd)

Check sum function.

Parameters
ctxClick object.
cmdCommand structure.
Returns
Sum

@description This function returns sum of all elements in Command structure.

◆ lr4_command()

uint8_t lr4_command ( lr4_t * ctx,
lr4_message_t * msg,
lr4_message_t * rsp )

Command function.

Parameters
ctxClick object.
msgPointer to command buffer
rspPointer to output where response will be stored.
Returns
0 - OK, 1 - Check Sum Error

@description Function executes commands and reads response on executed commands. Also checks CRC error report.

◆ lr4_factory_reset()

LR4_RETVAL lr4_factory_reset ( lr4_t * ctx)

Factory reset function.

Parameters
ctxClick object.
Returns
0 - OK, 253 - Check Sum Error, 254 - Response Error, 255 - Header Error A value different from 0 is ERROR

@description Function performs the recovery of EEPROM default values.

◆ lr4_generic_read()

int32_t lr4_generic_read ( lr4_t * ctx,
char * data_buf,
uint16_t max_len )

Generic read function.

Parameters
ctxClick object.
data_bufData buffer for read data.
max_lenThe maximum length of data that can be read.
Returns
Number of read data.

@description This function read maximum length of data.

◆ lr4_generic_write()

void lr4_generic_write ( lr4_t * ctx,
char * data_buf,
uint16_t len )

Generic write function.

Parameters
lr4Click object.
data_bufData buffer for sends.
lenNumber of bytes for sends.

◆ lr4_get_battery_level()

LR4_RETVAL lr4_get_battery_level ( lr4_t * ctx)

Get Battery Level function.

Parameters
ctxClick object.
Returns
253 - Check Sum Error, 254 - Response Error, 255 - Header Error 0 - The end-device is connected to an external power source The battery level - 1 being at minimum and 254 being at maximum 255 - The end-device was not able to measure battery level

@description Function gets Battery Level.

◆ lr4_get_counter()

LR4_RETVAL lr4_get_counter ( lr4_t * ctx,
uint32_t * cnt,
uint8_t cnt_mode )

Get Counter function.

Parameters
ctxClick object.
cntPointer to buffer where counter value could be stored
cnt_mode0 - Get Uplink counter, 1 - Get Downlink counter
Returns
0 - OK, 253 - Check Sum Error, 254 - Response Error, 255 - Header Error

@description Function gets Uplink or Downlink counter.

◆ lr4_get_dev_eui()

LR4_RETVAL lr4_get_dev_eui ( lr4_t * ctx,
uint8_t * dev_eui )

Get DevEUI function.

Parameters
ctxClick object.
dev_euiPointer to buffer where devEUI data could be stored
Returns
0 - OK, 253 - Check Sum Error, 254 - Response Error, 255 - Header Error

@description Function gets DevEUI provided by Mipot.

◆ lr4_get_fw_version()

LR4_RETVAL lr4_get_fw_version ( lr4_t * ctx,
uint32_t * fw_version )

Get FW Version function.

Parameters
ctxClick object.
fw_versionPointer to buffer where FW Version could be stored
Returns
0 - OK, 253 - Check Sum Error, 254 - Response Error, 255 - Header Error

@description Function gets 32-bit FW version.

◆ lr4_get_serial_no()

LR4_RETVAL lr4_get_serial_no ( lr4_t * ctx,
uint32_t * serial_no )

Get Serial Number function.

Parameters
ctxClick object.
serial_noPointer to buffer where Serial Number could be stored
Returns
0 - OK, 253 - Check Sum Error, 254 - Response Error, 255 - Header Error

@description Function gets 32-bit Serial Number.

◆ lr4_get_status()

LR4_RETVAL lr4_get_status ( lr4_t * ctx,
uint8_t status_mode )

Get Status function.

Parameters
ctxClick object.
status_mode0 - Get Activation Status, 1 - Get Session Status
Returns
253 - Check Sum Error, 254 - Response Error, 255 - Header Error 0 - Not activated, 1 - Joining, 2 - Joined, 3 - MAC ERROR; when statusMode is 0 0 - Idle, 1 - Busy, 2 - Device not activated, 3 - Delayed; when statusMode is 1

@description Function gets the module activation and session status.

◆ lr4_hard_reset()

void lr4_hard_reset ( lr4_t * ctx)

Hardware reset function.

Parameters
ctxClick object.

@description Resets device by setting pin and after that puts device back in normal operation mode.

◆ lr4_init()

LR4_RETVAL lr4_init ( lr4_t * ctx,
lr4_cfg_t * cfg )

Initialization function.

Parameters
ctxClick object.
cfgClick configuration structure.

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

◆ lr4_join_network()

LR4_RETVAL lr4_join_network ( lr4_t * ctx,
uint8_t mode )

Join Network function.

Parameters
ctxClick object.
mode0 - Activation by personalization, 1 - Over the air activation
Returns
0 - OK, 2 - Busy, 253 - Check Sum Error, 254 - Response Error, 255 - Header Error

@description Function performs the join network command.

◆ lr4_read_eeprom()

LR4_RETVAL lr4_read_eeprom ( lr4_t * ctx,
uint8_t address,
uint8_t n_bytes,
uint8_t * data_out )

EEPROM read function.

Parameters
ctxClick object.
addressEEPROM Address from which data will be read
n_bytesNumber of bytes which will be read (max 254)
data_outPointer to buffer where data be stored
Returns
0 - OK, 252 - Payload Length Error, 253 - Check Sum Error, 254 - Response Error, 255 - Header Error or Data is empty

@description Function reads data from EEPROM.

◆ lr4_read_message_process()

uint8_t lr4_read_message_process ( lr4_t * ctx)

Process function.

Parameters
ctxClick object.
Returns
0 - OK, other - ERROR

@description Function executes reading indications and forwards indications to handler.

◆ lr4_set_battery_level()

LR4_RETVAL lr4_set_battery_level ( lr4_t * ctx,
uint8_t battery_level )

Set Battery Level function.

Parameters
ctxClick object.
battery_level0 - The end-device is connected to an external power source The battery level - 1 being at minimum and 254 being at maximum 255 - The end-device was not able to measure battery level
Returns
0 - OK, 253 - Check Sum Error, 254 - Response Error, 255 - Header Error

@description Function sets Battery Level.

◆ lr4_set_channel()

LR4_RETVAL lr4_set_channel ( lr4_t * ctx,
uint8_t index,
uint32_t freq,
uint8_t data_rate_range,
uint8_t status )

Set Channel function.

Parameters
ctxClick object.
indexFrom 3 to 15
freq32-bit frequency value
data_rate_rangeData Rate Max is most significant nibble (from 0 to 7) Data Rate Min is less significant nibble (from 0 to 7)
status0 - Disabled, 1 - Enabled
Returns
0 - OK, 253 - Check Sum Error, 254 - Response Error, 255 - Header Error 242 - Frequency out of range, 244 - MAC busy

@description Function sets channel parameters and enable/disable optional channels.

◆ lr4_set_counter()

LR4_RETVAL lr4_set_counter ( lr4_t * ctx,
uint32_t cnt,
uint8_t cnt_mode )

Set Counter function.

Parameters
ctxClick object.
cnt32-bit counter value
cnt_mode0 - Set Uplink counter, 1 - Set Downlink counter
Returns
0 - OK, 253 - Check Sum Error, 254 - Response Error, 255 - Header Error

@description Function sets Uplink or Downlink counter.

◆ lr4_set_ind_handler()

void lr4_set_ind_handler ( lr4_t * ctx,
lr4_ind_hdl_t hdl )

Set indication handler function.

Parameters
ctxClick object.
hdlPointer to void handler function

@description Function reads indications (response) to determined command.

◆ lr4_set_key()

LR4_RETVAL lr4_set_key ( lr4_t * ctx,
uint8_t * key_data,
uint8_t key_mode )

Set Key function.

Parameters
ctxClick object.
key_dataPointer to buffer which contains key data
key_mode0 - Set App Key, 1 - Set App Session Key, 2 - Set NWK Session Key
Returns
0 - OK, 253 - Check Sum Error, 254 - Response Error, 255 - Header Error

@description Function sets 16 byte key in Little Endian Order. App key is needed for OTAA procedure, and App Session key and NWK Session key is needed for APB procedure.

◆ lr4_set_next_tx_data_rate()

LR4_RETVAL lr4_set_next_tx_data_rate ( lr4_t * ctx,
uint8_t data_rate )

Set Next Data Rate function.

Parameters
ctxClick object.
data_rate0 - SF12/125kHz, 1 - SF11/125kHz, 2 - SF10/125kHz, 3 - SF9/125kHz 4 - SF8/125kHz, 5 - SF7/125kHz, 6 - SF7/250kHz, 7 - FSK
Returns
0 - OK, 253 - Check Sum Error, 254 - Response Error, 255 - Header Error A value different from zero means that an error has occurred

@description Function sets next transmission Data Rate.

◆ lr4_soft_reset()

LR4_RETVAL lr4_soft_reset ( lr4_t * ctx)

Software reset function.

Parameters
ctxClick object.
Returns
0 - OK, 253 - Check Sum Error, 254 - Response Error, 255 - Header Error

@description Function resets module by sending command.

◆ lr4_tx_message()

LR4_RETVAL lr4_tx_message ( lr4_t * ctx,
lr4_tx_msg_t * tx_msg )

Radio frame Transmission function.

Parameters
ctxClick object.
tx_msg
Structure arguments:
- data_in               Pointer to buffer that contains data for transmission.
- n_bytes               Number of bytes which will be sent (max 253)
- port                  From 1 to 223
- option                0bxxxxxxx0 - Unreliable Data Transmission, 0bxxxxxxx1 - Reliable Data Transmission
Returns
0 - OK, 252 - Payload Length Error, 253 - Check Sum Error, 254 - Response Error, 255 - Header Error, 1 - Device busy, 2 - Device not activated, 3 - Channel blocked by duty-cycle, 5 - Length not supported, 6 - End Node in silent state, 7 - Error

@description Function performs the transmission of radio frames.

◆ lr4_wake_up()

void lr4_wake_up ( lr4_t * ctx,
uint8_t state )

Wake Up function.

Parameters
ctxClick object.
state0 - wake up, 1 - shutdown

@description Puts device in shutdown mode or wake up device depending on state.

◆ lr4_write_eeprom()

LR4_RETVAL lr4_write_eeprom ( lr4_t * ctx,
uint8_t address,
uint8_t n_bytes,
uint8_t * data_in )

EEPROM write function.

Parameters
ctxClick object.
addressEEPROM Address where data be written
n_bytesNumber of bytes which will be written (max 254)
data_inPointer to buffer which will be written.
Returns
0 - OK, 1 - Invalid address, 252 - Payload Length Error, 253 - Check Sum Error, 254 - Response Error, 255 - Header Error

@description Function writes data to EEPROM.