diff --git a/libraries/MySensors/core/MyMessage.h b/libraries/MySensors/core/MyMessage.h index 3ed57ed..2d7b96f 100644 --- a/libraries/MySensors/core/MyMessage.h +++ b/libraries/MySensors/core/MyMessage.h @@ -50,7 +50,7 @@ typedef enum { C_STREAM = 4 //!< For firmware and other larger chunks of data that need to be divided into pieces. } mysensor_command; -// Type of sensor (used when presenting sensors) +/// @brief Type of sensor (used when presenting sensors) typedef enum { S_DOOR, // Door sensor, V_TRIPPED, V_ARMED S_MOTION, // Motion sensor, V_TRIPPED, V_ARMED @@ -94,7 +94,7 @@ typedef enum { S_GPS, // GPS Sensor, V_POSITION } mysensor_sensor; -// Type of sensor data (for set/req/ack messages) +/// @brief Type of sensor data (for set/req/ack messages) typedef enum { V_TEMP, // S_TEMP. Temperature S_TEMP, S_HEATER, S_HVAC V_HUM, // S_HUM. Humidity @@ -163,19 +163,20 @@ typedef enum { I_INCLUSION_MODE, I_CONFIG, I_FIND_PARENT, I_FIND_PARENT_RESPONSE, I_LOG_MESSAGE, I_CHILDREN, I_SKETCH_NAME, I_SKETCH_VERSION, I_REBOOT, I_GATEWAY_READY, - I_SIGNING_PRESENTATION, /*!< Provides signing related preferences (first byte is preference version) */ - I_NONCE_REQUEST, /*!< Request for a nonce */ - I_NONCE_RESPONSE, /*!< Payload is nonce data */ + I_SIGNING_PRESENTATION, //!< Provides signing related preferences (first byte is preference version) + I_NONCE_REQUEST, //!< Request for a nonce + I_NONCE_RESPONSE, //!< Payload is nonce data I_HEARTBEAT, I_PRESENTATION, I_DISCOVER, I_DISCOVER_RESPONSE, I_HEARTBEAT_RESPONSE } mysensor_internal; -// Type of data stream (for streamed message) +/// @brief Type of data stream (for streamed message) typedef enum { ST_FIRMWARE_CONFIG_REQUEST, ST_FIRMWARE_CONFIG_RESPONSE, ST_FIRMWARE_REQUEST, ST_FIRMWARE_RESPONSE, ST_SOUND, ST_IMAGE } mysensor_stream; +/// @brief Type of payload typedef enum { P_STRING, P_BYTE, P_INT16, P_UINT16, P_LONG32, P_ULONG32, P_CUSTOM, P_FLOAT32 } mysensor_payload; @@ -183,57 +184,52 @@ typedef enum { #ifndef BIT -#define BIT(n) ( 1<<(n) ) +#define BIT(n) ( 1<<(n) ) //!< Bit indexing macro #endif -// Create a bitmask of length len. -#define BIT_MASK(len) ( BIT(len)-1 ) -// Create a bitfield mask of length starting at bit 'start'. -#define BF_MASK(start, len) ( BIT_MASK(len)<<(start) ) +#define BIT_MASK(len) ( BIT(len)-1 ) //!< Create a bitmask of length 'len' +#define BF_MASK(start, len) ( BIT_MASK(len)<<(start) ) //!< Create a bitfield mask of length starting at bit 'start' -// Prepare a bitmask for insertion or combining. -#define BF_PREP(x, start, len) ( ((x)&BIT_MASK(len)) << (start) ) -// Extract a bitfield of length len starting at bit 'start' from y. -#define BF_GET(y, start, len) ( ((y)>>(start)) & BIT_MASK(len) ) -// Insert a new bitfield value x into y. -#define BF_SET(y, x, start, len) ( y= ((y) &~ BF_MASK(start, len)) | BF_PREP(x, start, len) ) +#define BF_PREP(x, start, len) ( ((x)&BIT_MASK(len)) << (start) ) //!< Prepare a bitmask for insertion or combining +#define BF_GET(y, start, len) ( ((y)>>(start)) & BIT_MASK(len) ) //!< Extract a bitfield of length 'len' starting at bit 'start' from 'y' +#define BF_SET(y, x, start, len) ( y= ((y) &~ BF_MASK(start, len)) | BF_PREP(x, start, len) ) //!< Insert a new bitfield value 'x' into 'y' // Getters/setters for special bit fields in header -#define mSetVersion(_msg,_version) BF_SET(_msg.version_length, _version, 0, 2) -#define mGetVersion(_msg) BF_GET(_msg.version_length, 0, 2) +#define mSetVersion(_msg,_version) BF_SET(_msg.version_length, _version, 0, 2) //!< Set version field +#define mGetVersion(_msg) BF_GET(_msg.version_length, 0, 2) //!< Get version field -#define mSetSigned(_msg,_signed) BF_SET(_msg.version_length, _signed, 2, 1) -#define mGetSigned(_msg) BF_GET(_msg.version_length, 2, 1) +#define mSetSigned(_msg,_signed) BF_SET(_msg.version_length, _signed, 2, 1) //!< Set signed field +#define mGetSigned(_msg) BF_GET(_msg.version_length, 2, 1) //!< Get versignedsion field -#define mSetLength(_msg,_length) BF_SET(_msg.version_length, _length, 3, 5) -#define mGetLength(_msg) BF_GET(_msg.version_length, 3, 5) +#define mSetLength(_msg,_length) BF_SET(_msg.version_length, _length, 3, 5) //!< Set length field +#define mGetLength(_msg) BF_GET(_msg.version_length, 3, 5) //!< Get length field -#define mSetCommand(_msg,_command) BF_SET(_msg.command_ack_payload, _command, 0, 3) -#define mGetCommand(_msg) BF_GET(_msg.command_ack_payload, 0, 3) +#define mSetCommand(_msg,_command) BF_SET(_msg.command_ack_payload, _command, 0, 3) //!< Set command field +#define mGetCommand(_msg) BF_GET(_msg.command_ack_payload, 0, 3) //!< Get command field -#define mSetRequestAck(_msg,_rack) BF_SET(_msg.command_ack_payload, _rack, 3, 1) -#define mGetRequestAck(_msg) BF_GET(_msg.command_ack_payload, 3, 1) +#define mSetRequestAck(_msg,_rack) BF_SET(_msg.command_ack_payload, _rack, 3, 1) //!< Set ack-request field +#define mGetRequestAck(_msg) BF_GET(_msg.command_ack_payload, 3, 1) //!< Get ack-request field -#define mSetAck(_msg,_ackMsg) BF_SET(_msg.command_ack_payload, _ackMsg, 4, 1) -#define mGetAck(_msg) BF_GET(_msg.command_ack_payload, 4, 1) +#define mSetAck(_msg,_ackMsg) BF_SET(_msg.command_ack_payload, _ackMsg, 4, 1) //!< Set ack field +#define mGetAck(_msg) BF_GET(_msg.command_ack_payload, 4, 1) //!< Get ack field -#define mSetPayloadType(_msg, _pt) BF_SET(_msg.command_ack_payload, _pt, 5, 3) -#define mGetPayloadType(_msg) BF_GET(_msg.command_ack_payload, 5, 3) +#define mSetPayloadType(_msg, _pt) BF_SET(_msg.command_ack_payload, _pt, 5, 3) //!< Set payload type field +#define mGetPayloadType(_msg) BF_GET(_msg.command_ack_payload, 5, 3) //!< Get payload type field // internal access for special fields -#define miGetCommand() BF_GET(command_ack_payload, 0, 3) +#define miGetCommand() BF_GET(command_ack_payload, 0, 3) //!< Internal getter for command field -#define miSetLength(_length) BF_SET(version_length, _length, 3, 5) -#define miGetLength() BF_GET(version_length, 3, 5) +#define miSetLength(_length) BF_SET(version_length, _length, 3, 5) //!< Internal setter for length field +#define miGetLength() BF_GET(version_length, 3, 5) //!< Internal getter for length field -#define miSetRequestAck(_rack) BF_SET(command_ack_payload, _rack, 3, 1) -#define miGetRequestAck() BF_GET(command_ack_payload, 3, 1) +#define miSetRequestAck(_rack) BF_SET(command_ack_payload, _rack, 3, 1) //!< Internal setter for ack-request field +#define miGetRequestAck() BF_GET(command_ack_payload, 3, 1) //!< Internal getter for ack-request field -#define miSetAck(_ack) BF_SET(command_ack_payload, _ack, 4, 1) -#define miGetAck() BF_GET(command_ack_payload, 4, 1) +#define miSetAck(_ack) BF_SET(command_ack_payload, _ack, 4, 1) //!< Internal setter for ack field +#define miGetAck() BF_GET(command_ack_payload, 4, 1) //!< Internal getter for ack field -#define miSetPayloadType(_pt) BF_SET(command_ack_payload, _pt, 5, 3) -#define miGetPayloadType() BF_GET(command_ack_payload, 5, 3) +#define miSetPayloadType(_pt) BF_SET(command_ack_payload, _pt, 5, 3) //!< Internal setter for payload type field +#define miGetPayloadType() BF_GET(command_ack_payload, 5, 3) //!< Internal getter for payload type field #if !DOXYGEN diff --git a/libraries/MySensors/core/MySensorCore.h b/libraries/MySensors/core/MySensorCore.h index 1991673..b7b25f0 100644 --- a/libraries/MySensors/core/MySensorCore.h +++ b/libraries/MySensors/core/MySensorCore.h @@ -1,4 +1,4 @@ -/** +/* * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each @@ -44,15 +44,24 @@ #define NODE_SENSOR_ID 0xFF -struct NodeConfig -{ - uint8_t nodeId; // Current node id - uint8_t parentNodeId; // Where this node sends its messages - uint8_t distance; // This nodes distance to sensor net gateway (number of hops) +/** + * @brief Node configuration + * + * This structure stores node-related configurations + */ +struct NodeConfig { + uint8_t nodeId; //!< Current node id + uint8_t parentNodeId; //!< Where this node sends its messages + uint8_t distance; //!< This nodes distance to sensor net gateway (number of hops) }; +/** + * @brief Controller configuration + * + * This structure stores controllerrelated configurations + */ struct ControllerConfig { - uint8_t isMetric; + uint8_t isMetric; //!< Flag indicating if metric or imperial measurements are used }; diff --git a/libraries/MySensors/core/MyTransport.h b/libraries/MySensors/core/MyTransport.h index e23869e..d0d8bc7 100644 --- a/libraries/MySensors/core/MyTransport.h +++ b/libraries/MySensors/core/MyTransport.h @@ -1,4 +1,4 @@ -/** +/* * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each @@ -42,33 +42,36 @@ #define SEARCH_FAILURES 5 -// FW config structure, stored in eeprom +/// @brief FW config structure, stored in eeprom typedef struct { - uint16_t type; - uint16_t version; - uint16_t blocks; - uint16_t crc; + uint16_t type; //!< Type of config + uint16_t version; //!< Version of config + uint16_t blocks; //!< Number of blocks + uint16_t crc; //!< CRC of block data } __attribute__((packed)) NodeFirmwareConfig; +/// @brief FW config request structure typedef struct { - uint16_t type; - uint16_t version; - uint16_t blocks; - uint16_t crc; - uint16_t BLVersion; + uint16_t type; //!< Type of config + uint16_t version; //!< Version of config + uint16_t blocks; //!< Number of blocks + uint16_t crc; //!< CRC of block data + uint16_t BLVersion; //!< Bootloader version } __attribute__((packed)) RequestFirmwareConfig; +/// @brief FW block request structure typedef struct { - uint16_t type; - uint16_t version; - uint16_t block; + uint16_t type; //!< Type of config + uint16_t version; //!< Version of config + uint16_t block; //!< Block index } __attribute__((packed)) RequestFWBlock; +/// @brief FW block reply structure typedef struct { - uint16_t type; - uint16_t version; - uint16_t block; - uint8_t data[FIRMWARE_BLOCK_SIZE]; + uint16_t type; //!< Type of config + uint16_t version; //!< Version of config + uint16_t block; //!< Block index + uint8_t data[FIRMWARE_BLOCK_SIZE]; //!< Block data } __attribute__((packed)) ReplyFWBlock;