Code harmonization

This commit is contained in:
Olivier
2016-10-09 15:53:51 +02:00
parent 32596676e5
commit 351845205c
7 changed files with 176 additions and 178 deletions
+51 -46
View File
@@ -122,17 +122,17 @@ extern MyMessage _msgTmp; //!< Buffer for temporary messages (acks and nonc
/**
* Return this nodes id.
*/
uint8_t getNodeId();
uint8_t getNodeId(void);
/**
* Return the parent node id.
*/
uint8_t getParentNodeId();
uint8_t getParentNodeId(void);
/**
* Sends node information to the gateway.
*/
void presentNode();
void presentNode(void);
/**
* Each node must present all attached sensors before any values can be handled correctly by the controller.
@@ -143,17 +143,18 @@ void presentNode();
* @param description A textual description of the sensor.
* @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
* @param description A textual description of the sensor.
* @return true Returns true if message reached the first stop on its way to destination.
*/
void present(uint8_t sensorId, uint8_t sensorType, const char *description="", bool ack=false);
bool present(const uint8_t sensorId, const uint8_t sensorType, const char *description="", const bool ack = false);
/**
* Sends sketch meta information to the gateway. Not mandatory but a nice thing to do.
* @param name String containing a short Sketch name or NULL if not applicable
* @param version String containing a short Sketch version or NULL if not applicable
* @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
*
* @return true Returns true if message reached the first stop on its way to destination.
*/
void sendSketchInfo(const char *name, const char *version, bool ack=false);
bool sendSketchInfo(const char *name, const char *version, const bool ack = false);
/**
* Sends a message to gateway or one of the other nodes in the radio network
@@ -162,22 +163,24 @@ void sendSketchInfo(const char *name, const char *version, bool ack=false);
* @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
* @return true Returns true if message reached the first stop on its way to destination.
*/
bool send(MyMessage &msg, bool ack=false);
bool send(MyMessage &msg, const bool ack = false);
/**
* Send this nodes battery level to gateway.
* @param level Level between 0-100(%)
* @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
*
* @return true Returns true if message reached the first stop on its way to destination.
*/
void sendBatteryLevel(uint8_t level, bool ack=false);
bool sendBatteryLevel(const uint8_t level, const bool ack = false);
/**
* Send a heartbeat message (I'm alive!) to the gateway/controller.
* The payload will be an incremental 16 bit integer value starting at 1 when sensor is powered on.
* @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
* @return true Returns true if message reached the first stop on its way to destination.
*/
void sendHeartbeat(void);
bool sendHeartbeat(const bool ack = false);
/**
* Requests a value from gateway or some other sensor in the radio network.
@@ -186,19 +189,21 @@ void sendHeartbeat(void);
* @param childSensorId The unique child id for the different sensors connected to this Arduino. 0-254.
* @param variableType The variableType to fetch
* @param destination The nodeId of other node in radio network. Default is gateway
* @return true Returns true if message reached the first stop on its way to destination.
*/
void request(uint8_t childSensorId, uint8_t variableType, uint8_t destination=GATEWAY_ADDRESS);
bool request(const uint8_t childSensorId, const uint8_t variableType, const uint8_t destination = GATEWAY_ADDRESS);
/**
* Requests time from controller. Answer will be delivered to receiveTime function in sketch.
*
* @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
* @return true Returns true if message reached the first stop on its way to destination.
*/
void requestTime();
bool requestTime(const bool ack = false);
/**
* Returns the most recent node configuration received from controller
*/
ControllerConfig getConfig();
ControllerConfig getConfig(void);
/**
* Save a state (in local EEPROM). Good for actuators to "remember" state between
@@ -210,7 +215,7 @@ ControllerConfig getConfig();
* @param pos The position to store value in (0-255)
* @param value to store in position
*/
void saveState(uint8_t pos, uint8_t value);
void saveState(const uint8_t pos, const uint8_t value);
/**
* Load a state (from local EEPROM).
@@ -218,36 +223,36 @@ void saveState(uint8_t pos, uint8_t value);
* @param pos The position to fetch value from (0-255)
* @return Value to store in position
*/
uint8_t loadState(uint8_t pos);
uint8_t loadState(const uint8_t pos);
/**
* Wait for a specified amount of time to pass. Keeps process()ing.
* This does not power-down the radio nor the Arduino.
* Because this calls process() in a loop, it is a good way to wait
* in your loop() on a repeater node or sensor that listens to messages.
* @param ms Number of milliseconds to sleep.
* @param waitingMS Number of milliseconds to wait.
*/
void wait(unsigned long ms);
void wait(const uint32_t waitingMS);
/**
* Wait for a specified amount of time to pass or until specified message received. Keeps process()ing.
* This does not power-down the radio nor the Arduino.
* Because this calls process() in a loop, it is a good way to wait
* in your loop() on a repeater node or sensor that listens to messages.
* @param ms Number of milliseconds to sleep.
* @param waitingMS Number of milliseconds to wait.
* @param cmd Command of incoming message.
* @param msgtype Message type.
* @return True if specified message received
*/
bool wait(unsigned long ms, uint8_t cmd, uint8_t msgtype);
bool wait(const uint32_t waitingMS, const uint8_t cmd, const uint8_t msgtype);
/**
* Sleep (PowerDownMode) the MCU and radio. Wake up on timer.
* @param ms Number of milliseconds to sleep.
* @param sleepingMS Number of milliseconds to sleep.
* @param smartSleep Set True if sending heartbeat and process incoming messages before going to sleep.
* @return @ref MY_WAKE_UP_BY_TIMER if timer woke it up, @ref MY_SLEEP_NOT_POSSIBLE if not possible (e.g. ongoing FW update)
*/
int8_t sleep(const uint32_t ms, const bool smartSleep = false);
int8_t sleep(const uint32_t sleepingMS, const bool smartSleep = false);
/**
* Sleep (PowerDownMode) the MCU and radio. Wake up on timer or pin change.
@@ -255,11 +260,11 @@ int8_t sleep(const uint32_t ms, const bool smartSleep = false);
* is assigned to what interrupt. On Nano/Pro Mini: 0=Pin2, 1=Pin3
* @param interrupt Interrupt that should trigger the wakeup
* @param mode RISING, FALLING, CHANGE
* @param ms Number of milliseconds to sleep or 0 to sleep forever
* @param sleepingMS Number of milliseconds to sleep or 0 to sleep forever
* @param smartSleep Set True if sending heartbeat and process incoming messages before going to sleep
* @return Interrupt number if wake up was triggered by pin change, @ref MY_WAKE_UP_BY_TIMER if wake up was triggered by timer, @ref MY_SLEEP_NOT_POSSIBLE if sleep was not possible (e.g. ongoing FW update)
*/
int8_t sleep(const uint8_t interrupt, const uint8_t mode, const uint32_t ms=0, const bool smartSleep = false);
int8_t sleep(const uint8_t interrupt, const uint8_t mode, const uint32_t sleepingMS = 0, const bool smartSleep = false);
/**
* Sleep (PowerDownMode) the MCU and radio. Wake up on timer or pin change for two separate interrupts.
@@ -269,20 +274,20 @@ int8_t sleep(const uint8_t interrupt, const uint8_t mode, const uint32_t ms=0, c
* @param mode1 Mode for first interrupt (RISING, FALLING, CHANGE)
* @param interrupt2 Second interrupt that should trigger the wakeup
* @param mode2 Mode for second interrupt (RISING, FALLING, CHANGE)
* @param ms Number of milliseconds to sleep or 0 to sleep forever
* @param sleepingMS Number of milliseconds to sleep or 0 to sleep forever
* @param smartSleep Set True if sending heartbeat and process incoming messages before going to sleep.
* @return Interrupt number if wake up was triggered by pin change, @ref MY_WAKE_UP_BY_TIMER if wake up was triggered by timer, @ref MY_SLEEP_NOT_POSSIBLE if sleep was not possible (e.g. ongoing FW update)
*/
int8_t sleep(const uint8_t interrupt1, const uint8_t mode1, const uint8_t interrupt2, const uint8_t mode2, const uint32_t ms=0, const bool smartSleep = false);
int8_t sleep(const uint8_t interrupt1, const uint8_t mode1, const uint8_t interrupt2, const uint8_t mode2, const uint32_t sleepingMS = 0, const bool smartSleep = false);
/**
* \deprecated Use sleep(ms, true) instead
* Same as sleep(), send heartbeat and process incoming messages before going to sleep.
* Specify the time to wait for incoming messages by defining MY_SMART_SLEEP_WAIT_DURATION to a time (ms).
* @param ms Number of milliseconds to sleep.
* @param sleepingMS Number of milliseconds to sleep.
* @return @ref MY_WAKE_UP_BY_TIMER if timer woke it up, @ref MY_SLEEP_NOT_POSSIBLE if not possible (e.g. ongoing FW update)
*/
int8_t smartSleep(const uint32_t ms);
int8_t smartSleep(const uint32_t sleepingMS);
/**
* \deprecated Use sleep(interrupt, mode, ms, true) instead
@@ -290,10 +295,10 @@ int8_t smartSleep(const uint32_t ms);
* Specify the time to wait for incoming messages by defining MY_SMART_SLEEP_WAIT_DURATION to a time (ms).
* @param interrupt Interrupt that should trigger the wakeup
* @param mode RISING, FALLING, CHANGE
* @param ms Number of milliseconds to sleep or 0 to sleep forever
* @param sleepingMS Number of milliseconds to sleep or 0 to sleep forever
* @return Interrupt number if wake up was triggered by pin change, @ref MY_WAKE_UP_BY_TIMER if wake up was triggered by timer, @ref MY_SLEEP_NOT_POSSIBLE if sleep was not possible (e.g. ongoing FW update)
*/
int8_t smartSleep(const uint8_t interrupt, const uint8_t mode, const uint32_t ms = 0);
int8_t smartSleep(const uint8_t interrupt, const uint8_t mode, const uint32_t sleepingMS = 0);
/**
* \deprecated Use sleep(interrupt1, mode1, interrupt2, mode2, ms, true) instead
@@ -303,16 +308,16 @@ int8_t smartSleep(const uint8_t interrupt, const uint8_t mode, const uint32_t ms
* @param mode1 Mode for first interrupt (RISING, FALLING, CHANGE)
* @param interrupt2 Second interrupt that should trigger the wakeup
* @param mode2 Mode for second interrupt (RISING, FALLING, CHANGE)
* @param ms Number of milliseconds to sleep or 0 to sleep forever
* @param sleepingMS Number of milliseconds to sleep or 0 to sleep forever
* @return Interrupt number if wake up was triggered by pin change, @ref MY_WAKE_UP_BY_TIMER if wake up was triggered by timer, @ref MY_SLEEP_NOT_POSSIBLE if sleep was not possible (e.g. ongoing FW update)
*/
int8_t smartSleep(const uint8_t interrupt1, const uint8_t mode1, const uint8_t interrupt2, const uint8_t mode2, const uint32_t ms=0);
int8_t smartSleep(const uint8_t interrupt1, const uint8_t mode1, const uint8_t interrupt2, const uint8_t mode2, const uint32_t sleepingMS = 0);
/**
* Sleep (PowerDownMode) the MCU and radio. Wake up on timer or pin change for two separate interrupts.
* See: http://arduino.cc/en/Reference/attachInterrupt for details on modes and which pin
* is assigned to what interrupt. On Nano/Pro Mini: 0=Pin2, 1=Pin3
* @param ms Number of milliseconds to sleep or 0 to sleep forever
* @param sleepingMS Number of milliseconds to sleep or 0 to sleep forever
* @param interrupt1 (optional) First interrupt that should trigger the wakeup
* @param mode1 (optional) Mode for first interrupt (RISING, FALLING, CHANGE)
* @param interrupt2 (optional) Second interrupt that should trigger the wakeup
@@ -320,7 +325,7 @@ int8_t smartSleep(const uint8_t interrupt1, const uint8_t mode1, const uint8_t i
* @param smartSleep (optional) Set True if sending heartbeat and process incoming messages before going to sleep.
* @return Interrupt number if wake up was triggered by pin change, @ref MY_WAKE_UP_BY_TIMER if wake up was triggered by timer, @ref MY_SLEEP_NOT_POSSIBLE if sleep was not possible (e.g. ongoing FW update)
*/
int8_t _sleep(const uint32_t ms, const bool smartSleep = false, const uint8_t interrupt1 = INTERRUPT_NOT_DEFINED, const uint8_t mode1 = MODE_NOT_DEFINED, const uint8_t interrupt2 = INTERRUPT_NOT_DEFINED, const uint8_t mode2 = MODE_NOT_DEFINED);
int8_t _sleep(const uint32_t sleepingMS, const bool smartSleep = false, const uint8_t interrupt1 = INTERRUPT_NOT_DEFINED, const uint8_t mode1 = MODE_NOT_DEFINED, const uint8_t interrupt2 = INTERRUPT_NOT_DEFINED, const uint8_t mode2 = MODE_NOT_DEFINED);
#ifdef MY_NODE_LOCK_FEATURE
@@ -343,7 +348,7 @@ void nodeLock(const char* str);
/**
* @brief Node initialisation
*/
void _begin();
void _begin(void);
/**
* @brief Main framework process
*/
@@ -352,19 +357,19 @@ void _process(void);
* @brief Processes internal messages
* @return True if received message requires further processing
*/
bool _processInternalMessages();
bool _processInternalMessages(void);
/**
* @brief Puts node to a infinite loop if unrecoverable situation detected
*/
void _infiniteLoop();
void _infiniteLoop(void);
/**
* @brief Handles registration request
*/
void _registerNode();
void _registerNode(void);
/**
* @brief Sends message according to routing table
* @param message
* @return True if message successfully sent to next node
* @return true Returns true if message reached the first stop on its way to destination.
*/
bool _sendRoute(MyMessage &message);
@@ -380,33 +385,33 @@ void receiveTime(unsigned long) __attribute__((weak));
/**
* @brief Node presenation
*/
void presentation() __attribute__((weak));
void presentation(void) __attribute__((weak));
/**
* @brief Called before node initialises
*/
void before() __attribute__((weak));
void before(void) __attribute__((weak));
/**
* @brief Called before any hwInitialization is done
*/
void preHwInit() __attribute__((weak));
void preHwInit(void) __attribute__((weak));
/**
* @brief Called after node initialises but before main loop
*/
void setup() __attribute__((weak));
void setup(void) __attribute__((weak));
/**
* @brief Main loop
*/
void loop() __attribute__((weak));
void loop(void) __attribute__((weak));
// Inline function and macros
static inline MyMessage& build(MyMessage &msg, const uint8_t destination, const uint8_t sensor, const uint8_t command, const uint8_t type, const bool enableAck) {
static inline MyMessage& build(MyMessage &msg, const uint8_t destination, const uint8_t sensor, const uint8_t command, const uint8_t type, const bool ack = false) {
msg.sender = _nc.nodeId;
msg.destination = destination;
msg.sensor = sensor;
msg.type = type;
mSetCommand(msg,command);
mSetRequestAck(msg,enableAck);
mSetRequestAck(msg,ack);
mSetAck(msg,false);
return msg;
}