MiraOS  v1.0 2016-02-20
Typedefs | Enumerations | Functions
miralib.h File Reference

Main include file for the MiraOS library. More...

#include "sys/autostart.h"
#include "sys/process.h"
#include "sys/etimer.h"
#include "mira_gpio.h"
#include "mira_adc.h"
#include "mira_pwm.h"
#include "mira_i2c.h"
#include "mira_spi.h"
#include <stdint.h>

Go to the source code of this file.

Typedefs

typedef void(* MiraReceivedDataCallback) (uint8_t *data_ptr, uint8_t length, MiraAddressType address_type, uint8_t *address_ptr)
 Function pointer to receive callback. More...
 

Enumerations

enum  MiraErrorType { MIRA_NOERROR = 0, MIRA_ERROR_UNKNOWN_ADDRESS = -1, MIRA_ERROR_UNSUPPORTED_SIZE = -2 }
 Return error codes for Mira library functions. More...
 
enum  MiraAddressType { MIRA_TO_EUI64 = 0x12, MIRA_TO_ROOT = 0x21, MIRA_TO_LOCAL = 0x41, MIRA_TO_BROADCAST = 0x81 }
 Supported addressing modes for Mira messages. More...
 
enum  MiraAntennaType { MIRA_CHIP_ANTENNA = 0, MIRA_EXT_ANTENNA = 1 }
 Antenna options. More...
 

Functions

MiraErrorType mira_send_data (MiraAddressType address_type, uint8_t *address_ptr, uint8_t *data_ptr, uint8_t length)
 Function to send a data message. More...
 
void mira_register_data_received_callback (MiraReceivedDataCallback callback)
 Register the received data callback. More...
 
void mira_set_credentials (uint16_t pan_id, uint8_t *aes_key)
 Sets the network credentials to use. More...
 
void mira_become_root (void)
 Become the network root. More...
 
void mira_commit_network_setup (void)
 Commit the network setup and start routing traffic. More...
 
void mira_set_name (char *name)
 Set the node name. More...
 
void mira_select_antenna (MiraAntennaType antenna)
 Selects the antenna option. More...
 
void mira_disable_rf_frontend (void)
 Disables the RF frontend. More...
 
void mira_enable_rf_frontend (void)
 Enables the RF frontend. More...
 
void mira_reboot (void)
 Reboots the module. More...
 
void mira_init (void)
 Initializes the library. More...
 

Detailed Description

Main include file for the MiraOS library.

Author
LumenRadio AB
Date
17 Jan 2016 The MiraOS library provides functions for controlling the Mira radio module, sending/receiving messages, controlling peripherals, etc.
See also
http://docs.lumenrad.io/mira

Typedef Documentation

typedef void(* MiraReceivedDataCallback) (uint8_t *data_ptr, uint8_t length, MiraAddressType address_type, uint8_t *address_ptr)

Function pointer to receive callback.

Parameters
data_ptra pointer to the received data
lengththe length of the received data
address_typeaddressing mode that was used for the message
address_ptra pointer to the destination address, NULL of none.
Returns
void

Enumeration Type Documentation

Supported addressing modes for Mira messages.

Enumerator
MIRA_TO_EUI64 

EUI64 destination address

MIRA_TO_ROOT 

Send to network root (no address needed)

MIRA_TO_LOCAL 

Send to local neighbours (no address needed)

MIRA_TO_BROADCAST 

Broadcast to entire network (no address needed)

Antenna options.

Enumerator
MIRA_CHIP_ANTENNA 

Integrated chip antenna

MIRA_EXT_ANTENNA 

Antenna connector for external antenna

Return error codes for Mira library functions.

Enumerator
MIRA_NOERROR 

Success

MIRA_ERROR_UNKNOWN_ADDRESS 

Unknown address type

MIRA_ERROR_UNSUPPORTED_SIZE 

Message is larger than allowed

Function Documentation

void mira_become_root ( void  )

Become the network root.

Each network must have a network root that sets up the network and coordinates and synchronizes the frequency hopping as well as setting up routes. Calling this function causes this node to become a root. Currently, there may not be more than one root on one network at a time.

Returns
void
void mira_commit_network_setup ( void  )

Commit the network setup and start routing traffic.

When setting up the network, this function shall be called to make all network settings take effect. This will start the routing protocol. If this function is not called, only broadcast traffic will work.

Returns
void
void mira_disable_rf_frontend ( void  )

Disables the RF frontend.

If RF frontend is disabled, the module will run at the maximum output power it can without the PA. Note: this also disables the LNA.

Returns
void
void mira_enable_rf_frontend ( void  )

Enables the RF frontend.

This enabled both PA and LNA in the RF frontend. The module will consume some more energy, but will get greater range due to better receiver sensitivity and higher output power.

Returns
void
void mira_init ( void  )

Initializes the library.

The Mira library must be initialized before any other mira functions are used. Failure to do so may result in unexpected behaviour.

Returns
void
void mira_reboot ( void  )

Reboots the module.

Returns
void
void mira_register_data_received_callback ( MiraReceivedDataCallback  callback)

Register the received data callback.

The received data callback will be called every time a new data message is received.

Parameters
callbacka function pointer to the callback function
Returns
void
void mira_select_antenna ( MiraAntennaType  antenna)

Selects the antenna option.

Selects if to use the internal chip antenna or if to use the antenna connector connected to an external antenna.

Parameters
antennathe antenna option to use.
Returns
void
MiraErrorType mira_send_data ( MiraAddressType  address_type,
uint8_t *  address_ptr,
uint8_t *  data_ptr,
uint8_t  length 
)

Function to send a data message.

Parameters
address_typeadressing mode to use for this message
address_ptrpointer to the destination address, format must match address_type parameters
data_ptrpointer to the data to be sent
lengththe length of the data
Returns
MiraErrorType
void mira_set_credentials ( uint16_t  pan_id,
uint8_t *  aes_key 
)

Sets the network credentials to use.

Each network uses a set of credentials to be able to communicate. Network ID (aka. PAN ID) and AES encryption key need to be set to be able to participate in the communication on a network. This function overrides whatever may (or may not) be set using the comissioning application.

Parameters
pan_idthe PAN ID (network ID) to use
aes_keya pointer to the AES key to use
Returns
void
void mira_set_name ( char *  name)

Set the node name.

Sets the human readable node name for this node. This name will be returned as the device label of this node in the network statistics commands.

Parameters
nameA pointer to a null terminated string with the name.
Returns
void