MySensors Library & Examples  2.3.2-36-g2e00bf6
MyTransportHAL.h
1 /*
2  * The MySensors Arduino library handles the wireless radio link and protocol
3  * between your home built sensors/actuators and HA controller of choice.
4  * The sensors forms a self healing radio network with optional repeaters. Each
5  * repeater and gateway builds a routing tables in EEPROM which keeps track of the
6  * network topology allowing messages to be routed to nodes.
7  *
8  * Created by Henrik Ekblad <[email protected]>
9  * Copyright (C) 2013-2020 Sensnology AB
10  * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
11  *
12  * Documentation: http://www.mysensors.org
13  * Support Forum: http://forum.mysensors.org
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * version 2 as published by the Free Software Foundation.
18  *
19  * TransportHAL debug log messages:
20  *
21  * |E| SYS | SUB | Message | Comment
22  * |-|-----|-------|----------------------------|---------------------------------------------------------------------
23  * | | THA | INIT | | Initialize transportHAL
24  * | | THA | INIT | PSK=%%s | Load PSK for transport encryption (%AES)
25  * | | THA | SAD | ADDR=%%d | Set transport address (ADDR)
26  * | | THA | GAD | ADDR=%%d | Get trnasport address (ADDR)
27  * | | THA | DATA | AVAIL | Message available
28  * | | THA | SAN | RES=%%d | Transport sanity check, result (RES)
29  * | | THA | RCV | MSG=%%s | Receive message (MSG)
30  * | | THA | RCV | DECRYPT | Decrypt received message
31  * | | THA | RCV | PLAIN=%%s | Decrypted message (PLAIN)
32  * |!| THA | RCV | PVER=%%d | Message protocol version (PVER) mismatch
33  * |!| THA | RCV | LEN=%%d,EXP=%%d | Invalid message length (LEN), exptected length (EXP)
34  * | | THA | RCV | MSG LEN=%%d | Length of received message (LEN)
35  * | | THA | SND | MSG=%%s | Send message (MSG)
36  * | | THA | SND | ENCRYPT | Encrypt message to send (%AES)
37  * | | THA | SND | CIP=%%s | Ciphertext of encypted message (CIP)
38  * | | THA | SND | MSG LEN=%%d,RES=%%d | Sending message with length (LEN), result (RES)
39  *
40  *
41  */
42 
43 #ifndef MyTransportHAL_h
44 #define MyTransportHAL_h
45 
46 #define INVALID_SNR ((int16_t)-256)
47 #define INVALID_RSSI ((int16_t)-256)
48 #define INVALID_PERCENT ((int16_t)-100)
49 #define INVALID_LEVEL ((int16_t)-256)
50 
51 #if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
52 #if defined(MY_RADIO_NRF5_ESB)
53 #error Receive message buffering not supported for NRF5 radio! Please define MY_NRF5_RX_BUFFER_SIZE
54 #endif
55 #if defined(MY_RADIO_RFM69)
56 #error Receive message buffering not supported for RFM69!
57 #endif
58 #if defined(MY_RADIO_RFM95)
59 #error Receive message buffering not supported for RFM95!
60 #endif
61 #if defined(MY_RS485)
62 #error Receive message buffering not supported for RS485!
63 #endif
64 #elif defined(MY_RX_MESSAGE_BUFFER_SIZE)
65 #error Receive message buffering requires message buffering feature enabled!
66 #endif
67 
71 typedef enum {
72  SR_RX_RSSI,
73  SR_TX_RSSI,
74  SR_RX_SNR,
75  SR_TX_SNR,
76  SR_TX_POWER_LEVEL,
77  SR_TX_POWER_PERCENT,
78  SR_UPLINK_QUALITY,
79  SR_NOT_DEFINED
80 } signalReport_t;
81 
82 
87 bool transportHALInit(void);
91 void transportHALSetAddress(const uint8_t address);
95 uint8_t transportHALGetAddress(void);
104 bool transportHALSend(const uint8_t nextRecipient, const MyMessage *outMsg, const uint8_t len,
105  const bool noACK);
110 bool transportHALDataAvailable(void);
115 bool transportHALSanityCheck(void);
122 bool transportHALReceive(MyMessage *inMsg, uint8_t *msgLength);
126 void transportHALPowerDown(void);
130 void transportHALPowerUp(void);
134 void transportHALSleep(void);
138 void transportHALStandBy(void);
143 int16_t transportHALGetSendingRSSI(void);
148 int16_t transportHALGetReceivingRSSI(void);
153 int16_t transportHALGetSendingSNR(void);
158 int16_t transportHALGetReceivingSNR(void);
163 int16_t transportHALGetTxPowerPercent(void);
169 bool transportHALSetTxPowerPercent(const uint8_t powerPercent);
174 int16_t transportHALGetTxPowerLevel(void);
175 
176 #endif // MyTransportHAL_h
MyMessage
MyMessage is used to create, manipulate, send and read MySensors messages.
Definition: MyMessage.h:289