wirepas 2.1.0.0
Main Page

Wirepas click

‍Wirepas Click is a compact add-on board that allows you to implement the Wirepas Mesh wireless connectivity stack to your application. This board features the WIRL-PRO2 Thetis-I (2611011021010), a radio module with Wirepas Mesh Protocol from Würth Elektronik. It supports creating a Wirepas routing mesh protocol and is optimized for ultra-low energy consumption. The large scalability is ideal for extensive IoT networks and can work as a host-controlled device.

click Product page


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 :

Example key functions :

  • wirepas_send_command Wirepas send command function.
    err_t wirepas_send_command ( wirepas_t *ctx, uint8_t primitive_id, uint8_t payload_length, uint8_t *payload );
    err_t wirepas_send_command(wirepas_t *ctx, uint8_t primitive_id, uint8_t payload_length, uint8_t *payload)
    Wirepas send command function.
  • wirepas_write_csap_attribute Wirepas write CSAP attribute function.
    err_t wirepas_write_csap_attribute ( wirepas_t *ctx, uint16_t attribute_id, uint8_t attribute_len, uint8_t *attribute_val );
    err_t wirepas_write_csap_attribute(wirepas_t *ctx, 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, wirepas_sink_data sink_data, uint8_t tx_op, uint8_t apdu_length, uint8_t *apdu );
    err_t wirepas_send_data(wirepas_t *ctx, wirepas_sink_data sink_data, uint8_t tx_op, uint8_t apdu_length, uint8_t *apdu)
    Wirepas send data function.
    Wirepas Click sink data object.
    Definition wirepas.h:248

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 channel addresses, and starting stack.

void application_init ( void )
{
log_cfg_t log_cfg;
wirepas_cfg_t wirepas_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
wirepas_cfg_setup( &wirepas_cfg );
WIREPAS_MAP_MIKROBUS( wirepas_cfg, MIKROBUS_1 );
if ( UART_ERROR == wirepas_init( &wirepas, &wirepas_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
wirepas_default_cfg ( &wirepas );
wirepas.tx_frame_id = 0;
do
{
log_printf( &logger, " Wirepas stack stop request:" );
}
Delay_ms ( 1000 );
do
{
log_printf( &logger, " Wirepas factory reset request:" );
}
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
do
{
log_printf( &logger, " Set node address:" );
}
Delay_ms ( 1000 );
do
{
log_printf( &logger, " Set net address:" );
}
Delay_ms ( 1000 );
uint8_t channel_net = CHANNEL_ADDRESS;
do
{
log_printf( &logger, " Set channel address:" );
}
Delay_ms ( 1000 );
uint8_t role;
#if ( ROUTER_NODE_ADDRESS == NODE_ADDRESS )
#else
#endif
do
{
log_printf( &logger, " Set role:" );
}
Delay_1sec( );
do
{
log_printf( &logger, " Wirepas Stack start request:" );
}
Delay_1sec( );
#if ( ROUTER_NODE_ADDRESS == NODE_ADDRESS )
sink_1.pduid = 0x00;
#if defined MULTI_SINK_MODE
sink_2.pduid = 0x00;
#endif
#endif
Delay_ms ( 100 );
log_info( &logger, " Application Task " );
}
#define WIREPAS_MSAP_STACK_STOP_CONFIRM
Definition wirepas.h:96
#define WIREPAS_MSAP_STACK_START_REQUEST
Definition wirepas.h:93
#define WIREPAS_CSAP_FACTORY_RESET_CONFIRM
Definition wirepas.h:113
#define WIREPAS_CSAP_ATTRIBUTE_WRITE_CONFIRM
Definition wirepas.h:109
#define WIREPAS_CSAP_ATTRIBUTE_NETWORK_CHANNEL
Definition wirepas.h:121
#define WIREPAS_FACTORY_RESET_CODE
Wirepas factory reset code.
Definition wirepas.h:128
#define WIREPAS_SINK_NODE_MODE
Definition wirepas.h:141
#define WIREPAS_MSAP_STACK_START_CONFIRM
Definition wirepas.h:94
#define WIREPAS_ROUTER_NODE_MODE
Wirepas node role mode settings.
Definition wirepas.h:140
#define WIREPAS_CSAP_FACTORY_RESET_REQUEST
Definition wirepas.h:112
#define WIREPAS_MSAP_STACK_STOP_REQUEST
Definition wirepas.h:95
#define WIREPAS_CSAP_ATTRIBUTE_NODE_ROLE
Definition wirepas.h:122
#define WIREPAS_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition wirepas.h:174
err_t wirepas_set_node_address(wirepas_t *ctx, uint32_t address)
Wirepas set node address function.
err_t wirepas_set_net_address(wirepas_t *ctx, uint32_t net_address)
Wirepas set net address function.
err_t wirepas_wait_response(wirepas_t *ctx, uint8_t primitive_id)
Wirepas wait response function.
Definition main.c:254
void application_init(void)
Definition main.c:101
#define SINK_1_NODE_ADDRESS
Definition main.c:46
#define CHANNEL_ADDRESS
Definition main.c:49
wirepas_sink_data sink_1
Definition main.c:58
wirepas_sink_data sink_2
Definition main.c:59
#define SINK_2_NODE_ADDRESS
Definition main.c:47
#define NET_ADDRESS
Definition main.c:48
uint8_t stack_auto_start
Definition main.c:56
#define NODE_ADDRESS
Definition main.c:51
uint32_t destination_addr
Definition wirepas.h:251
uint8_t source_endpoint
Definition wirepas.h:250
uint16_t pduid
Definition wirepas.h:249
uint8_t destination_endpoint
Definition wirepas.h:252
@ WIREPAS_OK
Definition wirepas.h:262

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.

void application_task ( void )
{
#if ( ROUTER_NODE_ADDRESS == NODE_ADDRESS )
if ( wirepas_get_din_state ( &wirepas ) && ( pdu_capacity > 0 ) )
{
log_printf( &logger, " Sending data to the first Sink node: \n" );
wirepas_send_data ( &wirepas, sink_1, 0x01, strlen( TX_DATA ), TX_DATA );
Delay_ms ( 1000 );
#if defined MULTI_SINK_MODE
log_printf( &logger, " Sending data to the second Sink node: \n" );
wirepas_send_data ( &wirepas, sink_2, 0x01, strlen( TX_DATA ), TX_DATA );
Delay_ms ( 1000 );
#endif
}
#endif
}
#define WIREPAS_DSAP_DATA_TX_CONFIRM
Definition wirepas.h:79
uint8_t wirepas_get_din_state(wirepas_t *ctx)
Wirepas get DIN state function.
err_t wirepas_poll_indication(wirepas_t *ctx)
Wirepas send poll indication function function.
Definition main.c:402
void application_task(void)
Definition main.c:216
uint8_t pdu_capacity
Definition main.c:57
#define TX_DATA
Definition main.c:37

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.