MiraOS  1.14
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 {
79  MIRA_SERIAL_COMMAND_INTERFACE_DISABLED = 0,
80  MIRA_SERIAL_COMMAND_INTERFACE_ENABLED
81 } MiraSerialCommandInterfaceMode;
82 
93 typedef void (*MiraReceivedDataCallback)(uint8_t* data_ptr, uint8_t length, MiraAddressType address_type, uint8_t* address_ptr);
94 
103 typedef void (*MiraReceivedMailCallback)(uint8_t* data_ptr, uint8_t length);
104 
105 
109 extern process_event_t mira_tx_queue_empty_event;
110 
111 
123 MiraErrorType mira_send_data(MiraAddressType address_type, uint8_t* address_ptr, uint8_t* data_ptr, uint8_t length);
124 
132 uint8_t mira_tx_queue_is_empty(void);
133 
141 #define mira_wait_for_empty_queue() \
142 { \
143  while (!mira_tx_queue_is_empty()) { \
144  PROCESS_PAUSE(); \
145  } \
146 }
147 
158 
165 
172 
183 
192 int8_t mira_check_mailbox(void);
193 
208 void mira_set_credentials(uint16_t pan_id, uint8_t* aes_key);
209 
220 void mira_become_root(void);
221 
231 void mira_commit_network_setup(void);
232 
243 void mira_set_name(char* name);
244 
256 
265 void mira_disable_rf_frontend(void);
266 
276 void mira_enable_rf_frontend(void);
277 
283 void mira_reboot(void);
284 
295 void mira_init(MiraSerialCommandInterfaceMode serial_command_interface_mode);
296 
308 void mira_init_bootloader(MiraSerialCommandInterfaceMode serial_command_interface_mode, uint16_t firmware_image_id);
309 
321 void mira_set_fw_encryption_key(uint8_t *key);
322 
332 void mira_copy_board_eui(uint8_t *eui_ptr);
333 
334 #endif /* LIBMIRA_H_ */
int8_t mira_check_mailbox(void)
Check for mails.
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.
MiraOS GPIO driver.
Definition: miralib.h:48
Definition: miralib.h:70
MiraOS I2C driver.
void(* MiraReceivedMailCallback)(uint8_t *data_ptr, uint8_t length)
Function pointer to receive callback.
Definition: miralib.h:103
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:93
void mira_reboot(void)
Reboots the module.
MiraOS PWM driver.