MiraOS  1.26
miralib.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (C) 2016 LumenRadio AB *
3  * *
4  * This file is part of MiraOS. *
5  * *
6  * MiraOS contains software components that are patented by LumenRadio. *
7  * Use of this software is under the terms of the LumenRadio MiraOS *
8  * license.
9  * *
10  * You should have received a copy of the MiraOS license from your *
11  * LumenRadio representative. If not, email to <licenses@lumenradio.com> *
12  ****************************************************************************/
13 
25 #ifndef LIBMIRA_H_
26 #define LIBMIRA_H_
27 
28 #include "sys/autostart.h"
29 #include "sys/process.h"
30 #include "sys/etimer.h"
31 #include "mira_gpio.h"
32 #include "mira_adc.h"
33 #include "mira_pwm.h"
34 #include "mira_i2c.h"
35 #include "mira_spi.h"
36 
37 #include <stdint.h>
38 
39 
45 typedef enum {
50 
56 typedef enum {
57  MIRA_TO_EUI64 = 0x12,
58  MIRA_TO_ROOT = 0x21,
59  MIRA_TO_LOCAL = 0x41,
62 
68 typedef enum {
72 
78 typedef enum {
83 
89 typedef enum {
90  MIRA_SERIAL_COMMAND_INTERFACE_DISABLED = 0,
91  MIRA_SERIAL_COMMAND_INTERFACE_ENABLED
92 } MiraSerialCommandInterfaceMode;
93 
104 typedef void (*MiraReceivedDataCallback)(uint8_t* data_ptr, uint8_t length, MiraAddressType address_type, uint8_t* address_ptr);
105 
114 typedef void (*MiraReceivedMailCallback)(uint8_t* data_ptr, uint8_t length);
115 
116 
120 extern process_event_t mira_tx_queue_empty_event;
121 
122 
134 MiraErrorType mira_send_data(MiraAddressType address_type, uint8_t* address_ptr, uint8_t* data_ptr, uint8_t length);
135 
143 uint8_t mira_tx_queue_is_empty(void);
144 
152 #define mira_wait_for_empty_queue() \
153 { \
154  while (!mira_tx_queue_is_empty()) { \
155  PROCESS_PAUSE(); \
156  } \
157 }
158 
169 
176 
183 
194 
204 int8_t mira_check_mailbox(void);
205 
220 void mira_set_credentials(uint16_t pan_id, uint8_t* aes_key);
221 
232 void mira_become_root(void);
233 
243 void mira_commit_network_setup(void);
244 
255 void mira_set_name(char* name);
256 
263 
275 
284 void mira_disable_rf_frontend(void);
285 
295 void mira_enable_rf_frontend(void);
296 
302 void mira_reboot(void);
303 
314 void mira_init(MiraSerialCommandInterfaceMode serial_command_interface_mode);
315 
327 void mira_init_bootloader(MiraSerialCommandInterfaceMode serial_command_interface_mode, uint16_t firmware_image_id);
328 
340 void mira_set_fw_encryption_key(uint8_t *key);
341 
351 void mira_copy_board_eui(uint8_t *eui_ptr);
352 
360 void mira_leave_fwup_process(void);
361 
362 #endif /* LIBMIRA_H_ */
Definition: miralib.h:80
int8_t mira_check_mailbox(void)
Check for mails.
void mira_leave_fwup_process(void)
Leaves a firmware update process.
Definition: miralib.h:60
void mira_init(MiraSerialCommandInterfaceMode serial_command_interface_mode)
Initializes the library.
void mira_set_name(char *name)
Set the node name.
Definition: miralib.h:59
void mira_disable_data_forwarding()
Disable forwarding of data messages to the command serial port.
void mira_init_bootloader(MiraSerialCommandInterfaceMode serial_command_interface_mode, uint16_t firmware_image_id)
Initializes the library in bootloader mode.
Definition: miralib.h:57
void mira_register_data_received_callback(MiraReceivedDataCallback callback)
Register the received data callback.
MiraOS analog to digital converter driver.
process_event_t mira_tx_queue_empty_event
Event for that the TX queue now is empty.
void mira_become_root(void)
Become the network root.
void mira_copy_board_eui(uint8_t *eui_ptr)
Get the board EUI-64.
MiraOS SPI driver.
Definition: miralib.h:58
void mira_set_credentials(uint16_t pan_id, uint8_t *aes_key)
Sets the network credentials to use.
Definition: miralib.h:47
void mira_enable_data_forwarding()
Enable forwarding of data messages to the command serial port.
void mira_commit_network_setup(void)
Commit the network setup and start routing traffic.
Definition: miralib.h:46
void mira_register_mail_received_callback(MiraReceivedMailCallback callback)
Register the received data callback for mails to sleepy nodes.
Definition: miralib.h:69
void mira_enable_rf_frontend(void)
Enables the RF frontend.
uint8_t mira_tx_queue_is_empty(void)
TX queue empty check.
MiraAddressType
Supported addressing modes for Mira messages.
Definition: miralib.h:56
void mira_select_antenna(MiraAntennaType antenna)
Selects the antenna option.
void mira_set_fw_encryption_key(uint8_t *key)
Sets the encryption key to be used for firmware update files.
MiraErrorType mira_send_data(MiraAddressType address_type, uint8_t *address_ptr, uint8_t *data_ptr, uint8_t length)
Function to send a data message.
MiraAntennaType
Antenna options.
Definition: miralib.h:68
void mira_disable_rf_frontend(void)
Disables the RF frontend.
MiraConnectionStatus mira_get_connection_status(void)
Get the current network connection status.
MiraOS GPIO driver.
Definition: miralib.h:48
MiraConnectionStatus
Connection status.
Definition: miralib.h:78
Definition: miralib.h:81
Definition: miralib.h:70
MiraOS I2C driver.
void(* MiraReceivedMailCallback)(uint8_t *data_ptr, uint8_t length)
Function pointer to receive callback.
Definition: miralib.h:114
MiraErrorType
Return error codes for Mira library functions.
Definition: miralib.h:45
void(* MiraReceivedDataCallback)(uint8_t *data_ptr, uint8_t length, MiraAddressType address_type, uint8_t *address_ptr)
Function pointer to receive callback.
Definition: miralib.h:104
Definition: miralib.h:79
void mira_reboot(void)
Reboots the module.
MiraOS PWM driver.