simplified message handling, switch from XOR checksum to CRC8 with polynomial 0x97.
0x97 allows for detection of all 1-3 bit errors in a message of up to 119 bytes (see https://www.faa.gov/aircraft/air_cert/design_approvals/air_software/media/TC-14-49.pdf)
This commit is contained in:
@@ -18,31 +18,23 @@
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_CLAIMADDR_UID 0
|
||||
#define AQH_MSG_OFFS_CLAIMADDR_ADDR 4
|
||||
|
||||
#define AQH_MSG_CLAIMADDR_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_CLAIMADDR_ADDR+1)
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_ClaimAddrMsg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_CLAIM_ADDRESS) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_CLAIMADDR_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_CLAIMADDR_UID;
|
||||
return (uint32_t)(ptr[0])+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_CLAIMADDR_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_ClaimAddrMsg_GetAddress(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_CLAIM_ADDRESS) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_CLAIMADDR_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_CLAIMADDR_ADDR;
|
||||
return ptr[0];
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_CLAIMADDR_ADDR, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,14 +18,6 @@
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_CLAIMADDR_UID 0
|
||||
#define AQH_MSG_OFFS_CLAIMADDR_ADDR 4
|
||||
|
||||
#define AQH_MSG_CLAIMADDR_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_CLAIMADDR_ADDR+1)
|
||||
|
||||
|
||||
|
||||
|
||||
AQHOME_API uint32_t AQH_ClaimAddrMsg_GetUid(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_ClaimAddrMsg_GetAddress(const GWEN_MSG *msg);
|
||||
AQHOME_API void AQH_ClaimAddrMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
@@ -19,30 +19,23 @@
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_DENYADDR_UID 0
|
||||
#define AQH_MSG_OFFS_DENYADDR_ADDR 4
|
||||
|
||||
#define AQH_MSG_DENYADDR_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DENYADDR_ADDR+1)
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_DenyAddrMsg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_DENY_ADDRESS) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_DENYADDR_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DENYADDR_UID;
|
||||
return (uint32_t)(ptr[0])+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DENYADDR_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_DenyAddrMsg_GetAddress(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_DENY_ADDRESS) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_DENYADDR_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DENYADDR_ADDR;
|
||||
return ptr[0];
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DENYADDR_ADDR, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,14 +18,6 @@
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_DENYADDR_UID 0
|
||||
#define AQH_MSG_OFFS_DENYADDR_ADDR 4
|
||||
|
||||
#define AQH_MSG_DENYADDR_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DENYADDR_ADDR+1)
|
||||
|
||||
|
||||
|
||||
|
||||
AQHOME_API uint32_t AQH_DenyAddrMsg_GetUid(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_DenyAddrMsg_GetAddress(const GWEN_MSG *msg);
|
||||
AQHOME_API void AQH_DenyAddrMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
@@ -18,82 +18,47 @@
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_DEVICE_UID 0 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_DEVICE_FWTYPE 4 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_DEVICE_FWLOW 6 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_DEVICE_FWHIGH 7 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_DEVICE_MODULES 8 /* 2 byte */
|
||||
|
||||
#define AQH_MSG_DEVICE_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_MODULES+2)
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_DeviceMsg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_DEVICE_MINSIZE) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_UID;
|
||||
return (uint32_t)(ptr[0])+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_DeviceMsg_GetFirmwareType(const GWEN_MSG *msg)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_DEVICE_MINSIZE) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_FWTYPE;
|
||||
return (uint16_t)((ptr[0])+(ptr[1]<<8));
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_FWTYPE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_DeviceMsg_GetFirmwareLow(const GWEN_MSG *msg)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_DEVICE_MINSIZE) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_FWLOW;
|
||||
return ptr[0];
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_FWLOW, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_DeviceMsg_GetFirmwareHigh(const GWEN_MSG *msg)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_DEVICE_MINSIZE) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_FWHIGH;
|
||||
return ptr[0];
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_FWHIGH, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_DeviceMsg_GetModuleMaskLow(const GWEN_MSG *msg)
|
||||
uint16_t AQH_DeviceMsg_GetModuleMask(const GWEN_MSG *msg)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_DEVICE_MINSIZE) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_MODULESLOW;
|
||||
return ptr[0];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_DeviceMsg_GetModuleMaskHigh(const GWEN_MSG *msg)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_DEVICE_MINSIZE) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_MODULESHIGH;
|
||||
return ptr[0];
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_MODULES, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +68,7 @@ void AQH_DeviceMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const ch
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_DEVICE_MINSIZE) {
|
||||
uint16_t modules;
|
||||
|
||||
modules=(AQH_DeviceMsg_GetModuleMaskHigh(msg)<<8) | AQH_DeviceMsg_GetModuleMaskLow(msg);
|
||||
modules=AQH_DeviceMsg_GetModuleMask(msg);
|
||||
GWEN_Buffer_AppendArgs(dbuf, "0x%02x->0x%02x: DEVICE %s (uid=0x%08x, fw type=%d, fw ver=%d.%d, mods=0x%04x",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
|
||||
@@ -18,15 +18,6 @@
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_DEVICE_UID 0 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_DEVICE_FWTYPE 4 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_DEVICE_FWLOW 6 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_DEVICE_FWHIGH 7 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_DEVICE_MODULESLOW 8 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_DEVICE_MODULESHIGH 9 /* 1 byte */
|
||||
|
||||
#define AQH_MSG_DEVICE_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_MODULESHIGH+1)
|
||||
|
||||
#define AQH_MSG_DEVICE_MASK_TIMER 0x02
|
||||
#define AQH_MSG_DEVICE_MASK_COM 0x04
|
||||
#define AQH_MSG_DEVICE_MASK_LED 0x08
|
||||
@@ -40,8 +31,7 @@ AQHOME_API uint32_t AQH_DeviceMsg_GetUid(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_DeviceMsg_GetFirmwareType(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_DeviceMsg_GetFirmwareLow(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_DeviceMsg_GetFirmwareHigh(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_DeviceMsg_GetModuleMaskLow(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_DeviceMsg_GetModuleMaskHigh(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_DeviceMsg_GetModuleMask(const GWEN_MSG *msg);
|
||||
|
||||
|
||||
AQHOME_API void AQH_DeviceMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
@@ -18,31 +18,23 @@
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_HAVEADDR_UID 0
|
||||
#define AQH_MSG_OFFS_HAVEADDR_ADDR 4
|
||||
|
||||
#define AQH_MSG_HAVEADDR_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_HAVEADDR_ADDR+1)
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_HaveAddrMsg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_HAVE_ADDRESS) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_HAVEADDR_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_HAVEADDR_UID;
|
||||
return (uint32_t)(ptr[0])+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_HAVEADDR_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_HaveAddrMsg_GetAddress(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_HAVE_ADDRESS) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_HAVEADDR_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_HAVEADDR_ADDR;
|
||||
return ptr[0];
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_HAVEADDR_ADDR, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,14 +18,6 @@
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_HAVEADDR_UID 0
|
||||
#define AQH_MSG_OFFS_HAVEADDR_ADDR 4
|
||||
|
||||
#define AQH_MSG_HAVEADDR_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_HAVEADDR_ADDR+1)
|
||||
|
||||
|
||||
|
||||
|
||||
AQHOME_API uint32_t AQH_HaveAddrMsg_GetUid(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_HaveAddrMsg_GetAddress(const GWEN_MSG *msg);
|
||||
AQHOME_API void AQH_HaveAddrMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
@@ -19,16 +19,15 @@
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_NEEDADDR_UID 0
|
||||
|
||||
#define AQH_MSG_NEEDADDR_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_NEEDADDR_UID+4)
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_NeedAddrMsg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_NEED_ADDRESS) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_NEEDADDR_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_NEEDADDR_UID;
|
||||
return (uint32_t)(ptr[0])+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_NEEDADDR_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,13 +18,6 @@
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_NEEDADDR_UID 0
|
||||
|
||||
#define AQH_MSG_NEEDADDR_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_NEEDADDR_UID+4)
|
||||
|
||||
|
||||
|
||||
|
||||
AQHOME_API uint32_t AQH_NeedAddrMsg_GetUid(const GWEN_MSG *msg);
|
||||
AQHOME_API void AQH_NeedAddrMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
@@ -16,10 +16,15 @@
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
#define COM_USE_CRC8 1
|
||||
|
||||
|
||||
|
||||
#ifdef COM_USE_CRC8
|
||||
static uint8_t _calcCrc8Checksum(const uint8_t *ptr, uint8_t len);
|
||||
#else
|
||||
static uint8_t _calcXorChecksum(const uint8_t *ptr, uint8_t len);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
uint8_t AQH_NodeMsg_GetDestAddress(const GWEN_MSG *msg)
|
||||
@@ -104,8 +109,13 @@ int AQH_NodeMsg_IsMsgComplete(const GWEN_MSG *msg)
|
||||
|
||||
int AQH_NodeMsg_IsChecksumValid(const GWEN_MSG *msg)
|
||||
{
|
||||
if (msg && AQH_NodeMsg_IsMsgComplete(msg))
|
||||
if (msg && AQH_NodeMsg_IsMsgComplete(msg)) {
|
||||
#ifdef COM_USE_CRC8
|
||||
return (_calcCrc8Checksum(GWEN_Msg_GetConstBuffer(msg), GWEN_Msg_GetBytesInBuffer(msg))==0)?1:0;
|
||||
#else
|
||||
return (_calcXorChecksum(GWEN_Msg_GetConstBuffer(msg), GWEN_Msg_GetBytesInBuffer(msg))==0)?1:0;
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -116,7 +126,11 @@ int AQH_NodeMsg_AddChecksum(GWEN_MSG *msg)
|
||||
if (msg) {
|
||||
int rv;
|
||||
|
||||
#ifdef COM_USE_CRC8
|
||||
rv=GWEN_Msg_AddByte(msg, _calcCrc8Checksum(GWEN_Msg_GetConstBuffer(msg), GWEN_Msg_GetBytesInBuffer(msg)));
|
||||
#else
|
||||
rv=GWEN_Msg_AddByte(msg, _calcXorChecksum(GWEN_Msg_GetConstBuffer(msg), GWEN_Msg_GetBytesInBuffer(msg)));
|
||||
#endif
|
||||
if (rv<0) {
|
||||
DBG_INFO(NULL, "here (%d)", rv);
|
||||
return rv;
|
||||
@@ -128,6 +142,45 @@ int AQH_NodeMsg_AddChecksum(GWEN_MSG *msg)
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_NodeMsg_GetUint32At(const GWEN_MSG *msg, int offs, int defaultValue)
|
||||
{
|
||||
if ((GWEN_Msg_GetBytesInBuffer(msg)>=offs+4)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+offs;
|
||||
return (uint32_t)(ptr[0])+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_NodeMsg_GetUint16At(const GWEN_MSG *msg, int offs, int defaultValue)
|
||||
{
|
||||
if ((GWEN_Msg_GetBytesInBuffer(msg)>=offs+2)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+offs;
|
||||
return (uint16_t)(ptr[0])+(ptr[1]<<8);
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_NodeMsg_GetUint8At(const GWEN_MSG *msg, int offs, int defaultValue)
|
||||
{
|
||||
if ((GWEN_Msg_GetBytesInBuffer(msg)>=offs+1)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+offs;
|
||||
return ptr[0];
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_NodeMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
@@ -171,20 +224,7 @@ uint32_t AQH_NodeMsg_GetMsgGroup(uint8_t msgType)
|
||||
|
||||
|
||||
|
||||
uint8_t _calcXorChecksum(const uint8_t *ptr, uint8_t len)
|
||||
{
|
||||
int i;
|
||||
uint8_t x=0;
|
||||
|
||||
for (i=0; i<len; i++, ptr++) {
|
||||
x^=*ptr;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef COM_USE_CRC8
|
||||
uint8_t _calcCrc8Checksum(const uint8_t *ptr, uint8_t len)
|
||||
{
|
||||
int i;
|
||||
@@ -204,6 +244,21 @@ uint8_t _calcCrc8Checksum(const uint8_t *ptr, uint8_t len)
|
||||
|
||||
return x;
|
||||
}
|
||||
#else
|
||||
uint8_t _calcXorChecksum(const uint8_t *ptr, uint8_t len)
|
||||
{
|
||||
int i;
|
||||
uint8_t x=0;
|
||||
|
||||
for (i=0; i<len; i++, ptr++) {
|
||||
x^=*ptr;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
#define AQH_MAXMSGSIZE 16
|
||||
#define AQH_MAXMSGSIZE 24
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_ALL_DEST_ADDRESS 0
|
||||
@@ -69,6 +69,10 @@ AQHOME_API int AQH_NodeMsg_IsMsgComplete(const GWEN_MSG *msg);
|
||||
AQHOME_API int AQH_NodeMsg_IsChecksumValid(const GWEN_MSG *msg);
|
||||
AQHOME_API int AQH_NodeMsg_AddChecksum(GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API uint32_t AQH_NodeMsg_GetUint32At(const GWEN_MSG *msg, int offs, int defaultValue);
|
||||
AQHOME_API uint16_t AQH_NodeMsg_GetUint16At(const GWEN_MSG *msg, int offs, int defaultValue);
|
||||
AQHOME_API uint8_t AQH_NodeMsg_GetUint8At(const GWEN_MSG *msg, int offs, int defaultValue);
|
||||
|
||||
AQHOME_API void AQH_NodeMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
AQHOME_API uint32_t AQH_NodeMsg_GetMsgGroup(uint8_t msgType);
|
||||
|
||||
@@ -18,17 +18,15 @@
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_PING_TIMESTAMP 0
|
||||
|
||||
#define AQH_MSG_PING_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PING_TIMESTAMP+4)
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_PingMsg_GetTimestamp(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_PING) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_PING_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PING_TIMESTAMP;
|
||||
return (uint32_t)(ptr[0])+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PING_TIMESTAMP, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,13 +18,6 @@
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_PING_TIMESTAMP 0
|
||||
|
||||
#define AQH_MSG_PING_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PING_TIMESTAMP+4)
|
||||
|
||||
|
||||
|
||||
|
||||
AQHOME_API uint32_t AQH_PingMsg_GetTimestamp(const GWEN_MSG *msg);
|
||||
AQHOME_API void AQH_PingMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
@@ -18,17 +18,15 @@
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_PONG_TIMESTAMP 0
|
||||
|
||||
#define AQH_MSG_PONG_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PONG_TIMESTAMP+4)
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_PongMsg_GetTimestamp(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_PONG) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_PONG_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PONG_TIMESTAMP;
|
||||
return (uint32_t)(ptr[0])+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PONG_TIMESTAMP, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,13 +18,6 @@
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_PONG_TIMESTAMP 0
|
||||
|
||||
#define AQH_MSG_PONG_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PONG_TIMESTAMP+4)
|
||||
|
||||
|
||||
|
||||
|
||||
AQHOME_API uint32_t AQH_PongMsg_GetTimestamp(const GWEN_MSG *msg);
|
||||
AQHOME_API void AQH_PongMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
@@ -19,10 +19,13 @@
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_RECVSTATS_UID 0
|
||||
#define AQH_MSG_OFFS_RECVSTATS_PACKETSIN 4
|
||||
#define AQH_MSG_OFFS_RECVSTATS_CRCERRORS 6
|
||||
#define AQH_MSG_OFFS_RECVSTATS_UID 0
|
||||
#define AQH_MSG_OFFS_RECVSTATS_PACKETSIN 4
|
||||
#define AQH_MSG_OFFS_RECVSTATS_CRCERRORS 6
|
||||
#define AQH_MSG_OFFS_RECVSTATS_IOERRORS 8
|
||||
#define AQH_MSG_OFFS_RECVSTATS_NOBUFFER 10
|
||||
#define AQH_MSG_OFFS_RECVSTATS_HANDLED 12
|
||||
#define AQH_MSG_OFFS_RECVSTATS_MISSED 14
|
||||
|
||||
#define AQH_MSG_RECVSTATS_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_IOERRORS+2)
|
||||
|
||||
@@ -30,52 +33,49 @@
|
||||
|
||||
uint32_t AQH_RecvStatsMsg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_RECVSTATS_MINSIZE) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_UID;
|
||||
return (uint32_t)(ptr[0])+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMsg_GetPacketsIn(const GWEN_MSG *msg)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_RECVSTATS_MINSIZE) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_PACKETSIN;
|
||||
return (uint16_t)(ptr[0])+(ptr[1]<<8);
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_PACKETSIN, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMsg_GetCrcErrors(const GWEN_MSG *msg)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_RECVSTATS_MINSIZE) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_CRCERRORS;
|
||||
return (uint16_t)(ptr[0])+(ptr[1]<<8);
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_CRCERRORS, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMsg_GetIoErrors(const GWEN_MSG *msg)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_RECVSTATS_MINSIZE) {
|
||||
const uint8_t *ptr;
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_IOERRORS, 0);
|
||||
}
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_IOERRORS;
|
||||
return (uint16_t)(ptr[0])+(ptr[1]<<8);
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMsg_GetNoBufferErrors(const GWEN_MSG *msg)
|
||||
{
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_NOBUFFER, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMsg_GetHandled(const GWEN_MSG *msg)
|
||||
{
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_HANDLED, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMsg_GetMissed(const GWEN_MSG *msg)
|
||||
{
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_MISSED, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,14 +85,17 @@ void AQH_RecvStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_COMRECVSTATS) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_RECVSTATS_MINSIZE)) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: RECVSTATS %s (uid=0x%08x, in=%d, crc errors=%d, io errors=%d)\n",
|
||||
"0x%02x->0x%02x: RECVSTATS %s (uid=0x%08x, in=%d, crc errs=%d, io errs=%d, nobuf errs=%d, handled=%d, missed=%d)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_RecvStatsMsg_GetUid(msg),
|
||||
AQH_RecvStatsMsg_GetPacketsIn(msg),
|
||||
AQH_RecvStatsMsg_GetCrcErrors(msg),
|
||||
AQH_RecvStatsMsg_GetIoErrors(msg));
|
||||
AQH_RecvStatsMsg_GetIoErrors(msg),
|
||||
AQH_RecvStatsMsg_GetNoBufferErrors(msg),
|
||||
AQH_RecvStatsMsg_GetHandled(msg),
|
||||
AQH_RecvStatsMsg_GetMissed(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@ AQHOME_API uint32_t AQH_RecvStatsMsg_GetUid(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_RecvStatsMsg_GetPacketsIn(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_RecvStatsMsg_GetCrcErrors(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_RecvStatsMsg_GetIoErrors(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_RecvStatsMsg_GetNoBufferErrors(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_RecvStatsMsg_GetHandled(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_RecvStatsMsg_GetMissed(const GWEN_MSG *msg);
|
||||
|
||||
|
||||
AQHOME_API void AQH_RecvStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#define AQH_MSG_OFFS_SENDSTATS_PACKETSOUT 4
|
||||
#define AQH_MSG_OFFS_SENDSTATS_COLLISIONS 6
|
||||
#define AQH_MSG_OFFS_SENDSTATS_ABORTED 8
|
||||
#define AQH_MSG_OFFS_SENDSTATS_NOBUFFER 10
|
||||
|
||||
#define AQH_MSG_SENDSTATS_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_ABORTED+2)
|
||||
|
||||
@@ -29,56 +30,35 @@
|
||||
|
||||
uint32_t AQH_SendStatsMsg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_COMSENDSTATS) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_SENDSTATS_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_UID;
|
||||
return (uint32_t)(ptr[0])+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_SendStatsMsg_GetPacketsOut(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_COMSENDSTATS) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_SENDSTATS_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_PACKETSOUT;
|
||||
return (uint16_t)(ptr[0])+(ptr[1]<<8);
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_PACKETSOUT, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_SendStatsMsg_GetCollisions(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_COMSENDSTATS) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_SENDSTATS_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_COLLISIONS;
|
||||
return (uint16_t)(ptr[0])+(ptr[1]<<8);
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_COLLISIONS, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_SendStatsMsg_GetAborted(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_COMSENDSTATS) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_SENDSTATS_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_ABORTED, 0);
|
||||
}
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_ABORTED;
|
||||
return (uint16_t)(ptr[0])+(ptr[1]<<8);
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
||||
uint16_t AQH_SendStatsMsg_GetNoBufferErrors(const GWEN_MSG *msg)
|
||||
{
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_NOBUFFER, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,14 +68,15 @@ void AQH_SendStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_COMSENDSTATS) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_SENDSTATS_MINSIZE)) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: SENDSTATS %s (uid=0x%08x, out=%d, collisions=%d, aborted=%d)\n",
|
||||
"0x%02x->0x%02x: SENDSTATS %s (uid=0x%08x, out=%d, collisions=%d, aborted=%d, no buffer=%d)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_SendStatsMsg_GetUid(msg),
|
||||
AQH_SendStatsMsg_GetPacketsOut(msg),
|
||||
AQH_SendStatsMsg_GetCollisions(msg),
|
||||
AQH_SendStatsMsg_GetAborted(msg));
|
||||
AQH_SendStatsMsg_GetAborted(msg),
|
||||
AQH_SendStatsMsg_GetNoBufferErrors(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ AQHOME_API uint32_t AQH_SendStatsMsg_GetUid(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_SendStatsMsg_GetPacketsOut(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_SendStatsMsg_GetCollisions(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_SendStatsMsg_GetAborted(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_SendStatsMsg_GetNoBufferErrors(const GWEN_MSG *msg);
|
||||
|
||||
|
||||
AQHOME_API void AQH_SendStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
@@ -22,42 +22,21 @@
|
||||
|
||||
uint32_t AQH_ValueMsg_GetTimestamp(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_VALUE) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_VALUE_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE_TIMESTAMP;
|
||||
return (uint32_t)(ptr[0])+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE_TIMESTAMP, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_ValueMsg_GetValueId(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_VALUE) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_VALUE_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE_VALUEID;
|
||||
return ptr[0];
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE_VALUEID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_ValueMsg_GetValueType(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_VALUE) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_VALUE_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE_VALUETYPE;
|
||||
return ptr[0];
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE_VALUETYPE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,72 +19,47 @@
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_VALUE2_UID 0
|
||||
#define AQH_MSG_OFFS_VALUE2_VALUEID 4
|
||||
#define AQH_MSG_OFFS_VALUE2_VALUETYPE 5
|
||||
#define AQH_MSG_OFFS_VALUE2_VALUE 6
|
||||
#define AQH_MSG_OFFS_VALUE2_DENOM 8
|
||||
|
||||
#define AQH_MSG_VALUE2_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE2_DENOM+2)
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_Value2Msg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_VALUE2) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_VALUE2_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE2_TIMESTAMP;
|
||||
return (uint32_t)(ptr[0])+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE2_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_Value2Msg_GetValueId(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_VALUE2) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_VALUE2_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE2_VALUEID;
|
||||
return ptr[0];
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE2_VALUEID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_Value2Msg_GetValueType(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_VALUE2) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_VALUE2_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE2_VALUETYPE;
|
||||
return ptr[0];
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE2_VALUETYPE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int16_t AQH_Value2Msg_GetValueNom(const GWEN_MSG *msg)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_VALUE2) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_VALUE2_MINSIZE)) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE2_VALUE;
|
||||
return (int16_t)((uint16_t)((ptr[0])+(ptr[1]<<8)));
|
||||
}
|
||||
return 0;
|
||||
return (int16_t) AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE2_VALUE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int16_t AQH_Value2Msg_GetValueDenom(const GWEN_MSG *msg)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_VALUE2_MINSIZE) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE2_DENOM;
|
||||
return (int16_t)((uint16_t)((ptr[0])+(ptr[1]<<8)));
|
||||
}
|
||||
return 0;
|
||||
return (int16_t) AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE2_DENOM, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,14 +18,6 @@
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_VALUE2_TIMESTAMP 0
|
||||
#define AQH_MSG_OFFS_VALUE2_VALUEID 4
|
||||
#define AQH_MSG_OFFS_VALUE2_VALUETYPE 5
|
||||
#define AQH_MSG_OFFS_VALUE2_VALUE 6
|
||||
#define AQH_MSG_OFFS_VALUE2_DENOM 8
|
||||
|
||||
#define AQH_MSG_VALUE2_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE2_DENOM+2)
|
||||
|
||||
#define AQH_MSG_VALUE2_TYPE_TEMP 1
|
||||
#define AQH_MSG_VALUE2_TYPE_HUMIDITY 2
|
||||
|
||||
|
||||
Reference in New Issue
Block a user