wireless.h File Reference

This provides simplified way to send/receive data from Nordic wireless chip. ALL WIRELESS DATA should be sent/received through this API. More...

#include <stdbool.h>
#include "src/mesh.h"
#include "src/mesh_typedefs.h"
Include dependency graph for wireless.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define wireless_form_pkt(pkt, dst, protocol, max_hops, num_ptrs, args...)   mesh_form_pkt(pkt, dst, protocol, max_hops, num_ptrs, args)
 Just a wrapper around mesh_form_pkt() to put all wireless related API at this file. More...
 
#define wireless_deform_pkt(pkt, num_ptrs, args...)   mesh_deform_pkt(pkt, num_ptrs, args)
 Just a wrapper around mesh_deform_pkt() to put all wireless related API at this file. More...
 

Functions

bool wireless_init (void)
 
void wireless_service (void)
 
char wireless_get_rx_pkt (mesh_packet_t *pkt, const uint32_t timeout_ms)
 
char wireless_get_ack_pkt (mesh_packet_t *pkt, const uint32_t timeout_ms)
 Same as wireless_get_rx_pkt(), except this will retrieve an ACK response. More...
 
int wireless_flush_rx (void)
 

Detailed Description

This provides simplified way to send/receive data from Nordic wireless chip. ALL WIRELESS DATA should be sent/received through this API.

Macro Definition Documentation

#define wireless_deform_pkt (   pkt,
  num_ptrs,
  args... 
)    mesh_deform_pkt(pkt, num_ptrs, args)

Just a wrapper around mesh_deform_pkt() to put all wireless related API at this file.

#define wireless_form_pkt (   pkt,
  dst,
  protocol,
  max_hops,
  num_ptrs,
  args... 
)    mesh_form_pkt(pkt, dst, protocol, max_hops, num_ptrs, args)

Just a wrapper around mesh_form_pkt() to put all wireless related API at this file.

Function Documentation

int wireless_flush_rx ( void  )

Flush all received data of mesh (ACKs and RX packets)

Returns
the discarded packet count
char wireless_get_ack_pkt ( mesh_packet_t *  pkt,
const uint32_t  timeout_ms 
)

Same as wireless_get_rx_pkt(), except this will retrieve an ACK response.

char wireless_get_rx_pkt ( mesh_packet_t *  pkt,
const uint32_t  timeout_ms 
)

Call this function periodically to get a queued packet.

Parameters
timeout_msThe number of milliseconds to wait for a packet. If FreeRTOS is running, then this becomes the queue wait time.
Returns
true if a packet was dequeued, or false if there is no packet.

Here is an example of how to send a packet and ensure the destined node received the data :

1 wireless_send(destination, mesh_pkt_ack, "Hello", 5, 3);
2 mesh_packet_t rx;
3 
4 if (wireless_get_ack_pkt(&rx, 100)) {
5  // We got an ACK, but to be sure it came from the right place, check:
6  // if(rx.nwk.src == destination)
7 }
bool wireless_init ( void  )

Initializes nordic driver layer and the mesh network layer. This is already called before main() function is run.

Returns
true if everything is successful.
void wireless_service ( void  )

Calls mesh_service() routine. This is encapsulated because this function will only call mesh_service() when there is either a pending packet or a packet received as indicated by nordic interrupt. This function is called through RIT or through FreeRTOS tick hook, so you don't have to call it yourself.