You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.2 KiB
59 lines
1.2 KiB
/*
|
|
* z21prot.h
|
|
*
|
|
* Created on: 15.12.2017
|
|
* Author: steffen
|
|
*/
|
|
|
|
#ifndef Z21PROT_H_
|
|
#define Z21PROT_H_
|
|
|
|
#include <list>
|
|
#include "udp.h"
|
|
|
|
#define Z21_X_LEN 16
|
|
|
|
struct {
|
|
unsigned char xheader;
|
|
unsigned char db[Z21_X_LEN];
|
|
} typedef Z21_lan_x_data;
|
|
|
|
//
|
|
// work around for memory alignment on some CPUs/PocketPCs
|
|
uint8_t bufgetint8 (char *buf, int pos);
|
|
uint16_t bufgetint16 (char *buf, int pos);
|
|
uint32_t bufgetint32 (char *buf, int pos);
|
|
void bufsetint8 (char *buf, int pos, uint8_t i);
|
|
void bufsetint16 (char *buf, int pos, uint16_t i);
|
|
void bufsetint32 (char *buf, int pos, uint32_t i);
|
|
|
|
class Z21Client {
|
|
private:
|
|
char outbuf[NET_BUFFERSIZE];
|
|
string source;
|
|
public:
|
|
Z21Client();
|
|
~Z21Client();
|
|
|
|
void setSource(string newsrc) { source = newsrc; };
|
|
string getSource() { return source; };
|
|
bool isSource(string srcaddr) { return (source.compare(srcaddr) == 0); };
|
|
bool LoopData (UDPConnection *udp, char *buffer, size_t len);
|
|
void Send_LAN_RMBUS_DATACHANGED (UDPConnection *udp, unsigned char grpidx);
|
|
};
|
|
|
|
class Z21Server{
|
|
private:
|
|
list<Z21Client*> clients;
|
|
UDPConnection udp;
|
|
char buffer[NET_BUFFERSIZE];
|
|
public:
|
|
Z21Server ();
|
|
~Z21Server ();
|
|
|
|
int Loop(); // returns number of connections
|
|
void Start();
|
|
};
|
|
|
|
#endif /* Z21PROT_H_ */
|