aqhome, aqhome-apps: cleanup, removed unneeded files.
This commit is contained in:
@@ -45,61 +45,17 @@
|
||||
|
||||
|
||||
<headers dist="true" install="$(pkgincludedir)/msg" >
|
||||
endpoint_tty.h
|
||||
msg_node.h
|
||||
msg_ping.h
|
||||
msg_pong.h
|
||||
msg_claimaddr.h
|
||||
msg_denyaddr.h
|
||||
msg_haveaddr.h
|
||||
msg_needaddr.h
|
||||
msg_sendstats.h
|
||||
msg_recvstats.h
|
||||
msg_memstats.h
|
||||
msg_sysstats.h
|
||||
msg_value.h
|
||||
msg_value2.h
|
||||
msg_value3.h
|
||||
msg_device.h
|
||||
msg_flashready.h
|
||||
msg_flashstart.h
|
||||
msg_flashresponse.h
|
||||
msg_flashend.h
|
||||
msg_flashdata.h
|
||||
msg_reboot.h
|
||||
</headers>
|
||||
|
||||
|
||||
<headers dist="true" >
|
||||
endpoint_tty_p.h
|
||||
</headers>
|
||||
|
||||
|
||||
<sources>
|
||||
$(local/typefiles)
|
||||
|
||||
endpoint_tty.c
|
||||
msg_node.c
|
||||
msg_ping.c
|
||||
msg_pong.c
|
||||
msg_claimaddr.c
|
||||
msg_denyaddr.c
|
||||
msg_haveaddr.c
|
||||
msg_needaddr.c
|
||||
msg_sendstats.c
|
||||
msg_recvstats.c
|
||||
msg_memstats.c
|
||||
msg_sysstats.c
|
||||
msg_value.c
|
||||
msg_value2.c
|
||||
msg_value3.c
|
||||
msg_device.c
|
||||
msg_flashready.c
|
||||
msg_flashstart.c
|
||||
msg_flashresponse.c
|
||||
msg_flashend.c
|
||||
msg_flashdata.c
|
||||
msg_reboot.c
|
||||
dummy.c
|
||||
</sources>
|
||||
|
||||
|
||||
|
||||
0
aqhome/msg/dummy.c
Normal file
0
aqhome/msg/dummy.c
Normal file
@@ -1,423 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "aqhome/msg/endpoint_tty_p.h"
|
||||
|
||||
#include "aqhome/msg/msg_node.h"
|
||||
|
||||
#include <gwenhywfar/inherit.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
#include <gwenhywfar/text.h>
|
||||
#include <gwenhywfar/endpoint_msgio.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
#include <errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_ENDPOINT_TTY_BAUDRATE B19200
|
||||
#define AQH_MSG_ENDPOINT_TTY_BYTE_MICROSECS 520
|
||||
#define GWEN_ENDPOINT_TTY_RECONNECT_TIME 10
|
||||
|
||||
|
||||
|
||||
GWEN_INHERIT(GWEN_MSG_ENDPOINT, AQH_MSG_ENDPOINT_TTY)
|
||||
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* forward declarations
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void GWENHYWFAR_CB _freeData(void *bp, void *p);
|
||||
|
||||
/* virtual fn for GWEN_MSG_ENDPOINT */
|
||||
static void _addSockets(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKETSET *readSet, GWEN_SOCKETSET *writeSet, GWEN_SOCKETSET *xSet);
|
||||
|
||||
/* virtual fns for GWEN_MSG_ENDPOINT_MSGIO */
|
||||
static int _getBytesNeededForMessage(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *msg);
|
||||
static int _startMsg(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *msg);
|
||||
static void _endMsg(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *msg);
|
||||
|
||||
/* private fns */
|
||||
static int _getSocketFd(GWEN_MSG_ENDPOINT *ep);
|
||||
static int _openDevice(GWEN_MSG_ENDPOINT *ep);
|
||||
static int _attnLow(GWEN_MSG_ENDPOINT *ep);
|
||||
static int _attnHigh(GWEN_MSG_ENDPOINT *ep);
|
||||
static int _isAttnLow(GWEN_MSG_ENDPOINT *ep);
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* implementations
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
GWEN_MSG_ENDPOINT *AQH_TtyEndpoint_new(const char *devicePath, int groupId)
|
||||
{
|
||||
GWEN_MSG_ENDPOINT *ep;
|
||||
AQH_MSG_ENDPOINT_TTY *xep;
|
||||
|
||||
ep=GWEN_MsgEndpoint_new(AQH_MSG_ENDPOINT_TTY_NAME, groupId);
|
||||
GWEN_MsgEndpoint_SetDefaultMessageSize(ep, AQH_MAXMSGSIZE);
|
||||
|
||||
GWEN_NEW_OBJECT(AQH_MSG_ENDPOINT_TTY, xep);
|
||||
GWEN_INHERIT_SETDATA(GWEN_MSG_ENDPOINT, AQH_MSG_ENDPOINT_TTY, ep, xep, _freeData);
|
||||
|
||||
xep->deviceName=strdup(devicePath);
|
||||
|
||||
GWEN_MsgEndpoint_SetAddSocketsFn(ep, _addSockets);
|
||||
|
||||
/* extend with msg handling code */
|
||||
GWEN_MsgIoEndpoint_Extend(ep);
|
||||
GWEN_MsgIoEndpoint_SetGetNeededBytesFn(ep, _getBytesNeededForMessage);
|
||||
GWEN_MsgIoEndpoint_SetSendMsgStartFn(ep, _startMsg);
|
||||
GWEN_MsgIoEndpoint_SetSendMsgFinishFn(ep, _endMsg);
|
||||
|
||||
return ep;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _freeData(GWEN_UNUSED void *bp, void *p)
|
||||
{
|
||||
AQH_MSG_ENDPOINT_TTY *xep;
|
||||
|
||||
xep=(AQH_MSG_ENDPOINT_TTY*) p;
|
||||
free(xep->deviceName);
|
||||
GWEN_FREE_OBJECT(xep);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _addSockets(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKETSET *readSet, GWEN_SOCKETSET *writeSet, GWEN_UNUSED GWEN_SOCKETSET *xSet)
|
||||
{
|
||||
if (ep) {
|
||||
if (GWEN_MsgEndpoint_GetState(ep)==GWEN_MSG_ENDPOINT_STATE_UNCONNECTED) {
|
||||
time_t now;
|
||||
|
||||
now=time(NULL);
|
||||
if ((now-GWEN_MsgEndpoint_GetTimeOfLastStateChange(ep))>=GWEN_ENDPOINT_TTY_RECONNECT_TIME) {
|
||||
int rv;
|
||||
|
||||
/* (re)connect, set state */
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Starting to (re-)connect");
|
||||
rv=AQH_TtyEndpoint_Connect(ep);
|
||||
if (rv<0) {
|
||||
DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (GWEN_MsgEndpoint_GetState(ep)==GWEN_MSG_ENDPOINT_STATE_CONNECTED) {
|
||||
GWEN_SocketSet_AddSocket(readSet, GWEN_MsgEndpoint_GetSocket(ep));
|
||||
if (GWEN_MsgEndpoint_HaveMessageToSend(ep))
|
||||
GWEN_SocketSet_AddSocket(writeSet, GWEN_MsgEndpoint_GetSocket(ep));
|
||||
}
|
||||
} /* if (ep) */
|
||||
}
|
||||
|
||||
|
||||
|
||||
int AQH_TtyEndpoint_Connect(GWEN_MSG_ENDPOINT *ep)
|
||||
{
|
||||
if (ep) {
|
||||
if (GWEN_MsgEndpoint_GetState(ep)==GWEN_MSG_ENDPOINT_STATE_UNCONNECTED) {
|
||||
int fd;
|
||||
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Connecting TTY device");
|
||||
fd=_openDevice(ep);
|
||||
if (fd<0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "here (%d)", fd);
|
||||
return fd;
|
||||
}
|
||||
else {
|
||||
GWEN_SOCKET *sk;
|
||||
int rv;
|
||||
|
||||
sk=GWEN_Socket_fromFile(fd);
|
||||
rv=GWEN_Socket_SetBlocking(sk, 0);
|
||||
if (rv<0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Error setting socket nonblocking: %d", rv);
|
||||
GWEN_Socket_free(sk);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
GWEN_Socket_AddFlags(sk, GWEN_SOCKET_FLAGS_DUMP_READ);
|
||||
|
||||
GWEN_MsgEndpoint_SetSocket(ep, sk);
|
||||
GWEN_MsgEndpoint_SetState(ep, GWEN_MSG_ENDPOINT_STATE_CONNECTED);
|
||||
GWEN_MsgEndpoint_DiscardInput(ep);
|
||||
_attnHigh(ep);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Endpoint %s: Not unconnected", GWEN_MsgEndpoint_GetName(ep));
|
||||
return GWEN_ERROR_INVALID;
|
||||
}
|
||||
}
|
||||
return GWEN_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int _getSocketFd(GWEN_MSG_ENDPOINT *ep)
|
||||
{
|
||||
if (ep) {
|
||||
GWEN_SOCKET *sk;
|
||||
|
||||
sk=GWEN_MsgEndpoint_GetSocket(ep);
|
||||
if (sk) {
|
||||
return GWEN_Socket_GetSocketInt(sk);
|
||||
}
|
||||
}
|
||||
return GWEN_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int _openDevice(GWEN_MSG_ENDPOINT *ep)
|
||||
{
|
||||
AQH_MSG_ENDPOINT_TTY *xep;
|
||||
int fd;
|
||||
struct termios options;
|
||||
int rv;
|
||||
|
||||
xep=GWEN_INHERIT_GETDATA(GWEN_MSG_ENDPOINT, AQH_MSG_ENDPOINT_TTY, ep);
|
||||
assert(xep);
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Opening device %s", xep->deviceName);
|
||||
fd=open(xep->deviceName, O_NOCTTY | O_NDELAY | O_RDWR);
|
||||
if (fd<0) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Error on open(%s): %s (%d)", xep->deviceName, strerror(errno), errno);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Device %s open (socket %d)", xep->deviceName, fd);
|
||||
rv=tcgetattr(fd, &(xep->previousOptions));
|
||||
if (rv<0) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Error on tcgetattr(%s): %s (%d)", xep->deviceName, strerror(errno), errno);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
options=xep->previousOptions;
|
||||
// memset(&options, 0, sizeof(options)); /* preset */
|
||||
|
||||
options.c_cflag=CLOCAL | CREAD | CS8;
|
||||
options.c_iflag=IGNPAR | IGNBRK;
|
||||
options.c_oflag=0;
|
||||
options.c_lflag&= ~(ICANON | ECHO | ECHOE | ISIG);
|
||||
options.c_cc[VTIME]=0; /* read timeout in deciseconds */
|
||||
options.c_cc[VMIN]=0; /* no minimum number of receive bytes */
|
||||
cfmakeraw(&options);
|
||||
|
||||
rv=cfsetispeed(&options, AQH_MSG_ENDPOINT_TTY_BAUDRATE);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Error on cfsetispeed(%s): %s (%d)", xep->deviceName, strerror(errno), errno);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
rv=cfsetospeed(&options, AQH_MSG_ENDPOINT_TTY_BAUDRATE);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Error on cfsetospeed(%s): %s (%d)", xep->deviceName, strerror(errno), errno);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
|
||||
rv=tcflush(fd, TCIOFLUSH);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Error on tcflush(%s): %s (%d)", xep->deviceName, strerror(errno), errno);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
|
||||
rv=tcsetattr(fd, TCSANOW, &options);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Error on tcsetattr(%s): %s (%d)", xep->deviceName, strerror(errno), errno);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int _startMsg(GWEN_MSG_ENDPOINT *ep, GWEN_UNUSED GWEN_MSG *msg)
|
||||
{
|
||||
if (ep) {
|
||||
AQH_MSG_ENDPOINT_TTY *xep;
|
||||
|
||||
xep=GWEN_INHERIT_GETDATA(GWEN_MSG_ENDPOINT, AQH_MSG_ENDPOINT_TTY, ep);
|
||||
assert(xep);
|
||||
if (xep->intendedAttnState==1) {
|
||||
int rv;
|
||||
|
||||
rv=_isAttnLow(ep);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "here (%d)", rv);
|
||||
return rv;
|
||||
}
|
||||
if (rv>0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Line busy");
|
||||
usleep(AQH_MSG_ENDPOINT_TTY_BYTE_MICROSECS);
|
||||
return GWEN_ERROR_TIMEOUT;
|
||||
}
|
||||
|
||||
rv=_attnLow(ep);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "here (%d)", rv);
|
||||
return rv;
|
||||
}
|
||||
usleep(AQH_MSG_ENDPOINT_TTY_BYTE_MICROSECS/5);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _endMsg(GWEN_MSG_ENDPOINT *ep, GWEN_UNUSED GWEN_MSG *msg)
|
||||
{
|
||||
/* TODO: flush before releasing ATTN */
|
||||
_attnHigh(ep);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int _getBytesNeededForMessage(GWEN_UNUSED GWEN_MSG_ENDPOINT *ep, GWEN_MSG *msg)
|
||||
{
|
||||
uint32_t bytesInMsg;
|
||||
|
||||
bytesInMsg=GWEN_Msg_GetBytesInBuffer(msg);
|
||||
if (bytesInMsg<AQH_MSG_OFFS_ALL_DATA_BEGIN) {
|
||||
DBG_DEBUG(AQH_LOGDOMAIN, "Header not yet complete (%d)", bytesInMsg);
|
||||
return (int) (AQH_MSG_OFFS_ALL_DATA_BEGIN-bytesInMsg);
|
||||
}
|
||||
else {
|
||||
const uint8_t *ptr;
|
||||
uint32_t msgSize;
|
||||
int bytesNeeded;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg);
|
||||
msgSize=ptr[AQH_MSG_OFFS_ALL_PAYLOAD_LEN]+AQH_MSG_OFFS_ALL_PAYLOAD_BEGIN+1;
|
||||
if (msgSize>GWEN_Msg_GetMaxSize(msg)) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Message too long for msg (%d > %d)", msgSize, GWEN_Msg_GetMaxSize(msg));
|
||||
GWEN_MsgEndpoint_DiscardInput(ep);
|
||||
return GWEN_ERROR_BAD_DATA;
|
||||
}
|
||||
|
||||
bytesNeeded=(int) (msgSize-bytesInMsg);
|
||||
if (bytesNeeded<0 || (bytesNeeded==0 && bytesInMsg==0)) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Bad number of bytes needed, bad message format (bytesNeeded=%d)", bytesNeeded);
|
||||
GWEN_MsgEndpoint_DiscardInput(ep);
|
||||
return GWEN_ERROR_BAD_DATA;
|
||||
}
|
||||
|
||||
return bytesNeeded;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int _attnLow(GWEN_MSG_ENDPOINT *ep)
|
||||
{
|
||||
AQH_MSG_ENDPOINT_TTY *xep;
|
||||
int status;
|
||||
int rv;
|
||||
int fd;
|
||||
|
||||
xep=GWEN_INHERIT_GETDATA(GWEN_MSG_ENDPOINT, AQH_MSG_ENDPOINT_TTY, ep);
|
||||
assert(xep);
|
||||
fd=_getSocketFd(ep);
|
||||
if (fd<0) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Not connected (%s)", xep->deviceName);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
rv=ioctl(fd, TIOCMGET, &status); /* GET the State of MODEM bits in Status */
|
||||
if (rv<0) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Error on ioctl(%s): %s (%d)", xep->deviceName, strerror(errno), errno);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
status |= TIOCM_DTR | TIOCM_RTS; /* clear the DTR pin (cave: signals inverted!) */
|
||||
rv=ioctl(fd, TIOCMSET, &status);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Error on ioctl(%s): %s (%d)", xep->deviceName, strerror(errno), errno);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
xep->intendedAttnState=0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int _attnHigh(GWEN_MSG_ENDPOINT *ep)
|
||||
{
|
||||
AQH_MSG_ENDPOINT_TTY *xep;
|
||||
int status;
|
||||
int rv;
|
||||
int fd;
|
||||
|
||||
xep=GWEN_INHERIT_GETDATA(GWEN_MSG_ENDPOINT, AQH_MSG_ENDPOINT_TTY, ep);
|
||||
assert(xep);
|
||||
fd=_getSocketFd(ep);
|
||||
if (fd<0) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Not connected (%s)", xep->deviceName);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
rv=ioctl(fd, TIOCMGET, &status);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Error on ioctl(%s): %s (%d)", xep->deviceName, strerror(errno), errno);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
status |= TIOCM_DTR; /* Set the DTR pin */
|
||||
status &= ~ (TIOCM_DTR | TIOCM_RTS); /* clear the DTR pin (cave: signals inverted!) */
|
||||
rv=ioctl(fd, TIOCMSET, &status);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Error on ioctl(%s): %s (%d)", xep->deviceName, strerror(errno), errno);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
|
||||
xep->intendedAttnState=1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int _isAttnLow(GWEN_MSG_ENDPOINT *ep)
|
||||
{
|
||||
AQH_MSG_ENDPOINT_TTY *xep;
|
||||
int status;
|
||||
int rv;
|
||||
int fd;
|
||||
|
||||
xep=GWEN_INHERIT_GETDATA(GWEN_MSG_ENDPOINT, AQH_MSG_ENDPOINT_TTY, ep);
|
||||
assert(xep);
|
||||
fd=_getSocketFd(ep);
|
||||
if (fd<0) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Not connected (%s)", xep->deviceName);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
rv=ioctl(fd, TIOCMGET, &status);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Error on ioctl(%s): %s (%d)", xep->deviceName, strerror(errno), errno);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
return (status & TIOCM_CTS)?1:0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSGENDPOINT_TTY_H
|
||||
#define AQH_MSGENDPOINT_TTY_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
|
||||
#include <gwenhywfar/endpoint.h>
|
||||
|
||||
|
||||
#define AQH_MSG_ENDPOINT_TTY_NAME "tty"
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG_ENDPOINT *AQH_TtyEndpoint_new(const char *devicePath, int groupId);
|
||||
|
||||
AQHOME_API int AQH_TtyEndpoint_Connect(GWEN_MSG_ENDPOINT *ep);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,34 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSGENDPOINT_TTY_P_H
|
||||
#define AQH_MSGENDPOINT_TTY_P_H
|
||||
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
|
||||
#include "aqhome/msg/endpoint_tty.h"
|
||||
|
||||
#include <termios.h>
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct AQH_MSG_ENDPOINT_TTY AQH_MSG_ENDPOINT_TTY;
|
||||
struct AQH_MSG_ENDPOINT_TTY {
|
||||
char *deviceName;
|
||||
struct termios previousOptions;
|
||||
int intendedAttnState;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,60 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_claimaddr.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#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)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_CLAIMADDR_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_ClaimAddrMsg_GetAddress(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_CLAIMADDR_ADDR, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_ClaimAddrMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_CLAIM_ADDRESS) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_CLAIMADDR_MINSIZE)) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: CLAIM_ADDRESS %s (uid=0x%08x, address=0x%02x)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_ClaimAddrMsg_GetUid(msg),
|
||||
AQH_ClaimAddrMsg_GetAddress(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_CLAIMADDR_H
|
||||
#define AQH_MSG_CLAIMADDR_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_denyaddr.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
|
||||
#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)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DENYADDR_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_DenyAddrMsg_GetAddress(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DENYADDR_ADDR, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_DenyAddrMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_DENY_ADDRESS) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_DENYADDR_MINSIZE)) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: DENY_ADDRESS %s (uid=0x%08x, address=0x%02x)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_DenyAddrMsg_GetUid(msg),
|
||||
AQH_DenyAddrMsg_GetAddress(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_DENYADDR_H
|
||||
#define AQH_MSG_DENYADDR_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_device.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_DEVICE_UID 0 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_DEVICE_MANUF 4 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_DEVICE_DEVTYPE 8 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_DEVICE_DEVVERSION 10 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_DEVICE_DEVREVISION 11 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_DEVICE_FWVARIANT 12 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_DEVICE_FWVMAJOR 13 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_DEVICE_FWVMINOR 14 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_DEVICE_FWVPATCH 15 /* 1 byte */
|
||||
|
||||
|
||||
#define AQH_MSG_DEVICE_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_FWVPATCH+1)
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_DeviceMsg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_DeviceMsg_GetManufacturer(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_MANUF, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_DeviceMsg_GetDeviceType(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_DEVTYPE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_DeviceMsg_GetDeviceVersion(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_DEVVERSION, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_DeviceMsg_GetDeviceRevision(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_DEVREVISION, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_DeviceMsg_GetFirmwareVariant(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_FWVARIANT, 0);
|
||||
}
|
||||
|
||||
|
||||
uint8_t AQH_DeviceMsg_GetFirmwareVersionMajor(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_FWVMAJOR, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_DeviceMsg_GetFirmwareVersionMinor(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_FWVMINOR, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_DeviceMsg_GetFirmwareVersionPatchlevel(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_DEVICE_FWVPATCH, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_DeviceMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_DEVICE_MINSIZE) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: DEVICE %s (uid=0x%08x, dev=%08x:%04x v%d.%d, fw=%d.%d.%d (%d))\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_DeviceMsg_GetUid(msg),
|
||||
AQH_DeviceMsg_GetManufacturer(msg),
|
||||
AQH_DeviceMsg_GetDeviceType(msg),
|
||||
AQH_DeviceMsg_GetDeviceVersion(msg),
|
||||
AQH_DeviceMsg_GetDeviceRevision(msg),
|
||||
AQH_DeviceMsg_GetFirmwareVersionMajor(msg),
|
||||
AQH_DeviceMsg_GetFirmwareVersionMinor(msg),
|
||||
AQH_DeviceMsg_GetFirmwareVersionPatchlevel(msg),
|
||||
AQH_DeviceMsg_GetFirmwareVariant(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_DEVICE_H
|
||||
#define AQH_MSG_DEVICE_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
|
||||
AQHOME_API uint32_t AQH_DeviceMsg_GetUid(const GWEN_MSG *msg);
|
||||
AQHOME_API uint32_t AQH_DeviceMsg_GetManufacturer(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_DeviceMsg_GetDeviceType(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_DeviceMsg_GetDeviceVersion(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_DeviceMsg_GetDeviceRevision(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_DeviceMsg_GetFirmwareVariant(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_DeviceMsg_GetFirmwareVersionMajor(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_DeviceMsg_GetFirmwareVersionMinor(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_DeviceMsg_GetFirmwareVersionPatchlevel(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API void AQH_DeviceMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_flashdata.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
#include <gwenhywfar/text.h>
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_FLASHDATA_ADDRESS 0 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_FLASHDATA_DATA 4 /* x bytes */
|
||||
|
||||
|
||||
#define AQH_MSG_FLASHDATA_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHDATA_DATA)
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_FlashDataMsg_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code, uint32_t addr,
|
||||
const uint8_t *dataPtr, uint32_t dataLen)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
uint8_t *ptr;
|
||||
int rv;
|
||||
uint32_t i;
|
||||
|
||||
msg=AQH_NodeMsg_new(destAddr, srcAddr, code, dataLen+4, NULL);
|
||||
ptr=GWEN_Msg_GetBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHDATA_ADDRESS;
|
||||
|
||||
*(ptr++)=addr & 0xff;
|
||||
*(ptr++)=(addr>>8) & 0xff;
|
||||
*(ptr++)=(addr>>16) & 0xff;
|
||||
*(ptr++)=(addr>>24) & 0xff;
|
||||
|
||||
for (i=0; i<dataLen; i++) {
|
||||
*(ptr++)=*(dataPtr++);
|
||||
}
|
||||
|
||||
rv=AQH_NodeMsg_AddChecksum(msg);
|
||||
if (rv<0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "here (%d)", rv);
|
||||
GWEN_Msg_free(msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_FlashDataMsg_GetAddress(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHDATA_ADDRESS, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_FlashDataMsg_GetDataLen(const GWEN_MSG *msg)
|
||||
{
|
||||
uint8_t msgDataLen;
|
||||
|
||||
msgDataLen=GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_PAYLOAD_LEN, 0);
|
||||
if (msgDataLen>AQH_MSG_FLASHDATA_MINSIZE)
|
||||
return msgDataLen-6; /* cmd (1), src(1), addr(4) */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const uint8_t *AQH_FlashDataMsg_GetDataPtr(const GWEN_MSG *msg)
|
||||
{
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg);
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_FLASHDATA_MINSIZE)
|
||||
return ptr+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHDATA_DATA;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_FlashDataMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_FLASHDATA_MINSIZE) {
|
||||
GWEN_Buffer_AppendArgs(dbuf, "0x%02x->0x%02x: FLASHDATA %s (data address=0x%04x, data length=%d)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
AQH_FlashDataMsg_GetAddress(msg),
|
||||
AQH_FlashDataMsg_GetDataLen(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_FLASHDATA_H
|
||||
#define AQH_MSG_FLASHDATA_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_FlashDataMsg_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code, uint32_t addr,
|
||||
const uint8_t *dataPtr, uint32_t dataLen);
|
||||
|
||||
AQHOME_API uint32_t AQH_FlashDataMsg_GetAddress(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_FlashDataMsg_GetDataLen(const GWEN_MSG *msg);
|
||||
AQHOME_API const uint8_t *AQH_FlashDataMsg_GetDataPtr(const GWEN_MSG *msg);
|
||||
AQHOME_API void AQH_FlashDataMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_flashend.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_FLASHEND_REASON 0 /* 1 byte */
|
||||
|
||||
#define AQH_MSG_FLASHEND_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHEND_REASON+1)
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_FlashEndMsg_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code, uint8_t reason)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
uint8_t *ptr;
|
||||
int rv;
|
||||
|
||||
msg=AQH_NodeMsg_new(destAddr, srcAddr, code, 5, NULL);
|
||||
ptr=GWEN_Msg_GetBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHEND_REASON;
|
||||
|
||||
*(ptr++)=reason & 0xff; /* reason */
|
||||
GWEN_Msg_IncCurrentPos(msg, 5);
|
||||
|
||||
rv=AQH_NodeMsg_AddChecksum(msg);
|
||||
if (rv<0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "here (%d)", rv);
|
||||
GWEN_Msg_free(msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return msg;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_FlashEndMsg_GetReason(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHEND_REASON, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_FlashEndMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_FLASHEND_MINSIZE) {
|
||||
GWEN_Buffer_AppendArgs(dbuf, "0x%02x->0x%02x: FLASHEND %s (reason=%d)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
AQH_FlashEndMsg_GetReason(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_FLASHEND_H
|
||||
#define AQH_MSG_FLASHEND_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_FlashEndMsg_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code, uint8_t reason);
|
||||
|
||||
AQHOME_API uint8_t AQH_FlashEndMsg_GetReason(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API void AQH_FlashEndMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,136 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_flashready.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_FLASHREADY_UID 0 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_FLASHREADY_MANUF 4 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_FLASHREADY_DEVTYPE 8 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_FLASHREADY_DEVVERSION 10 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_FLASHREADY_DEVREVISION 11 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_FLASHREADY_FWVARIANT 12 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_FLASHREADY_FWVMAJOR 13 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_FLASHREADY_FWVMINOR 14 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_FLASHREADY_FWVPATCH 15 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_FLASHREADY_PAGESIZE 16 /* 2 bytes */
|
||||
|
||||
#define AQH_MSG_FLASHREADY_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_PAGESIZE+2)
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_FlashReadyMsg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_FlashReadyMsg_GetManufacturer(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_MANUF, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_FlashReadyMsg_GetDeviceType(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_DEVTYPE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_FlashReadyMsg_GetDeviceVersion(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_DEVVERSION, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_FlashReadyMsg_GetDeviceRevision(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_DEVREVISION, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_FlashReadyMsg_GetFirmwareVariant(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_FWVARIANT, 0);
|
||||
}
|
||||
|
||||
|
||||
uint8_t AQH_FlashReadyMsg_GetFirmwareVersionMajor(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_FWVMAJOR, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_FlashReadyMsg_GetFirmwareVersionMinor(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_FWVMINOR, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_FlashReadyMsg_GetFirmwareVersionPatchlevel(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_FWVPATCH, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_FlashReadyMsg_GetPagesize(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHREADY_PAGESIZE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void AQH_FlashReadyMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_FLASH_READY) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_FLASHREADY_MINSIZE)) {
|
||||
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: FLASHREADY %s (uid=0x%08x, dev=%08x:%04x v%d.%d, fw=%d.%d.%d (%d) pagesize=%d)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_FlashReadyMsg_GetUid(msg),
|
||||
AQH_FlashReadyMsg_GetManufacturer(msg),
|
||||
AQH_FlashReadyMsg_GetDeviceType(msg),
|
||||
AQH_FlashReadyMsg_GetDeviceVersion(msg),
|
||||
AQH_FlashReadyMsg_GetDeviceRevision(msg),
|
||||
AQH_FlashReadyMsg_GetFirmwareVersionMajor(msg),
|
||||
AQH_FlashReadyMsg_GetFirmwareVersionMinor(msg),
|
||||
AQH_FlashReadyMsg_GetFirmwareVersionPatchlevel(msg),
|
||||
AQH_FlashReadyMsg_GetFirmwareVariant(msg),
|
||||
AQH_FlashReadyMsg_GetPagesize(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_FLASHREADY_H
|
||||
#define AQH_MSG_FLASHREADY_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
AQHOME_API uint32_t AQH_FlashReadyMsg_GetUid(const GWEN_MSG *msg);
|
||||
AQHOME_API uint32_t AQH_FlashReadyMsg_GetManufacturer(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_FlashReadyMsg_GetDeviceType(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_FlashReadyMsg_GetDeviceVersion(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_FlashReadyMsg_GetDeviceRevision(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_FlashReadyMsg_GetFirmwareVariant(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_FlashReadyMsg_GetFirmwareVersionMajor(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_FlashReadyMsg_GetFirmwareVersionMinor(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_FlashReadyMsg_GetFirmwareVersionPatchlevel(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_FlashReadyMsg_GetPagesize(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API void AQH_FlashReadyMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_flashresponse.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_FLASHRESPONSE_CODE 0 /* 1 byte */
|
||||
|
||||
#define AQH_MSG_FLASHRESPONSE_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHRESPONSE_CODE+1)
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_FlashResponseMsg_GetCode(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHRESPONSE_CODE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_FlashResponseMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_FLASHRESPONSE_MINSIZE) {
|
||||
GWEN_Buffer_AppendArgs(dbuf, "0x%02x->0x%02x: FLASHRESPONSE %s (code=%d)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
AQH_FlashResponseMsg_GetCode(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_FLASHRESPONSE_H
|
||||
#define AQH_MSG_FLASHRESPONSE_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
AQHOME_API uint8_t AQH_FlashResponseMsg_GetCode(const GWEN_MSG *msg);
|
||||
AQHOME_API void AQH_FlashResponseMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_flashstart.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_FLASHSTART_UID 0 /* 4 bytes */
|
||||
|
||||
#define AQH_MSG_FLASHSTART_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHSTART_UID+4)
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_FlashStartMsg_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code, uint32_t uid)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
uint8_t *ptr;
|
||||
int rv;
|
||||
|
||||
msg=AQH_NodeMsg_new(destAddr, srcAddr, code, 8, NULL);
|
||||
ptr=GWEN_Msg_GetBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHSTART_UID;
|
||||
|
||||
*(ptr++)=uid & 0xff; /* uid */
|
||||
*(ptr++)=(uid>>8) & 0xff;
|
||||
*(ptr++)=(uid>>16) & 0xff;
|
||||
*(ptr++)=(uid>>24) & 0xff;
|
||||
|
||||
rv=AQH_NodeMsg_AddChecksum(msg);
|
||||
if (rv<0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "here (%d)", rv);
|
||||
GWEN_Msg_free(msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return msg;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_FlashStartMsg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_FLASHSTART_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_FlashStartMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_FLASHSTART_MINSIZE) {
|
||||
GWEN_Buffer_AppendArgs(dbuf, "0x%02x->0x%02x: FLASHSTART %s (uid=0x%08x)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_FlashStartMsg_GetUid(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_FLASHSTART_H
|
||||
#define AQH_MSG_FLASHSTART_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_FlashStartMsg_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code, uint32_t uid);
|
||||
|
||||
AQHOME_API uint32_t AQH_FlashStartMsg_GetUid(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API void AQH_FlashStartMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_haveaddr.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#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)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_HAVEADDR_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_HaveAddrMsg_GetAddress(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_HAVEADDR_ADDR, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_HaveAddrMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_HAVE_ADDRESS) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_HAVEADDR_MINSIZE)) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: HAVE_ADDRESS %s (uid=0x%08x, address=0x%02x)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_HaveAddrMsg_GetUid(msg),
|
||||
AQH_HaveAddrMsg_GetAddress(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_HAVEADDR_H
|
||||
#define AQH_MSG_HAVEADDR_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_memstats.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_MEMSTATS_SECONDS 0 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_MEMSTATS_UID 4 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_MEMSTATS_STACKUSAGE 8 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_MEMSTATS_BUFFERSUSED 10 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_MEMSTATS_MAXBUFFERSUSED 11 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_MEMSTATS_RECVNOBUFFER 12 /* 2 bytes */
|
||||
|
||||
#define AQH_MSG_MEMSTATS_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_MEMSTATS_RECVNOBUFFER+2)
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_MemStatsMsg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_MEMSTATS_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_MemStatsMsg_GetSeconds(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_MEMSTATS_SECONDS, 0);
|
||||
}
|
||||
|
||||
|
||||
uint16_t AQH_MemStatsMsg_GetStackUsage(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_MEMSTATS_STACKUSAGE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_MemStatsMsg_GetBuffersUsed(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_MEMSTATS_BUFFERSUSED, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_MemStatsMsg_GetMaxBuffersUsed(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_MEMSTATS_MAXBUFFERSUSED, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_MemStatsMsg_GetRecvNoBufferErrors(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_MEMSTATS_RECVNOBUFFER, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_MemStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: MEMSTATS %s (uid=0x%08x, uptime=%d, stack used=%d, buffers used=%d(max=%d), no recvbuf=%d)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_MemStatsMsg_GetUid(msg),
|
||||
AQH_MemStatsMsg_GetSeconds(msg),
|
||||
AQH_MemStatsMsg_GetStackUsage(msg),
|
||||
AQH_MemStatsMsg_GetBuffersUsed(msg),
|
||||
AQH_MemStatsMsg_GetMaxBuffersUsed(msg),
|
||||
AQH_MemStatsMsg_GetRecvNoBufferErrors(msg));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_MEMSTATS_H
|
||||
#define AQH_MSG_MEMSTATS_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
|
||||
AQHOME_API uint32_t AQH_MemStatsMsg_GetUid(const GWEN_MSG *msg);
|
||||
AQHOME_API uint32_t AQH_MemStatsMsg_GetSeconds(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_MemStatsMsg_GetStackUsage(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_MemStatsMsg_GetBuffersUsed(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_MemStatsMsg_GetMaxBuffersUsed(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_MemStatsMsg_GetSendNoBufferErrors(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_MemStatsMsg_GetRecvNoBufferErrors(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_MemStatsMsg_GetIdlePercentage(const GWEN_MSG *msg);
|
||||
|
||||
|
||||
AQHOME_API void AQH_MemStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_needaddr.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
|
||||
#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)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_NEEDADDR_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_NeedAddrMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_NEED_ADDRESS) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_NEEDADDR_MINSIZE)) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: NEED_ADDRESS %s (uid=0x%08x)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_NeedAddrMsg_GetUid(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_NEEDADDR_H
|
||||
#define AQH_MSG_NEEDADDR_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,308 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "aqhome/msg/msg_node.h"
|
||||
|
||||
#include <gwenhywfar/debug.h>
|
||||
#include <gwenhywfar/text.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
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_NodeMsg_new(uint8_t destAddr, uint8_t srcAddr, uint8_t code, uint8_t payloadLen, const uint8_t *payload)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
uint32_t len;
|
||||
uint8_t *ptr;
|
||||
|
||||
len=AQH_MSG_OFFS_ALL_DATA_BEGIN+payloadLen+1; /* dest, len, code, src, payload, crc8 */
|
||||
msg=GWEN_Msg_new(len);
|
||||
if (msg==NULL)
|
||||
return NULL;
|
||||
ptr=GWEN_Msg_GetBuffer(msg);
|
||||
|
||||
ptr[AQH_MSG_OFFS_ALL_DEST_ADDRESS]=destAddr & 0xff;
|
||||
ptr[AQH_MSG_OFFS_ALL_PAYLOAD_LEN]=payloadLen+2;
|
||||
ptr[AQH_MSG_OFFS_ALL_MSG_TYPE]=code;
|
||||
ptr[AQH_MSG_OFFS_ALL_SRC_ADDRESS]=srcAddr;
|
||||
|
||||
if (payloadLen && payload)
|
||||
memmove(ptr+AQH_MSG_OFFS_ALL_DATA_BEGIN, payload, payloadLen);
|
||||
GWEN_Msg_SetBytesInBuffer(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+payloadLen);
|
||||
GWEN_Msg_IncCurrentPos(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+payloadLen);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_NodeMsg_GetDestAddress(const GWEN_MSG *msg)
|
||||
{
|
||||
if (msg && GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_OFFS_ALL_DATA_BEGIN) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg);
|
||||
return ptr[AQH_MSG_OFFS_ALL_DEST_ADDRESS];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_NodeMsg_GetMsgType(const GWEN_MSG *msg)
|
||||
{
|
||||
if (msg && GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_OFFS_ALL_DATA_BEGIN) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg);
|
||||
return ptr[AQH_MSG_OFFS_ALL_MSG_TYPE];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_NodeMsg_GetSourceAddress(const GWEN_MSG *msg)
|
||||
{
|
||||
if (msg && GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_OFFS_ALL_DATA_BEGIN) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg);
|
||||
return ptr[AQH_MSG_OFFS_ALL_SRC_ADDRESS];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_NodeMsg_GetMsgPayloadLen(const GWEN_MSG *msg)
|
||||
{
|
||||
if (msg && GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_OFFS_ALL_DATA_BEGIN) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg);
|
||||
return ptr[AQH_MSG_OFFS_ALL_PAYLOAD_LEN];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int AQH_NodeMsg_IsMsgComplete(const GWEN_MSG *msg)
|
||||
{
|
||||
if (msg) {
|
||||
uint8_t msgLen;
|
||||
|
||||
msgLen=GWEN_Msg_GetBytesInBuffer(msg);
|
||||
if (msgLen>=AQH_MSG_OFFS_ALL_DATA_BEGIN) {
|
||||
const uint8_t *ptr;
|
||||
uint8_t len;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg);
|
||||
len=ptr[AQH_MSG_OFFS_ALL_PAYLOAD_LEN]+AQH_MSG_OFFS_ALL_PAYLOAD_BEGIN+1;
|
||||
if (len>AQH_MAXMSGSIZE) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Total length > max length (%d > %d)", len, AQH_MAXMSGSIZE);
|
||||
return -1;
|
||||
}
|
||||
else if (msgLen>=len)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int AQH_NodeMsg_IsChecksumValid(const GWEN_MSG *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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return GWEN_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_NodeMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: %d %s\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
AQH_NodeMsg_GetMsgType(msg),
|
||||
sText);
|
||||
GWEN_Text_DumpString2Buffer((const char*)GWEN_Msg_GetConstBuffer(msg), GWEN_Msg_GetBytesInBuffer(msg), dbuf, 34);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_NodeMsg_GetMsgGroup(uint8_t msgType)
|
||||
{
|
||||
switch(msgType) {
|
||||
case AQH_MSG_TYPE_PING:
|
||||
case AQH_MSG_TYPE_PONG:
|
||||
case AQH_MSG_TYPE_COMSENDSTATS:
|
||||
case AQH_MSG_TYPE_COMRECVSTATS:
|
||||
case AQH_MSG_TYPE_TWIBUSMEMBER:
|
||||
case AQH_MSG_TYPE_DEBUG:
|
||||
case AQH_MSG_TYPE_DEVICE:
|
||||
case AQH_MSG_TYPE_MEMSTATS:
|
||||
case AQH_MSG_TYPE_SYSSTATS:
|
||||
return AQH_MSG_TYPEGROUP_INFO;
|
||||
|
||||
case AQH_MSG_TYPE_VALUE:
|
||||
case AQH_MSG_TYPE_VALUE2:
|
||||
case AQH_MSG_TYPE_VALUE_REPORT:
|
||||
case AQH_MSG_TYPE_VALUE_SET:
|
||||
case AQH_MSG_TYPE_VALUE_SET_ACK:
|
||||
case AQH_MSG_TYPE_VALUE_SET_NACK:
|
||||
return AQH_MSG_TYPEGROUP_VALUES;
|
||||
|
||||
case AQH_MSG_TYPE_NEED_ADDRESS:
|
||||
case AQH_MSG_TYPE_HAVE_ADDRESS:
|
||||
case AQH_MSG_TYPE_CLAIM_ADDRESS:
|
||||
case AQH_MSG_TYPE_DENY_ADDRESS:
|
||||
case AQH_MSG_TYPE_ADDRESS_RANGE:
|
||||
return AQH_MSG_TYPEGROUP_ADDRESS;
|
||||
|
||||
case AQH_MSG_TYPE_NET_SET_ACCEPTED_MSGGROUPS:
|
||||
return AQH_MSG_TYPEGROUP_ADMIN;
|
||||
|
||||
case AQH_MSG_TYPE_FLASH_START:
|
||||
case AQH_MSG_TYPE_FLASH_END:
|
||||
case AQH_MSG_TYPE_FLASH_READY:
|
||||
case AQH_MSG_TYPE_FLASH_DATA:
|
||||
case AQH_MSG_TYPE_FLASH_RSP:
|
||||
case AQH_MSG_TYPE_REBOOT_REQ:
|
||||
case AQH_MSG_TYPE_REBOOT_RSP:
|
||||
return AQH_MSG_TYPEGROUP_FLASH;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef COM_USE_CRC8
|
||||
uint8_t _calcCrc8Checksum(const uint8_t *ptr, uint8_t len)
|
||||
{
|
||||
int i;
|
||||
uint8_t x=0xff;
|
||||
|
||||
for (i=0; i<len; i++, ptr++) {
|
||||
int j;
|
||||
|
||||
x^=*ptr;
|
||||
for (j=0; j<8; j++) {
|
||||
if (x & 0x80)
|
||||
x=(uint8_t) (x<<1)^0x97;
|
||||
else
|
||||
x<<=1;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
const char *AQH_NodeMsg_MsgTypeToChar(uint8_t i)
|
||||
{
|
||||
switch(i) {
|
||||
case AQH_MSG_TYPE_PING: return "Ping";
|
||||
case AQH_MSG_TYPE_PONG: return "Pong";
|
||||
case AQH_MSG_TYPE_COMSENDSTATS: return "SendStats";
|
||||
case AQH_MSG_TYPE_COMRECVSTATS: return "RecvStats";
|
||||
case AQH_MSG_TYPE_TWIBUSMEMBER: return "TwiBusMember";
|
||||
case AQH_MSG_TYPE_DEBUG: return "Debug";
|
||||
case AQH_MSG_TYPE_VALUE: return "Value";
|
||||
case AQH_MSG_TYPE_VALUE2: return "Value2";
|
||||
case AQH_MSG_TYPE_NEED_ADDRESS: return "NeedAddress";
|
||||
case AQH_MSG_TYPE_HAVE_ADDRESS: return "HaveAddress";
|
||||
case AQH_MSG_TYPE_CLAIM_ADDRESS: return "ClaimAddress";
|
||||
case AQH_MSG_TYPE_DENY_ADDRESS: return "DenyAddress";
|
||||
case AQH_MSG_TYPE_ADDRESS_RANGE: return "Range";
|
||||
|
||||
case AQH_MSG_TYPE_FLASH_START: return "FlashStart";
|
||||
case AQH_MSG_TYPE_FLASH_END: return "FlashEnd";
|
||||
case AQH_MSG_TYPE_FLASH_READY: return "FlashReady";
|
||||
case AQH_MSG_TYPE_FLASH_DATA: return "FlashData";
|
||||
case AQH_MSG_TYPE_FLASH_RSP: return "FlashResponse";
|
||||
|
||||
case AQH_MSG_TYPE_DEVICE: return "Device";
|
||||
case AQH_MSG_TYPE_MEMSTATS: return "MemStats";
|
||||
case AQH_MSG_TYPE_SYSSTATS: return "SysStats";
|
||||
case AQH_MSG_TYPE_REBOOT_REQ: return "RebootRequest";
|
||||
case AQH_MSG_TYPE_REBOOT_RSP: return "RebootResponse";
|
||||
default: return "(unknown)";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_NODE_H
|
||||
#define AQH_MSG_NODE_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
#define AQH_MAXMSGSIZE 128
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_ALL_DEST_ADDRESS 0
|
||||
#define AQH_MSG_OFFS_ALL_PAYLOAD_LEN 1
|
||||
#define AQH_MSG_OFFS_ALL_PAYLOAD_BEGIN 2
|
||||
#define AQH_MSG_OFFS_ALL_MSG_TYPE 2
|
||||
#define AQH_MSG_OFFS_ALL_SRC_ADDRESS 3
|
||||
#define AQH_MSG_OFFS_ALL_DATA_BEGIN 4
|
||||
|
||||
|
||||
#define AQH_MSG_TYPE_PING 10
|
||||
#define AQH_MSG_TYPE_PONG 11
|
||||
#define AQH_MSG_TYPE_COMSENDSTATS 20
|
||||
#define AQH_MSG_TYPE_COMRECVSTATS 21
|
||||
#define AQH_MSG_TYPE_TWIBUSMEMBER 30
|
||||
#define AQH_MSG_TYPE_DEBUG 40
|
||||
#define AQH_MSG_TYPE_VALUE 50 /* deprecated */
|
||||
#define AQH_MSG_TYPE_VALUE2 51 /* deprecated */
|
||||
#define AQH_MSG_TYPE_NEED_ADDRESS 60
|
||||
#define AQH_MSG_TYPE_HAVE_ADDRESS 61
|
||||
#define AQH_MSG_TYPE_CLAIM_ADDRESS 62
|
||||
#define AQH_MSG_TYPE_DENY_ADDRESS 63
|
||||
#define AQH_MSG_TYPE_ADDRESS_RANGE 64
|
||||
|
||||
#define AQH_MSG_TYPE_FLASH_START 70
|
||||
#define AQH_MSG_TYPE_FLASH_END 71
|
||||
#define AQH_MSG_TYPE_FLASH_READY 72
|
||||
#define AQH_MSG_TYPE_FLASH_DATA 73
|
||||
#define AQH_MSG_TYPE_FLASH_RSP 74
|
||||
|
||||
#define AQH_MSG_TYPE_DEVICE 80
|
||||
#define AQH_MSG_TYPE_MEMSTATS 81
|
||||
#define AQH_MSG_TYPE_SYSSTATS 82
|
||||
|
||||
#define AQH_MSG_TYPE_REBOOT_REQ 90
|
||||
#define AQH_MSG_TYPE_REBOOT_RSP 91
|
||||
|
||||
#define AQH_MSG_TYPE_VALUE_REPORT 100
|
||||
#define AQH_MSG_TYPE_VALUE_SET 101
|
||||
#define AQH_MSG_TYPE_VALUE_SET_ACK 102
|
||||
#define AQH_MSG_TYPE_VALUE_SET_NACK 103
|
||||
|
||||
|
||||
/* internal msg types via NET interface */
|
||||
#define AQH_MSG_TYPE_NET_SET_ACCEPTED_MSGGROUPS 200
|
||||
|
||||
|
||||
#define AQH_MSG_TYPEGROUP_INFO 0x00000001
|
||||
#define AQH_MSG_TYPEGROUP_VALUES 0x00000002
|
||||
#define AQH_MSG_TYPEGROUP_ADDRESS 0x00000004
|
||||
#define AQH_MSG_TYPEGROUP_FLASH 0x00000008
|
||||
#define AQH_MSG_TYPEGROUP_ADMIN 0x00000010
|
||||
#define AQH_MSG_TYPEGROUP_ALL 0xffffffff
|
||||
|
||||
|
||||
#define AQH_MSG_MODULES_MASK_TIMER 0x02
|
||||
#define AQH_MSG_MODULES_MASK_COM 0x04
|
||||
#define AQH_MSG_MODULES_MASK_LED 0x08
|
||||
#define AQH_MSG_MODULES_MASK_TWIMASTER 0x10
|
||||
#define AQH_MSG_MODULES_MASK_LCD 0x20
|
||||
#define AQH_MSG_MODULES_MASK_SI7021 0x40
|
||||
#define AQH_MSG_MODULES_MASK_STATS 0x80
|
||||
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_NodeMsg_new(uint8_t destAddr, uint8_t srcAddr, uint8_t code, uint8_t payloadLen, const uint8_t *payload);
|
||||
|
||||
|
||||
AQHOME_API uint8_t AQH_NodeMsg_GetDestAddress(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_NodeMsg_GetMsgType(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_NodeMsg_GetSourceAddress(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_NodeMsg_GetMsgPayloadLen(const GWEN_MSG *msg);
|
||||
|
||||
|
||||
|
||||
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 void AQH_NodeMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
AQHOME_API uint32_t AQH_NodeMsg_GetMsgGroup(uint8_t msgType);
|
||||
|
||||
AQHOME_API const char *AQH_NodeMsg_MsgTypeToChar(uint8_t i);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,80 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_ping.h"
|
||||
#include "aqhome/msg/msg_node.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
#include <gwenhywfar/text.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+1)
|
||||
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_PingMsg_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
uint8_t *ptr;
|
||||
int rv;
|
||||
|
||||
msg=AQH_NodeMsg_new(destAddr, srcAddr, code, 4, NULL);
|
||||
ptr=GWEN_Msg_GetBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PING_TIMESTAMP;
|
||||
*(ptr++)=0; /* timestamp */
|
||||
*(ptr++)=0;
|
||||
*(ptr++)=0;
|
||||
*ptr=0;
|
||||
|
||||
rv=AQH_NodeMsg_AddChecksum(msg);
|
||||
if (rv<0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "here (%d)", rv);
|
||||
GWEN_Msg_free(msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_PingMsg_GetTimestamp(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PING_TIMESTAMP, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_PingMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_PING) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_PING_MINSIZE)) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: PING %s (timestamp=0x%08x)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_PingMsg_GetTimestamp(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_NODE_PING_H
|
||||
#define AQH_MSG_NODE_PING_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_PingMsg_new(uint8_t code, uint8_t srcAddr, uint8_t destAddr);
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_pong.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#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)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PONG_TIMESTAMP, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_PongMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_PONG) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_PONG_MINSIZE)) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: PONG %s (timestamp=0x%08x)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_PongMsg_GetTimestamp(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_NODE_PONG_H
|
||||
#define AQH_MSG_NODE_PONG_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_reboot.h"
|
||||
#include "aqhome/msg/msg_node.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
#include <gwenhywfar/text.h>
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_REBOOT_UID 0 /* 4 bytes */
|
||||
|
||||
#define AQH_MSG_REBOOT_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_REBOOT_UID+4)
|
||||
|
||||
|
||||
|
||||
static GWEN_MSG *_rebootMsg_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code, uint32_t uid);
|
||||
static uint32_t _getUid(const GWEN_MSG *msg);
|
||||
static void _rebootMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText, const char *cmd);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_RebootRequestMsg_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code, uint32_t uid)
|
||||
{
|
||||
return _rebootMsg_new(srcAddr, destAddr, code, uid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_RebootRequestMsg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
return _getUid(msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_RebootRequestMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
_rebootMsg_DumpToBuffer(msg, dbuf, sText, "REBOOT_REQUEST");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_RebootResponseMsg_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code, uint32_t uid)
|
||||
{
|
||||
return _rebootMsg_new(srcAddr, destAddr, code, uid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_RebootResponseMsg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
return _getUid(msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_RebootResponseMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
_rebootMsg_DumpToBuffer(msg, dbuf, sText, "REBOOT_RESPONSE");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *_rebootMsg_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code, uint32_t uid)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
uint8_t *ptr;
|
||||
int rv;
|
||||
|
||||
msg=AQH_NodeMsg_new(destAddr, srcAddr, code, 4, NULL);
|
||||
ptr=GWEN_Msg_GetBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_REBOOT_UID;
|
||||
|
||||
*(ptr++)=uid & 0xff; /* uid */
|
||||
*(ptr++)=(uid>>8) & 0xff;
|
||||
*(ptr++)=(uid>>16) & 0xff;
|
||||
*(ptr++)=(uid>>24) & 0xff;
|
||||
|
||||
|
||||
rv=AQH_NodeMsg_AddChecksum(msg);
|
||||
if (rv<0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "here (%d)", rv);
|
||||
GWEN_Msg_free(msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t _getUid(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_REBOOT_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _rebootMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText, const char *cmd)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_REBOOT_MINSIZE) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: %s %s (uid=0x%08x)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
cmd,
|
||||
sText,
|
||||
_getUid(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_NODE_REBOOT_H
|
||||
#define AQH_MSG_NODE_REBOOT_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_RebootRequestMsg_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code, uint32_t uid);
|
||||
|
||||
AQHOME_API uint32_t AQH_RebootRequestMsg_GetUid(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API void AQH_RebootRequestMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_RebootResponseMsg_new(uint8_t srcAddr, uint8_t destAddr, uint8_t code, uint32_t uid);
|
||||
|
||||
AQHOME_API uint32_t AQH_RebootResponseMsg_GetUid(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API void AQH_RebootResponseMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_recvstats.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_RECVSTATS_UID 0 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_RECVSTATS_PACKETSIN 4 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_RECVSTATS_CRCERRORS 6 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_RECVSTATS_IOERRORS 8 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_RECVSTATS_NOBUFFER 10 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_RECVSTATS_HANDLED 12 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_RECVSTATS_MISSED 14 /* 2 bytes */
|
||||
|
||||
#define AQH_MSG_RECVSTATS_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_IOERRORS+2)
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_RecvStatsMsg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMsg_GetPacketsIn(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_PACKETSIN, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMsg_GetCrcErrors(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_CRCERRORS, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMsg_GetIoErrors(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_IOERRORS, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMsg_GetNoBufferErrors(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_NOBUFFER, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMsg_GetHandled(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_HANDLED, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMsg_GetMissed(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_MISSED, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_RecvStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
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 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_GetNoBufferErrors(msg),
|
||||
AQH_RecvStatsMsg_GetHandled(msg),
|
||||
AQH_RecvStatsMsg_GetMissed(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_RECVSTATS_H
|
||||
#define AQH_MSG_RECVSTATS_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_sendstats.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_SENDSTATS_UID 0 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_SENDSTATS_PACKETSOUT 4 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_SENDSTATS_COLLISIONS 6 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_SENDSTATS_BUSY 8 /* 2 bytes */
|
||||
|
||||
#define AQH_MSG_SENDSTATS_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_BUSY+2)
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_SendStatsMsg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_SendStatsMsg_GetPacketsOut(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_PACKETSOUT, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_SendStatsMsg_GetCollisions(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_COLLISIONS, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_SendStatsMsg_GetBusyErrors(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_BUSY, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_SendStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
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, busy line=%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_GetBusyErrors(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_SENDSTATS_H
|
||||
#define AQH_MSG_SENDSTATS_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
|
||||
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_GetBusyErrors(const GWEN_MSG *msg);
|
||||
|
||||
|
||||
AQHOME_API void AQH_SendStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_sysstats.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_SYSSTATS_SECONDS 0 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_SYSSTATS_UID 4 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_SYSSTATS_COMIRQS 8 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_SYSSTATS_TIMERIRQS 10 /* 2 bytes */
|
||||
|
||||
#define AQH_MSG_MEMSTATS_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SYSSTATS_TIMERIRQS+2)
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_SysStatsMsg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SYSSTATS_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_SysStatsMsg_GetSeconds(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SYSSTATS_SECONDS, 0);
|
||||
}
|
||||
|
||||
|
||||
uint16_t AQH_SysStatsMsg_GetComInterrupts(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SYSSTATS_COMIRQS, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_SysStatsMsg_GetTimerInterrupts(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SYSSTATS_TIMERIRQS, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_SysStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: SYSSTATS %s (uid=0x%08x, uptime=%d, com irqs=%d, timer irqs=%d)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_SysStatsMsg_GetUid(msg),
|
||||
AQH_SysStatsMsg_GetSeconds(msg),
|
||||
AQH_SysStatsMsg_GetComInterrupts(msg),
|
||||
AQH_SysStatsMsg_GetTimerInterrupts(msg));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_SYS_MEMSTATS_H
|
||||
#define AQH_SYS_MEMSTATS_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
|
||||
AQHOME_API uint32_t AQH_SysStatsMsg_GetUid(const GWEN_MSG *msg);
|
||||
AQHOME_API uint32_t AQH_SysStatsMsg_GetSeconds(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_SysStatsMsg_GetComInterrupts(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_SysStatsMsg_GetTimerInterrupts(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_SysStatsMsg_GetIdlePercentage(const GWEN_MSG *msg);
|
||||
|
||||
|
||||
AQHOME_API void AQH_SysStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_value.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_ValueMsg_GetTimestamp(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE_TIMESTAMP, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_ValueMsg_GetValueId(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE_VALUEID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_ValueMsg_GetValueType(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE_VALUETYPE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *AQH_ValueMsg_GetValueTypeName(const GWEN_MSG *msg)
|
||||
{
|
||||
uint8_t t;
|
||||
|
||||
t=AQH_ValueMsg_GetValueType(msg);
|
||||
switch(t) {
|
||||
case AQH_MSG_VALUE_TYPE_TEMP: return "temperature";
|
||||
case AQH_MSG_VALUE_TYPE_HUMIDITY: return "humidity";
|
||||
default: break;
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
|
||||
|
||||
double AQH_ValueMsg_GetValue(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;
|
||||
double value;
|
||||
double denom;
|
||||
uint16_t intDenom;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN;
|
||||
value=(double)((ptr[AQH_MSG_OFFS_VALUE_VALUE])+(ptr[AQH_MSG_OFFS_VALUE_VALUE+1]<<8));
|
||||
intDenom=(ptr[AQH_MSG_OFFS_VALUE_DENOM])+(ptr[AQH_MSG_OFFS_VALUE_DENOM+1]<<8);
|
||||
denom=(double)(intDenom);
|
||||
if (intDenom==0)
|
||||
denom=1.0;
|
||||
return (double)(value/denom);
|
||||
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_ValueMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_VALUE) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_VALUE_MINSIZE)) {
|
||||
GWEN_Buffer_AppendArgs(dbuf, "0x%02x->0x%02x: VALUE %s (timestamp=0x%08x, value_id=0x%02x type=%s value=%f)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_ValueMsg_GetTimestamp(msg),
|
||||
AQH_ValueMsg_GetValueId(msg),
|
||||
AQH_ValueMsg_GetValueTypeName(msg),
|
||||
AQH_ValueMsg_GetValue(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_VALUE_H
|
||||
#define AQH_MSG_VALUE_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_VALUE_TIMESTAMP 0
|
||||
#define AQH_MSG_OFFS_VALUE_VALUEID 4
|
||||
#define AQH_MSG_OFFS_VALUE_VALUETYPE 5
|
||||
#define AQH_MSG_OFFS_VALUE_VALUE 6
|
||||
#define AQH_MSG_OFFS_VALUE_DENOM 8
|
||||
|
||||
#define AQH_MSG_VALUE_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE_DENOM+2)
|
||||
|
||||
#define AQH_MSG_VALUE_TYPE_TEMP 1
|
||||
#define AQH_MSG_VALUE_TYPE_HUMIDITY 2
|
||||
|
||||
|
||||
|
||||
AQHOME_API uint32_t AQH_ValueMsg_GetTimestamp(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_ValueMsg_GetValueId(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_ValueMsg_GetValueType(const GWEN_MSG *msg);
|
||||
AQHOME_API double AQH_ValueMsg_GetValue(const GWEN_MSG *msg);
|
||||
|
||||
|
||||
AQHOME_API void AQH_ValueMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,163 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_value2.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
|
||||
#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)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE2_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_Value2Msg_GetValueId(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE2_VALUEID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_Value2Msg_GetValueType(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE2_VALUETYPE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int16_t AQH_Value2Msg_GetValueNom(const GWEN_MSG *msg)
|
||||
{
|
||||
return (int16_t) GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE2_VALUE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int16_t AQH_Value2Msg_GetValueDenom(const GWEN_MSG *msg)
|
||||
{
|
||||
return (int16_t) GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE2_DENOM, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *AQH_Value2Msg_GetValueTypeName(const GWEN_MSG *msg)
|
||||
{
|
||||
uint8_t t;
|
||||
|
||||
t=AQH_Value2Msg_GetValueType(msg);
|
||||
switch(t) {
|
||||
case AQH_MSG_VALUE2_TYPE_TEMP: return "temperature";
|
||||
case AQH_MSG_VALUE2_TYPE_HUMIDITY: return "humidity";
|
||||
case AQH_MSG_VALUE2_TYPE_DOOR: return "door_window";
|
||||
default: break;
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *AQH_Value2Msg_GetValueAsWindowStateString(const GWEN_MSG *msg)
|
||||
{
|
||||
switch(AQH_Value2Msg_GetValueNom(msg)) {
|
||||
case 0: return "closed";
|
||||
case 128: return "tilted";
|
||||
case 255: return "open";
|
||||
default: break;
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *AQH_Value2Msg_GetValueTypeUnits(const GWEN_MSG *msg)
|
||||
{
|
||||
uint8_t t;
|
||||
|
||||
t=AQH_Value2Msg_GetValueType(msg);
|
||||
switch(t) {
|
||||
case AQH_MSG_VALUE2_TYPE_TEMP: return "Celsius";
|
||||
case AQH_MSG_VALUE2_TYPE_HUMIDITY: return "%";
|
||||
case AQH_MSG_VALUE2_TYPE_DOOR: return NULL;
|
||||
default: break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
double AQH_Value2Msg_GetValue(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;
|
||||
double value;
|
||||
double denom;
|
||||
uint16_t intDenom;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN;
|
||||
value=(double)((ptr[AQH_MSG_OFFS_VALUE2_VALUE])+(ptr[AQH_MSG_OFFS_VALUE2_VALUE+1]<<8));
|
||||
intDenom=(ptr[AQH_MSG_OFFS_VALUE2_DENOM])+(ptr[AQH_MSG_OFFS_VALUE2_DENOM+1]<<8);
|
||||
denom=(double)(intDenom);
|
||||
if (intDenom==0)
|
||||
denom=1.0;
|
||||
return (double)(value/denom);
|
||||
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_Value2Msg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_VALUE2) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_VALUE2_MINSIZE)) {
|
||||
if (AQH_Value2Msg_GetValueType(msg)==AQH_MSG_VALUE2_TYPE_DOOR)
|
||||
GWEN_Buffer_AppendArgs(dbuf, "0x%02x->0x%02x: VALUE2 %s (uid=0x%08x, value_id=0x%02x type=%s value=%s)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_Value2Msg_GetUid(msg),
|
||||
AQH_Value2Msg_GetValueId(msg),
|
||||
AQH_Value2Msg_GetValueTypeName(msg),
|
||||
AQH_Value2Msg_GetValueAsWindowStateString(msg));
|
||||
else
|
||||
GWEN_Buffer_AppendArgs(dbuf, "0x%02x->0x%02x: VALUE2 %s (uid=0x%08x, value_id=0x%02x type=%s value=%f)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_Value2Msg_GetUid(msg),
|
||||
AQH_Value2Msg_GetValueId(msg),
|
||||
AQH_Value2Msg_GetValueTypeName(msg),
|
||||
AQH_Value2Msg_GetValue(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_VALUE2_H
|
||||
#define AQH_MSG_VALUE2_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_VALUE2_TYPE_TEMP 1
|
||||
#define AQH_MSG_VALUE2_TYPE_HUMIDITY 2
|
||||
#define AQH_MSG_VALUE2_TYPE_DOOR 3
|
||||
|
||||
|
||||
|
||||
AQHOME_API uint32_t AQH_Value2Msg_GetUid(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_Value2Msg_GetValueId(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_Value2Msg_GetValueType(const GWEN_MSG *msg);
|
||||
AQHOME_API int16_t AQH_Value2Msg_GetValueNom(const GWEN_MSG *msg);
|
||||
AQHOME_API int16_t AQH_Value2Msg_GetValueDenom(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API double AQH_Value2Msg_GetValue(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API const char *AQH_Value2Msg_GetValueAsWindowStateString(const GWEN_MSG *msg);
|
||||
AQHOME_API const char *AQH_Value2Msg_GetValueTypeName(const GWEN_MSG *msg);
|
||||
AQHOME_API const char *AQH_Value2Msg_GetValueTypeUnits(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API void AQH_Value2Msg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,234 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/msg/msg_value3.h"
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_VALUE3_UID 0 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_VALUE3_MSGID 4 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_VALUE3_VALUEID 6 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_VALUE3_VALUETYPE 7 /* 1 byte */
|
||||
#define AQH_MSG_OFFS_VALUE3_VALUE 8 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_VALUE3_DENOM 10 /* 2 bytes */
|
||||
|
||||
#define AQH_MSG_VALUE3_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE3_DENOM+2)
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_Value3Msg_new(uint8_t srcAddr, uint8_t destAddr,
|
||||
uint8_t code, uint16_t msgId,
|
||||
uint8_t valueId,
|
||||
uint16_t value, uint16_t denom)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
uint8_t *ptr;
|
||||
int rv;
|
||||
|
||||
msg=AQH_NodeMsg_new(destAddr, srcAddr, code, AQH_MSG_VALUE3_MINSIZE, NULL);
|
||||
ptr=GWEN_Msg_GetBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN;
|
||||
|
||||
*(ptr++)=0; /* uid (empty) */
|
||||
*(ptr++)=0;
|
||||
*(ptr++)=0;
|
||||
*(ptr++)=0;
|
||||
|
||||
*(ptr++)=msgId & 0xff; /* msgid */
|
||||
*(ptr++)=(msgId>>8) & 0xff;
|
||||
|
||||
*(ptr++)=valueId; /* valueid */
|
||||
*(ptr++)=0; /* valuetype (empty) */
|
||||
|
||||
*(ptr++)=value & 0xff; /* value */
|
||||
*(ptr++)=(value>>8) & 0xff;
|
||||
|
||||
*(ptr++)=denom & 0xff; /* denom */
|
||||
*(ptr++)=(denom>>8) & 0xff;
|
||||
|
||||
rv=AQH_NodeMsg_AddChecksum(msg);
|
||||
if (rv<0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "here (%d)", rv);
|
||||
GWEN_Msg_free(msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_Value3Msg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE3_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_Value3Msg_GetMsgId(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE3_MSGID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_Value3Msg_GetValueId(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE3_VALUEID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_Value3Msg_GetValueType(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE3_VALUETYPE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_Value3Msg_GetValueNom(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE3_VALUE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_Value3Msg_GetValueDenom(const GWEN_MSG *msg)
|
||||
{
|
||||
return (uint16_t) GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_VALUE3_DENOM, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *AQH_Value3Msg_GetValueTypeName(const GWEN_MSG *msg)
|
||||
{
|
||||
uint8_t t;
|
||||
|
||||
t=AQH_Value3Msg_GetValueType(msg);
|
||||
switch(t) {
|
||||
case AQH_MSG_VALUE3_TYPE_TEMP: return "temperature";
|
||||
case AQH_MSG_VALUE3_TYPE_HUMIDITY: return "humidity";
|
||||
case AQH_MSG_VALUE3_TYPE_DOOR: return "door_window";
|
||||
case AQH_MSG_VALUE3_TYPE_MOTION: return "motion";
|
||||
case AQH_MSG_VALUE3_TYPE_CO2: return "CO2";
|
||||
case AQH_MSG_VALUE3_TYPE_TVOC: return "TVOC";
|
||||
default: break;
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *AQH_Value3Msg_GetValueAsWindowStateString(const GWEN_MSG *msg)
|
||||
{
|
||||
switch(AQH_Value3Msg_GetValueNom(msg)) {
|
||||
case 0: return "closed";
|
||||
case 128: return "tilted";
|
||||
case 255: return "open";
|
||||
default: break;
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *AQH_Value3Msg_GetValueTypeUnits(const GWEN_MSG *msg)
|
||||
{
|
||||
uint8_t t;
|
||||
|
||||
t=AQH_Value3Msg_GetValueType(msg);
|
||||
switch(t) {
|
||||
case AQH_MSG_VALUE3_TYPE_TEMP: return "Celsius";
|
||||
case AQH_MSG_VALUE3_TYPE_HUMIDITY: return "%";
|
||||
case AQH_MSG_VALUE3_TYPE_DOOR: return NULL;
|
||||
case AQH_MSG_VALUE3_TYPE_CO2: return "ppm";
|
||||
case AQH_MSG_VALUE3_TYPE_TVOC: return "ppb";
|
||||
default: break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
double AQH_Value3Msg_GetValue(const GWEN_MSG *msg)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_VALUE3_MINSIZE) {
|
||||
const uint8_t *ptr;
|
||||
double value;
|
||||
double denom;
|
||||
uint16_t intDenom;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN;
|
||||
value=(double)((ptr[AQH_MSG_OFFS_VALUE3_VALUE])+(ptr[AQH_MSG_OFFS_VALUE3_VALUE+1]<<8));
|
||||
intDenom=(ptr[AQH_MSG_OFFS_VALUE3_DENOM])+(ptr[AQH_MSG_OFFS_VALUE3_DENOM+1]<<8);
|
||||
denom=(double)(intDenom);
|
||||
if (intDenom==0)
|
||||
denom=1.0;
|
||||
return (double)(value/denom);
|
||||
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_Value3Msg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_VALUE3_MINSIZE) {
|
||||
const char *sCmd;
|
||||
|
||||
switch(AQH_NodeMsg_GetMsgType(msg)) {
|
||||
case AQH_MSG_TYPE_VALUE_REPORT: sCmd="report"; break;
|
||||
case AQH_MSG_TYPE_VALUE_SET: sCmd="set"; break;
|
||||
case AQH_MSG_TYPE_VALUE_SET_ACK: sCmd="ack"; break;
|
||||
case AQH_MSG_TYPE_VALUE_SET_NACK: sCmd="nack"; break;
|
||||
default: sCmd="unknown"; break;
|
||||
}
|
||||
|
||||
if (AQH_Value3Msg_GetValueType(msg)==AQH_MSG_VALUE3_TYPE_DOOR)
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: VALUE3(%s) %s (uid=0x%08x, msgId=%u, value_id=0x%02x type=%s value=%s [%04x/%04x])\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sCmd,
|
||||
sText,
|
||||
(unsigned int) AQH_Value3Msg_GetUid(msg),
|
||||
(unsigned int)AQH_Value3Msg_GetMsgId(msg),
|
||||
AQH_Value3Msg_GetValueId(msg),
|
||||
AQH_Value3Msg_GetValueTypeName(msg),
|
||||
AQH_Value3Msg_GetValueAsWindowStateString(msg),
|
||||
AQH_Value3Msg_GetValueNom(msg),
|
||||
AQH_Value3Msg_GetValueDenom(msg));
|
||||
else
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: VALUE3(%s) %s (uid=0x%08x, msgId=%u, value_id=0x%02x type=%s value=%f [%04x/%04x])\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sCmd,
|
||||
sText,
|
||||
(unsigned int) AQH_Value3Msg_GetUid(msg),
|
||||
(unsigned int)AQH_Value3Msg_GetMsgId(msg),
|
||||
AQH_Value3Msg_GetValueId(msg),
|
||||
AQH_Value3Msg_GetValueTypeName(msg),
|
||||
AQH_Value3Msg_GetValue(msg),
|
||||
AQH_Value3Msg_GetValueNom(msg),
|
||||
AQH_Value3Msg_GetValueDenom(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2024 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_MSG_VALUE3_H
|
||||
#define AQH_MSG_VALUE3_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_VALUE3_TYPE_TEMP 1
|
||||
#define AQH_MSG_VALUE3_TYPE_HUMIDITY 2
|
||||
#define AQH_MSG_VALUE3_TYPE_DOOR 3
|
||||
#define AQH_MSG_VALUE3_TYPE_MOTION 6
|
||||
#define AQH_MSG_VALUE3_TYPE_CO2 7
|
||||
#define AQH_MSG_VALUE3_TYPE_TVOC 8
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_Value3Msg_new(uint8_t srcAddr, uint8_t destAddr,
|
||||
uint8_t code, uint16_t msgId,
|
||||
uint8_t valueId,
|
||||
uint16_t value, uint16_t denom);
|
||||
|
||||
AQHOME_API uint32_t AQH_Value3Msg_GetUid(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_Value3Msg_GetMsgId(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_Value3Msg_GetValueId(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_Value3Msg_GetValueType(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_Value3Msg_GetValueNom(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_Value3Msg_GetValueDenom(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API double AQH_Value3Msg_GetValue(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API const char *AQH_Value3Msg_GetValueAsWindowStateString(const GWEN_MSG *msg);
|
||||
AQHOME_API const char *AQH_Value3Msg_GetValueTypeName(const GWEN_MSG *msg);
|
||||
AQHOME_API const char *AQH_Value3Msg_GetValueTypeUnits(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API void AQH_Value3Msg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user