Skip to content

Network general

Types

Name Type Description
mira_link_metric_t uint16_t

Enums

mira_net_state_t

Name Value Description
MIRA_NET_STATE_NOT_ASSOCIATED

The unit is not part of a network yet.

MIRA_NET_STATE_IS_COORDINATOR

The unit is the network coordinator (root).

MIRA_NET_STATE_ASSOCIATED

The unit is in sync, but has no parent yet.

MIRA_NET_STATE_JOINED

The unit has a parent and is a part of the network-tree, can send packets.

mira_net_rate_t

Name Value Description
MIRA_NET_RATE_FAST 0
MIRA_NET_RATE_MID 8
MIRA_NET_RATE_SLOW 12

mira_net_mode_t

Name Value Description
MIRA_NET_MODE_ROOT 0
MIRA_NET_MODE_MESH
MIRA_NET_MODE_LEAF

Structs

mira_net_address_t

Type Name Description
uint8_t[16] u8
uint16_t[8] u16
uint32_t[4] u32

This is binary compatible with uip_addr_t for ipv6.

Structs

mira_net_config_t

Type Name Description
uint32_t pan_id Network ID, must be same for all nodes in the network.
uint8_t[16] key The encryption key for all data in the network. Must be the same for all nodes in the network.
mira_net_mode_t mode Set to mesh/leaf/root depending on desired mode of operation.Not all modes may be supported by all builds. If not supported, mira_net_init() will fail with MIRA_ERROR_INVALID_VALUE
uint8_t rate Higher value of rate reduces power consumption at the expense of data rate.Different nodes in the network may have different rates, and routes with higher rates are preferred over routes with lower rates.Recommended values are defined in mira_net_rate_t.Rates 0 to 10 are supported for meshing nodes and root node. Rates 0 to 12 are supported for leaf nodes.Rates 13 and higher are not supported.
mira_net_antenna_t antenna The preferred antenna. If the specified antenna is not available on the module, the default antenna is selected.
mira_net_address_t prefix If unset, fd00::/64 is default.This parameter only applies when mode == MIRA_NET_MODE_ROOT, for other modes, the prefix is derived from the joined network.Only first /64 is used.

Network configuration.

Functions

mira_net_init

mira_status_t mira_net_init(
    const mira_net_config_t*  config);

Initialize the mira network.

Parameters

Parameter Description
config Network configuration.

Return

See enum definition.

Value Description
MIRA_SUCCESS Mira net successfully initialized.
MIRA_ERROR_INVALID_VALUE Unsupported configuration parameters.
MIRA_ERROR_UNKNOWN An unknown error occurred.

mira_net_get_address

mira_status_t mira_net_get_address(
    mira_net_address_t*  dst);

Get the IP address.

Parameters

Parameter Description
dst The destination where to store the retrieved IP address.

Return

MIRA_SUCCESS if successful.

mira_net_get_state

mira_net_state_t mira_net_get_state(
    void);

Get the current state of network association.

Return

Current network state.

Value Description
MIRA_NET_STATE_IS_COORDINATOR Node state is coordinator.
MIRA_NET_STATE_NOT_ASSOCIATED Node state is not associated.
MIRA_NET_STATE_ASSOCIATED Node state is associated.
MIRA_NET_STATE_JOINED Node state is joined.

mira_net_get_root_address

mira_status_t mira_net_get_root_address(
    mira_net_address_t*  dst);

Get the IP address of the root node.

Parameters

Parameter Description
dst The destination where to store the retrieved IP address of the root node.

Return

See enum definition.

Value Description
MIRA_SUCCESS Got valid address.
MIRA_NET_ERROR_NOT_ASSOCIATED Node is not associated.

mira_net_get_parent_address

mira_status_t mira_net_get_parent_address(
    mira_net_address_t*  dst);

Gets the IP address of the parent node.

Parameters

Parameter Description
dst The destination where to store the retrieved IP address of the parent.

Return

See enum definition.

Value Description
MIRA_SUCCESS Got valid address.
MIRA_NET_ERROR_NOT_ASSOCIATED Node is not associated.
mira_link_metric_t mira_net_get_parent_link_metric(
    void);

Gets the link quality metric to the parent node. The link metric (as a 9.7 fixed point number) is a quality index of a particular link between two nodes. The value returned is called ETX, which is an approximate number of transmissions required for a successful transfer. Range is from 1.0 (0x0080) to infinity (0xFFFF). A value of 1.0 means a perfect link. Higher numbers are worse. To calculate an approximate packet delivery rate use the following formula: PDR = 1.0 / ETX.

Return

A link quality metric as an unsigned 9.7 fix point number.

mira_net_reset_scanning

mira_status_t mira_net_reset_scanning(
    void);

Reset network scanning. Network scanning will timeout after 5 minutes and sleep to conserve battery power in the case that there is no network to join. The sleep period is 5 minutes the first time, and doubles after each active scan period. The sleep period cannot be longer than 23 hours.

Return

MIRA_SUCCESS if successful.