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 :

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 " );
}

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
}

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.


wirepas_cfg_setup
void wirepas_cfg_setup(wirepas_cfg_t *cfg)
Wirepas configuration object setup function.
wirepas_cfg_t
Wirepas Click configuration object.
Definition: wirepas.h:225
CHANNEL_ADDRESS
#define CHANNEL_ADDRESS
Definition: main.c:49
WIREPAS_CSAP_ATTRIBUTE_NETWORK_CHANNEL
#define WIREPAS_CSAP_ATTRIBUTE_NETWORK_CHANNEL
Definition: wirepas.h:121
SINK_1_NODE_ADDRESS
#define SINK_1_NODE_ADDRESS
Definition: main.c:46
wirepas_default_cfg
void wirepas_default_cfg(wirepas_t *ctx)
Wirepas default configuration function.
wirepas_sink_data::destination_endpoint
uint8_t destination_endpoint
Definition: wirepas.h:252
wirepas_set_net_address
err_t wirepas_set_net_address(wirepas_t *ctx, uint32_t net_address)
Wirepas set net address function.
WIREPAS_MSAP_STACK_STOP_REQUEST
#define WIREPAS_MSAP_STACK_STOP_REQUEST
Definition: wirepas.h:95
WIREPAS_CSAP_ATTRIBUTE_NODE_ROLE
#define WIREPAS_CSAP_ATTRIBUTE_NODE_ROLE
Definition: wirepas.h:122
WIREPAS_FACTORY_RESET_CODE
#define WIREPAS_FACTORY_RESET_CODE
Wirepas factory reset code.
Definition: wirepas.h:128
WIREPAS_MSAP_STACK_STOP_CONFIRM
#define WIREPAS_MSAP_STACK_STOP_CONFIRM
Definition: wirepas.h:96
NET_ADDRESS
#define NET_ADDRESS
Definition: main.c:48
application_task
void application_task(void)
Definition: main.c:216
WIREPAS_MSAP_STACK_START_REQUEST
#define WIREPAS_MSAP_STACK_START_REQUEST
Definition: wirepas.h:93
sink_1
wirepas_sink_data sink_1
Definition: main.c:58
WIREPAS_MAP_MIKROBUS
#define WIREPAS_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: wirepas.h:174
wirepas_get_din_state
uint8_t wirepas_get_din_state(wirepas_t *ctx)
Wirepas get DIN state function.
WIREPAS_CSAP_FACTORY_RESET_REQUEST
#define WIREPAS_CSAP_FACTORY_RESET_REQUEST
Definition: wirepas.h:112
WIREPAS_ROUTER_NODE_MODE
#define WIREPAS_ROUTER_NODE_MODE
Wirepas node role mode settings.
Definition: wirepas.h:140
wirepas_set_node_address
err_t wirepas_set_node_address(wirepas_t *ctx, uint32_t address)
Wirepas set node address function.
wirepas_send_data
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_CSAP_ATTRIBUTE_WRITE_CONFIRM
#define WIREPAS_CSAP_ATTRIBUTE_WRITE_CONFIRM
Definition: wirepas.h:109
wirepas_write_csap_attribute
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_sink_data::source_endpoint
uint8_t source_endpoint
Definition: wirepas.h:250
SINK_2_NODE_ADDRESS
#define SINK_2_NODE_ADDRESS
Definition: main.c:47
wirepas_t
Wirepas Click context object.
Definition: wirepas.h:201
WIREPAS_CSAP_FACTORY_RESET_CONFIRM
#define WIREPAS_CSAP_FACTORY_RESET_CONFIRM
Definition: wirepas.h:113
wirepas_sink_data::pduid
uint16_t pduid
Definition: wirepas.h:249
wirepas_poll_indication
err_t wirepas_poll_indication(wirepas_t *ctx)
Wirepas send poll indication function function.
Definition: main.c:402
application_init
void application_init(void)
Definition: main.c:101
wirepas_wait_response
err_t wirepas_wait_response(wirepas_t *ctx, uint8_t primitive_id)
Wirepas wait response function.
Definition: main.c:254
wirepas_send_command
err_t wirepas_send_command(wirepas_t *ctx, uint8_t primitive_id, uint8_t payload_length, uint8_t *payload)
Wirepas send command function.
TX_DATA
#define TX_DATA
Definition: main.c:37
WIREPAS_MSAP_STACK_START_CONFIRM
#define WIREPAS_MSAP_STACK_START_CONFIRM
Definition: wirepas.h:94
sink_2
wirepas_sink_data sink_2
Definition: main.c:59
pdu_capacity
uint8_t pdu_capacity
Definition: main.c:57
stack_auto_start
uint8_t stack_auto_start
Definition: main.c:56
wirepas_sink_data
Wirepas Click sink data object.
Definition: wirepas.h:248
WIREPAS_OK
@ WIREPAS_OK
Definition: wirepas.h:262
wirepas_sink_data::destination_addr
uint32_t destination_addr
Definition: wirepas.h:251
WIREPAS_DSAP_DATA_TX_CONFIRM
#define WIREPAS_DSAP_DATA_TX_CONFIRM
Definition: wirepas.h:79
NODE_ADDRESS
#define NODE_ADDRESS
Definition: main.c:51
WIREPAS_SINK_NODE_MODE
#define WIREPAS_SINK_NODE_MODE
Definition: wirepas.h:141
wirepas_init
err_t wirepas_init(wirepas_t *ctx, wirepas_cfg_t *cfg)
Wirepas initialization function.