enocean4 2.0.0.0
Main Page

EnOcean 4 click

EnOcean 4 Click carries a ultra-low power TCM515U transceiver gateway module which operates at 902MHz radio band, perfectly suited for the realization of transceiver gateways, actuators and controllers for systems communicating based on the EnOcean radio standard.

click Product page


Click library

  • Author : MikroE Team
  • Date : Jun 2020.
  • Type : UART type

Software Support

We provide a library for the Enocean4 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 form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.

Library Description

‍This library contains API for Enocean4 Click driver.

Standard key functions :

  • Config Object Initialization function.

    ‍void enocean4_cfg_setup ( enocean4_cfg_t *cfg );

    - Initialization function.

    ‍ENOCEAN4_RETVAL enocean4_init ( enocean4_t *ctx, enocean4_cfg_t *cfg );

    Example key functions :

  • Handler Set function.

    ‍void enocean4_response_handler_set( enocean4_t ctx, void ( *handler )( enocean4_packet_t, uint8_t* ) );

    - Response Proccesing function.

    ‍uint8_t enocean4_process ( enocean4_t *ctx );

  • Response Ready Check function.

    ‍uint8_t enocean4_response_ready ( enocean4_t *ctx );

    Examples Description

‍This example reads and processes data from EnOcean 4 clicks.

The demo application is composed of two sections :

Application Init

‍Initializes the driver and configures the click board.

void application_init ( void )
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
ENOCEAN4_MAP_MIKROBUS( cfg, MIKROBUS_1 );
enocean4_init( &enocean4, &cfg );
Delay_ms ( 500 );
Delay_ms ( 300 );
rsp_check = 1;
enocean4_reset( &enocean4 );
log_printf( &logger, "** EnOcean 4 initialization done **\r\n" );
log_printf( &logger, "***********************************\r\n" );
Delay_ms ( 500 );
// Clearing RX buffer
{
uint8_t tmp_buf[ 100 ];
enocean4_generic_read( &enocean4, tmp_buf, 100 );
}
log_printf( &logger, "Device version reading...\r\n" );
message.data_length = 0x0001;
enocean4_send_packet( &enocean4, &message );
log_printf( &logger, "***********************************\r\n" );
Delay_ms ( 1000 );
Delay_ms ( 500 );
log_printf( &logger, "Add filter to filter list...\r\n" );
message.data_length = 0x0007;
message.data_buff[ 2 ] = 0x00;
message.data_buff[ 3 ] = 0x00;
message.data_buff[ 4 ] = 0x00;
enocean4_send_packet( &enocean4, &message );
log_printf( &logger, "***********************************\r\n" );
Delay_ms ( 1000 );
Delay_ms ( 500 );
log_printf( &logger, "Supplied filters reading...\r\n" );
message.data_length = 0x0001;
enocean4_send_packet( &enocean4, &message );
log_printf( &logger, "***********************************\r\n" );
log_printf( &logger, "Ready to exchange telegrams\r\n" );
log_printf( &logger, "***********************************\r\n" );
Delay_ms ( 1000 );
Delay_ms ( 500 );
}
#define ENOCEAN4_CMD_CO_RD_VERSION
Definition enocean4.h:139
#define ENOCEAN4_RORG_ADT
Definition enocean4.h:119
#define ENOCEAN4_CMD_CO_WR_FILTER_ADD
Definition enocean4.h:147
#define ENOCEAN4_FILTER_TYPE_RORG
Definition enocean4.h:203
#define ENOCEAN4_PACK_TYPE_COMMON_CMD
Definition enocean4.h:111
#define ENOCEAN4_APPLY_RADIO_INTER
Definition enocean4.h:207
#define ENOCEAN4_CMD_CO_RD_FILTER
Definition enocean4.h:151
#define ENOCEAN4_MAP_MIKROBUS(cfg, mikrobus)
Definition enocean4.h:67
uint8_t enocean4_send_packet(enocean4_t *ctx, enocean4_packet_t *packet)
Packet Send function.
void enocean4_response_handler_set(enocean4_t *ctx, void(*handler)(enocean4_packet_t *, uint8_t *))
Handler Set function.
void enocean4_reset(enocean4_t *ctx)
Reset function.
ENOCEAN4_RETVAL enocean4_init(enocean4_t *ctx, enocean4_cfg_t *cfg)
Initialization function.
int32_t enocean4_generic_read(enocean4_t *ctx, char *data_buf, uint16_t max_len)
Generic read function.
void enocean4_cfg_setup(enocean4_cfg_t *cfg)
Config Object Initialization function.
void application_init(void)
Definition main.c:314
void make_response(enocean4_packet_t *rsp, uint8_t *rsp_length_size)
Definition main.c:174
enocean4_packet_t message
Definition main.c:45
uint8_t rsp_check
Definition main.c:47
void check_response()
Definition main.c:294
Click configuration structure definition.
Definition enocean4.h:258
uint16_t data_length
Definition enocean4.h:224
uint8_t opt_length
Definition enocean4.h:225
uint8_t data_buff[256]
Definition enocean4.h:227
uint8_t packet_type
Definition enocean4.h:226

Application Task

‍In the receiver mode, it waits for a telegram, then replies to it with the certain message. In the transmitter mode, first it sends the telegram with the certain message, then waits for a response.

void application_task ( void )
{
#ifdef DEMO_APP_RECEIVER
log_printf( &logger, "Waiting for a telegram...\r\n" );
log_printf( &logger, "***********************************\r\n" );
log_printf( &logger, "Replying to the received telegram...\r\n" );
log_printf( &logger, "***********************************\r\n" );
#endif
#ifdef DEMO_APP_TRANSMITTER
log_printf( &logger, "Sending a telegram...\r\n" );
log_printf( &logger, "***********************************\r\n" );
log_printf( &logger, "Waiting for a response...\r\n" );
log_printf( &logger, "***********************************\r\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
#endif
}
#define DEMO_ANSWER
Definition main.c:42
void application_task(void)
Definition main.c:397
#define DEMO_MESSAGE
Definition main.c:41
void send_telegram(char *telegram, uint8_t tel_type)
Definition main.c:229

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Enocean4

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. The terminal available in all Mikroelektronika compilers, or any other terminal application of your choice, can be used to read the message.