Wirepas click
PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU
[click Product page](CLICK_PRODUCT_PAGE_LINK)
Click library
- Author : Stefan Ilic
- Date : Jun 2023.
- Type : UART type
Software Support
We provide a library for the Wirepas Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Library Description
This library contains API for Wirepas Click driver.
Standard key functions :
wirepas_cfg_setup
Config Object Initialization function.
void wirepas_cfg_setup(wirepas_cfg_t *cfg)
Wirepas configuration object setup function.
Wirepas Click configuration object.
Definition: wirepas.h:191
wirepas_init
Initialization function.
err_t wirepas_init(wirepas_t *ctx, wirepas_cfg_t *cfg)
Wirepas initialization function.
Wirepas Click context object.
Definition: wirepas.h:170
wirepas_default_cfg
Click Default Configuration function.
void wirepas_default_cfg(wirepas_t *ctx)
Wirepas default configuration function.
Example key functions :
wirepas_send_command
Wirepas send command function.
err_t wirepas_send_command(wirepas_t *ctx, uint8_t primitive_id, uint8_t frame_id, uint8_t payload_length, uint8_t *payload)
Wirepas send command function.
uint8_t frame_id
Definition: main.c:52
Wirepas write CSAP attribute function.
Wirepas read CSAP attribute function.
err_t wirepas_write_csap_attribute(wirepas_t *ctx, uint8_t frame_id, uint16_t attribute_id, uint8_t attribute_len, uint8_t *attribute_val)
Wirepas write CSAP attribute function.
wirepas_send_data
Wirepas send data function. err_t
wirepas_send_data (
wirepas_t *ctx, uint8_t
frame_id, uint16_t pduid, uint8_t source_endpoint, uint32_t destination_addr, uint8_t destination_endpoint, uint8_t tx_op, uint8_t apdu_length, uint8_t *apdu );
err_t wirepas_send_data(wirepas_t *ctx, uint8_t frame_id, uint16_t pduid, uint8_t source_endpoint, uint32_t destination_addr, uint8_t destination_endpoint, uint8_t tx_op, uint8_t apdu_length, uint8_t *apdu)
Wirepas send data function.
Example Description
This example demonstrates the use of Wirepas click board by processing
the incoming data and displaying them on the USB UART in sink mode, and sending data to the sinks in router mode.
The demo application is composed of two sections :
Application Init
Initializes the driver and performs the click default configuration, setting device mode, node,
net and chennel addresses, and starting stack.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
uint8_t tmp_data[ 1 ] = { 0x00 };
Delay_ms( 1000 );
Delay_ms( 1000 );
Delay_ms( 1000 );
log_printf( &logger, " Wirepas stack stop request: \n" );
Delay_ms( 1000 );
log_printf( &logger, " Wirepas factory reset request: \n" );
Delay_ms( 1000 );
Delay_ms( 1000 );
Delay_ms( 1000 );
log_printf( &logger, " Set node address: \n" );
#if defined ROUTER_MODE
#else
#endif
Delay_ms( 1000 );
log_printf( &logger, " Set net address: \n" );
Delay_ms( 1000 );
log_printf( &logger, " Set channel address: \n" );
Delay_ms( 1000 );
log_printf( &logger, " Set role: \n" );
#if defined ROUTER_MODE
#else
#endif
Delay_ms( 1000 );
log_printf( &logger, " Wirepas Stack start request: \n" );
tmp_data[ 0 ] = 0x01;
#if defined ROUTER_MODE
Delay_ms( 1000 );
#else
uint8_t data_rd = 0;
while ( data_rd == 0 )
{
Delay_ms( 1000 );
}
#endif
Delay_ms( 100 );
log_info( &logger, " Application Task " );
}
#define WIREPAS_MSAP_STACK_START_REQUEST
Definition: wirepas.h:79
#define WIREPAS_CSAP_ATTRIBUTE_NETWORK_CHANNEL
Definition: wirepas.h:103
#define WIREPAS_FACTORY_RESET_CODE
Wirepas factory reset code.
Definition: wirepas.h:110
#define WIREPAS_SINK_NODE_MODE
Definition: wirepas.h:123
#define WIREPAS_RX_DRV_BUFFER_SIZE
Definition: wirepas.h:138
#define WIREPAS_ROUTER_NODE_MODE
Wirepas node role mode settings.
Definition: wirepas.h:122
#define WIREPAS_CSAP_FACTORY_RESET_REQUEST
Definition: wirepas.h:94
#define WIREPAS_MSAP_STACK_STOP_REQUEST
Definition: wirepas.h:81
#define WIREPAS_CSAP_ATTRIBUTE_NODE_ROLE
Definition: wirepas.h:104
#define WIREPAS_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: wirepas.h:156
err_t wirepas_set_node_address(wirepas_t *ctx, uint8_t frame_id, uint32_t address)
Wirepas set node address function.
err_t wirepas_poll_indication(wirepas_t *ctx, uint8_t frame_id, uint8_t *rx_data, uint8_t *data_rdy)
Wirepas poll indication function.
err_t wirepas_set_net_address(wirepas_t *ctx, uint8_t frame_id, uint32_t net_address)
Wirepas set net address function.
void application_init(void)
Definition: main.c:66
err_t wirepas_get_resp(wirepas_t *ctx)
Wirepas get responce function.
Definition: main.c:230
#define CHANNEL_ADDRESS
Definition: main.c:48
#define TX_ADDRESS
Wirepas node addresses.
Definition: main.c:44
#define RX_ADDRESS_1
Definition: main.c:45
#define NET_ADDRESS
Definition: main.c:47
@ WIREPAS_ERROR
Definition: wirepas.h:217
Application Task
Router mode - Sending data to the sinks at the same network.
Sink mode - Reads and processes all incoming data and displays them on the USB UART.
{
#if defined ROUTER_MODE
log_printf( &logger, " Sending data to the first Sink node: \n" );
Delay_ms( 5000 );
#if defined MULTI_SINK_MODE
log_printf( &logger, " Sending data to the second Sink node: \n" );
Delay_ms( 5000 );
#endif
#else
uint8_t data_rdy = 0;
if ( data_rdy == 1 )
{
log_printf( &logger, "%s \r\n", data_buf );
}
Delay_ms( 2000 );
#endif
}
void application_task(void)
Definition: main.c:189
#define RX_ADDRESS_2
Definition: main.c:46
#define TX_DATA
Definition: main.c:35
Note
For the best experience use two clicks in sink mode and one in router.
The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Other Mikroe Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.Wirepas
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.