wirepas 2.1.0.0
main.c File Reference

Wirepas Click Example. More...

#include "board.h"
#include "log.h"
#include "wirepas.h"

Macros

#define PROCESS_BUFFER_SIZE   300
 
#define TX_DATA   "Wirepas Click"
 
#define MULTI_SINK_MODE
 
#define ROUTER_NODE_ADDRESS   0x01
 Wirepas node addresses.
 
#define SINK_1_NODE_ADDRESS   0x02
 
#define SINK_2_NODE_ADDRESS   0x03
 
#define NET_ADDRESS   0x01
 
#define CHANNEL_ADDRESS   0x01
 
#define NODE_ADDRESS
 

Functions

err_t wirepas_wait_response (wirepas_t *ctx, uint8_t primitive_id)
 Wirepas wait response function.
 
err_t wirepas_parse_frame (wirepas_t *ctx, uint8_t primitive_id)
 Wirepas parse frame function.
 
err_t wirepas_poll_indication (wirepas_t *ctx)
 Wirepas send poll indication function function.
 
void application_init (void)
 
void application_task (void)
 
int main (void)
 

Variables

uint8_t frame_id = 0
 
uint8_t stack_auto_start = 1
 
uint8_t pdu_capacity = 0x10
 
wirepas_sink_data sink_1
 
wirepas_sink_data sink_2
 

Detailed Description

Wirepas Click 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.

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.

Additional Function

  • err_t wirepas_wait_response ( wirepas_t *ctx, uint8_t primitive_id )
  • err_t wirepas_parse_frame ( wirepas_t *ctx, uint8_t primitive_id )
  • err_t wirepas_poll_indication ( wirepas_t *ctx )
Note
For the best experience use two clicks in sink mode and one in router.
Author
Stefan Ilic

Macro Definition Documentation

◆ CHANNEL_ADDRESS

#define CHANNEL_ADDRESS   0x01

◆ MULTI_SINK_MODE

#define MULTI_SINK_MODE

◆ NET_ADDRESS

#define NET_ADDRESS   0x01

◆ NODE_ADDRESS

#define NODE_ADDRESS
Value:
ROUTER_NODE_ADDRESS /* Change the value of this macro to change
node address, each node should have a unique address */
#define ROUTER_NODE_ADDRESS
Wirepas node addresses.
Definition main.c:45

◆ PROCESS_BUFFER_SIZE

#define PROCESS_BUFFER_SIZE   300

◆ ROUTER_NODE_ADDRESS

#define ROUTER_NODE_ADDRESS   0x01

Wirepas node addresses.

Specified setting for node addresses of Wirepas Click driver.

◆ SINK_1_NODE_ADDRESS

#define SINK_1_NODE_ADDRESS   0x02

◆ SINK_2_NODE_ADDRESS

#define SINK_2_NODE_ADDRESS   0x03

◆ TX_DATA

#define TX_DATA   "Wirepas Click"

Function Documentation

◆ application_init()

void application_init ( void )

< Logger config object.

< Click config object.

Logger initialization. Default baud rate: 115200 Default log level: LOG_LEVEL_DEBUG

Note
If USB_UART_RX and USB_UART_TX are defined as HAL_PIN_NC, you will need to define them manually for log to work. See LOG_MAP_USB_UART macro definition for detailed explanation.

◆ application_task()

void application_task ( void )

◆ main()

int main ( void )

◆ wirepas_parse_frame()

err_t wirepas_parse_frame ( wirepas_t * ctx,
uint8_t primitive_id )

Wirepas parse frame function.

This function is used to parse frame response from the device.

Parameters
[in]ctx: Click context object. See wirepas_t object definition for detailed explanation.
[in]primitive_id: Expected Primitive ID.
Returns
  • >=0 - Success,
  • <0 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ wirepas_poll_indication()

err_t wirepas_poll_indication ( wirepas_t * ctx)

Wirepas send poll indication function function.

This function is used to send poll indication, and get response from the device.

Parameters
[in]ctx: Click context object. See wirepas_t object definition for detailed explanation.
[in]primitive_id: Expected Primitive ID.
Returns
  • >=0 - Success,
  • <0 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ wirepas_wait_response()

err_t wirepas_wait_response ( wirepas_t * ctx,
uint8_t primitive_id )

Wirepas wait response function.

This function is used to get response from the device.

Parameters
[in]ctx: Click context object. See wirepas_t object definition for detailed explanation.
[in]primitive_id: Expected Primitive ID.
Returns
  • >=0 - Success,
  • <0 - Error. See #err_t definition for detailed explanation.
Note
None.

Variable Documentation

◆ frame_id

uint8_t frame_id = 0

◆ pdu_capacity

uint8_t pdu_capacity = 0x10

◆ sink_1

◆ sink_2

◆ stack_auto_start

uint8_t stack_auto_start = 1