neomesh915mhz  2.1.0.0
Main Page

NeoMesh 915MHz Click

NeoMesh Click - 915MHz is a compact add-on board with a low-power, long-range transceiver, ideal for Mesh wireless networking. This board features the NC1000C-9, a wireless Mesh network module from NeoCortec. With an additional antenna that MikroE offers connected to the module’s u.Fl connector, you can create a fully functional wireless Mesh network node that will work in the Sub-GHz frequency band of 915MHz. The module has a generic application layer that can configured to suit applications.

Click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Sep 2023.
  • Type : UART type

Software Support

We provide a library for the NeoMesh 915MHz 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 NeoMesh 915MHz Click driver.

Standard key functions :

Example key functions :

Example Description

This example demonstrates the use of NeoMesh 915MHz Click board by showing the communication between the two Click boards.

The demo application is composed of two sections :

Application Init

Initializes the driver and configures the Click board for the selected application mode.

void application_init ( void )
{
log_cfg_t log_cfg;
neomesh915mhz_cfg_t neomesh915mhz_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
neomesh915mhz_cfg_setup( &neomesh915mhz_cfg );
NEOMESH915MHZ_MAP_MIKROBUS( neomesh915mhz_cfg, MIKROBUS_1 );
if ( UART_ERROR == neomesh915mhz_init( &neomesh915mhz, &neomesh915mhz_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_printf( &logger, "\r\n Enable SAPI over AAPI\r\n" );
aapi_frame.len = 0;
neomesh915mhz_send_aapi_frame ( &neomesh915mhz, &aapi_frame );
neomesh915mhz_parse_sapi_rsp ( NEOMESH915MHZ_SAPI_RSP_BOOTLOADER_START );
log_printf( &logger, "\r\n Login with password\r\n" );
sapi_frame.cmd = NEOMESH915MHZ_SAPI_CMD_LOGIN;
sapi_frame.len = 5;
sapi_frame.payload[ 0 ] = NEOMESH915MHZ_SAPI_LOGIN_PASSWORD_0;
sapi_frame.payload[ 1 ] = NEOMESH915MHZ_SAPI_LOGIN_PASSWORD_1;
sapi_frame.payload[ 2 ] = NEOMESH915MHZ_SAPI_LOGIN_PASSWORD_2;
sapi_frame.payload[ 3 ] = NEOMESH915MHZ_SAPI_LOGIN_PASSWORD_3;
sapi_frame.payload[ 4 ] = NEOMESH915MHZ_SAPI_LOGIN_PASSWORD_4;
neomesh915mhz_send_sapi_frame ( &neomesh915mhz, &sapi_frame );
neomesh915mhz_parse_sapi_rsp ( NEOMESH915MHZ_SAPI_RSP_OK );
log_printf( &logger, "\r\n Set NODE ID to: " );
sapi_frame.len = 3;
sapi_frame.payload[ 0 ] = NEOMESH915MHZ_SAPI_SETTINGS_ID_NODE_ID;
#if ( DEMO_APP == APP_RECEIVER_1 )
log_printf( &logger, "%.4X\r\n", ( uint16_t ) NODE_ID_RECEIVER_1 );
sapi_frame.payload[ 1 ] = ( uint8_t ) ( ( NODE_ID_RECEIVER_1 >> 8 ) & 0xFF );
sapi_frame.payload[ 2 ] = ( uint8_t ) ( NODE_ID_RECEIVER_1 & 0xFF );
#elif ( DEMO_APP == APP_RECEIVER_2 )
log_printf( &logger, "%.4X\r\n", ( uint16_t ) NODE_ID_RECEIVER_2 );
sapi_frame.payload[ 1 ] = ( uint8_t ) ( ( NODE_ID_RECEIVER_2 >> 8 ) & 0xFF );
sapi_frame.payload[ 2 ] = ( uint8_t ) ( NODE_ID_RECEIVER_2 & 0xFF );
#elif ( DEMO_APP == APP_ORIGINATOR )
log_printf( &logger, "%.4X\r\n", ( uint16_t ) NODE_ID_ORIGINATOR );
sapi_frame.payload[ 1 ] = ( uint8_t ) ( ( NODE_ID_ORIGINATOR >> 8 ) & 0xFF );
sapi_frame.payload[ 2 ] = ( uint8_t ) ( NODE_ID_ORIGINATOR & 0xFF );
#endif
neomesh915mhz_send_sapi_frame ( &neomesh915mhz, &sapi_frame );
neomesh915mhz_parse_sapi_rsp ( NEOMESH915MHZ_SAPI_RSP_OK );
log_printf( &logger, "\r\n Commit settings\r\n" );
sapi_frame.len = 0;
neomesh915mhz_send_sapi_frame ( &neomesh915mhz, &sapi_frame );
neomesh915mhz_parse_sapi_rsp ( NEOMESH915MHZ_SAPI_RSP_OK );
log_printf( &logger, "\r\n Start protocol stack\r\n" );
sapi_frame.len = 0;
neomesh915mhz_send_sapi_frame ( &neomesh915mhz, &sapi_frame );
neomesh915mhz_parse_sapi_rsp ( NEOMESH915MHZ_SAPI_RSP_PROTOCOL_STACK_START );
// Wait for the device to actually switch back to application layer
while ( !neomesh915mhz_get_cts_pin ( &neomesh915mhz ) );
log_printf( &logger, "\r\n Get NODE info\r\n" );
aapi_frame.cmd = NEOMESH915MHZ_CMD_NODE_INFO;
aapi_frame.len = 0;
neomesh915mhz_send_aapi_frame ( &neomesh915mhz, &aapi_frame );
neomesh915mhz_parse_aapi_rsp ( NEOMESH915MHZ_RSP_NODE_INFO );
log_printf( &logger, "\r\n Get neighbour list\r\n" );
aapi_frame.len = 0;
neomesh915mhz_send_aapi_frame ( &neomesh915mhz, &aapi_frame );
neomesh915mhz_parse_aapi_rsp ( NEOMESH915MHZ_RSP_NEIGHBOUR_LIST );
#if ( DEMO_APP == APP_RECEIVER_1 )
log_printf( &logger, "\r\n Application Mode: Receiver 1\r\n" );
#elif ( DEMO_APP == APP_RECEIVER_2 )
log_printf( &logger, "\r\n Application Mode: Receiver 2\r\n" );
#elif ( DEMO_APP == APP_ORIGINATOR )
log_printf( &logger, "\r\n Application Mode: Originator\r\n" );
#else
#error "Selected application mode is not supported!"
#endif
log_info( &logger, " Application Task " );
}

Application Task

One Click board should be set to originator mode and the others to receiver 1 or 2.

If the SINGLE_RECEIVER_MODE is enabled, the originator device sends a desired message to RECEIVER_1 node and waits for an acknowledge response, otherwise it sends the same message to both RECEIVER_1 and RECEIVER_2 nodes. The receiver devices reads and parses all incoming AAPI frames and displays them on the USB UART.

void application_task ( void )
{
#if ( DEMO_APP == APP_ORIGINATOR )
log_printf( &logger, "\r\n Send message to node: %.4X\r\n", ( uint16_t ) NODE_ID_RECEIVER_1 );
aapi_frame.cmd = NEOMESH915MHZ_CMD_ACK_SEND;
aapi_frame.len = 3 + strlen ( DEMO_TEXT_MESSAGE );
aapi_frame.payload[ 0 ] = ( uint8_t ) ( ( NODE_ID_RECEIVER_1 >> 8 ) & 0xFF );
aapi_frame.payload[ 1 ] = ( uint8_t ) ( NODE_ID_RECEIVER_1 & 0xFF );
aapi_frame.payload[ 2 ] = DEFAULT_PORT;
strcpy ( &aapi_frame.payload[ 3 ], DEMO_TEXT_MESSAGE );
if ( NEOMESH915MHZ_OK == neomesh915mhz_send_aapi_frame ( &neomesh915mhz, &aapi_frame ) )
{
neomesh915mhz_parse_aapi_rsp ( NEOMESH915MHZ_RSP_ACK );
}
#ifndef SINGLE_RECEIVER_MODE
log_printf( &logger, "\r\n Send message to node: %.4X\r\n", ( uint16_t ) NODE_ID_RECEIVER_2 );
aapi_frame.cmd = NEOMESH915MHZ_CMD_ACK_SEND;
aapi_frame.len = 3 + strlen ( DEMO_TEXT_MESSAGE );
aapi_frame.payload[ 0 ] = ( uint8_t ) ( ( NODE_ID_RECEIVER_2 >> 8 ) & 0xFF );
aapi_frame.payload[ 1 ] = ( uint8_t ) ( NODE_ID_RECEIVER_2 & 0xFF );
aapi_frame.payload[ 2 ] = DEFAULT_PORT;
strcpy ( &aapi_frame.payload[ 3 ], DEMO_TEXT_MESSAGE );
if ( NEOMESH915MHZ_OK == neomesh915mhz_send_aapi_frame ( &neomesh915mhz, &aapi_frame ) )
{
neomesh915mhz_parse_aapi_rsp ( NEOMESH915MHZ_RSP_ACK );
}
#endif
#else
neomesh915mhz_parse_aapi_rsp ( NULL );
#endif
}

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.NeoMesh915MHz

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.


neomesh915mhz_send_aapi_frame
err_t neomesh915mhz_send_aapi_frame(neomesh915mhz_t *ctx, neomesh915mhz_aapi_frame_t *frame)
NeoMesh 915MHz send aapi frame function.
NEOMESH915MHZ_RSP_NEIGHBOUR_LIST
#define NEOMESH915MHZ_RSP_NEIGHBOUR_LIST
Definition: neomesh915mhz.h:99
DEFAULT_PORT
#define DEFAULT_PORT
Definition: main.c:41
NEOMESH915MHZ_RSP_ACK
#define NEOMESH915MHZ_RSP_ACK
NeoMesh 915MHz application data response.
Definition: neomesh915mhz.h:90
NEOMESH915MHZ_SAPI_CMD_COMMIT_SETTINGS
#define NEOMESH915MHZ_SAPI_CMD_COMMIT_SETTINGS
Definition: neomesh915mhz.h:116
NEOMESH915MHZ_SAPI_LOGIN_PASSWORD_2
#define NEOMESH915MHZ_SAPI_LOGIN_PASSWORD_2
Definition: neomesh915mhz.h:143
NEOMESH915MHZ_CMD_ACK_SEND
#define NEOMESH915MHZ_CMD_ACK_SEND
Definition: neomesh915mhz.h:74
NEOMESH915MHZ_SAPI_LOGIN_PASSWORD_3
#define NEOMESH915MHZ_SAPI_LOGIN_PASSWORD_3
Definition: neomesh915mhz.h:144
NEOMESH915MHZ_SAPI_LOGIN_PASSWORD_4
#define NEOMESH915MHZ_SAPI_LOGIN_PASSWORD_4
Definition: neomesh915mhz.h:145
NEOMESH915MHZ_RSP_NODE_INFO
#define NEOMESH915MHZ_RSP_NODE_INFO
Definition: neomesh915mhz.h:98
application_task
void application_task(void)
Definition: main.c:178
neomesh915mhz_sapi_frame_t
NeoMesh 915MHz Click data frame object.
Definition: neomesh915mhz.h:268
NEOMESH915MHZ_SAPI_CMD_START_PROTOCOL_STACK
#define NEOMESH915MHZ_SAPI_CMD_START_PROTOCOL_STACK
Definition: neomesh915mhz.h:119
NEOMESH915MHZ_SAPI_RSP_OK
#define NEOMESH915MHZ_SAPI_RSP_OK
NeoMesh 915MHz system data response.
Definition: neomesh915mhz.h:128
NEOMESH915MHZ_SAPI_CMD_LOGIN
#define NEOMESH915MHZ_SAPI_CMD_LOGIN
NeoMesh 915MHz SAPI control commands.
Definition: neomesh915mhz.h:111
NEOMESH915MHZ_SAPI_LOGIN_PASSWORD_0
#define NEOMESH915MHZ_SAPI_LOGIN_PASSWORD_0
NeoMesh 915MHz login password settings.
Definition: neomesh915mhz.h:141
NEOMESH915MHZ_SAPI_LOGIN_PASSWORD_1
#define NEOMESH915MHZ_SAPI_LOGIN_PASSWORD_1
Definition: neomesh915mhz.h:142
neomesh915mhz_aapi_frame_t
NeoMesh 915MHz Click data frame object.
Definition: neomesh915mhz.h:256
neomesh915mhz_init
err_t neomesh915mhz_init(neomesh915mhz_t *ctx, neomesh915mhz_cfg_t *cfg)
NeoMesh 915MHz initialization function.
NEOMESH915MHZ_MAP_MIKROBUS
#define NEOMESH915MHZ_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: neomesh915mhz.h:189
NEOMESH915MHZ_SAPI_RSP_PROTOCOL_STACK_START
#define NEOMESH915MHZ_SAPI_RSP_PROTOCOL_STACK_START
Definition: neomesh915mhz.h:131
NEOMESH915MHZ_SAPI_SETTINGS_ID_NODE_ID
#define NEOMESH915MHZ_SAPI_SETTINGS_ID_NODE_ID
NeoMesh 915MHz SAPI settings ID.
Definition: neomesh915mhz.h:151
neomesh915mhz_t
NeoMesh 915MHz Click context object.
Definition: neomesh915mhz.h:206
NEOMESH915MHZ_CMD_NEIGHBOUR_LIST
#define NEOMESH915MHZ_CMD_NEIGHBOUR_LIST
Definition: neomesh915mhz.h:77
neomesh915mhz_get_cts_pin
uint8_t neomesh915mhz_get_cts_pin(neomesh915mhz_t *ctx)
NeoMesh 915MHz get cts pin function.
NEOMESH915MHZ_CMD_SAPI_TO_AAPI
#define NEOMESH915MHZ_CMD_SAPI_TO_AAPI
Definition: neomesh915mhz.h:79
neomesh915mhz_cfg_t
NeoMesh 915MHz Click configuration object.
Definition: neomesh915mhz.h:230
NODE_ID_ORIGINATOR
#define NODE_ID_ORIGINATOR
Definition: main.c:44
NEOMESH915MHZ_CMD_NODE_INFO
#define NEOMESH915MHZ_CMD_NODE_INFO
Definition: neomesh915mhz.h:76
application_init
void application_init(void)
Definition: main.c:75
neomesh915mhz_read_aapi_frame
err_t neomesh915mhz_read_aapi_frame(neomesh915mhz_t *ctx, neomesh915mhz_aapi_frame_t *frame)
NeoMesh 915MHz read aapi frame function.
NODE_ID_RECEIVER_1
#define NODE_ID_RECEIVER_1
Definition: main.c:45
NODE_ID_RECEIVER_2
#define NODE_ID_RECEIVER_2
Definition: main.c:46
NEOMESH915MHZ_SAPI_CMD_SET_SETTING
#define NEOMESH915MHZ_SAPI_CMD_SET_SETTING
Definition: neomesh915mhz.h:118
NEOMESH915MHZ_OK
@ NEOMESH915MHZ_OK
Definition: neomesh915mhz.h:281
DEMO_TEXT_MESSAGE
#define DEMO_TEXT_MESSAGE
Definition: main.c:40
neomesh915mhz_cfg_setup
void neomesh915mhz_cfg_setup(neomesh915mhz_cfg_t *cfg)
NeoMesh 915MHz configuration object setup function.
neomesh915mhz_send_sapi_frame
err_t neomesh915mhz_send_sapi_frame(neomesh915mhz_t *ctx, neomesh915mhz_sapi_frame_t *frame)
NeoMesh 915MHz send sapi frame function.
NEOMESH915MHZ_SAPI_RSP_BOOTLOADER_START
#define NEOMESH915MHZ_SAPI_RSP_BOOTLOADER_START
Definition: neomesh915mhz.h:130