2018-06-05 00:32:26 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "data_link_layer.h"
|
|
|
|
|
|
|
|
class TpUartDataLinkLayer: public DataLinkLayer
|
|
|
|
{
|
|
|
|
using DataLinkLayer::_deviceObject;
|
2018-08-08 00:34:15 +02:00
|
|
|
using DataLinkLayer::_platform;
|
2018-08-14 23:40:47 +02:00
|
|
|
using DataLinkLayer::_groupAddressTable;
|
2018-06-05 00:32:26 +02:00
|
|
|
public:
|
|
|
|
TpUartDataLinkLayer(DeviceObject& devObj, AddressTableObject& addrTab, NetworkLayer& layer,
|
|
|
|
Platform& platform);
|
|
|
|
|
|
|
|
void loop();
|
|
|
|
void enabled(bool value);
|
|
|
|
bool enabled() const;
|
|
|
|
private:
|
|
|
|
bool _enabled = false;
|
2018-07-14 01:15:26 +02:00
|
|
|
uint8_t* _sendBuffer = 0;
|
|
|
|
bool _sendResult = false;
|
2018-07-25 22:24:25 +02:00
|
|
|
uint16_t _sendBufferLength = 0;
|
2018-06-05 00:32:26 +02:00
|
|
|
bool sendFrame(CemiFrame& frame);
|
2018-07-14 01:15:26 +02:00
|
|
|
bool checkDataInd(uint8_t firstByte);
|
|
|
|
bool checkDataCon(uint8_t firstByte);
|
|
|
|
bool checkPollDataInd(uint8_t firstByte);
|
|
|
|
bool checkAckNackInd(uint8_t firstByte);
|
|
|
|
bool checkResetInd(uint8_t firstByte);
|
|
|
|
bool checkStateInd(uint8_t firstByte);
|
|
|
|
bool checkFrameStateInd(uint8_t firstByte);
|
|
|
|
bool checkConfigureInd(uint8_t firstByte);
|
|
|
|
bool checkFrameEndInd(uint8_t firstByte);
|
|
|
|
bool checkStopModeInd(uint8_t firstByte);
|
|
|
|
bool checkSystemStatInd(uint8_t firstByte);
|
|
|
|
void handleUnexpected(uint8_t firstByte);
|
|
|
|
void sendBytes(uint8_t* buffer, uint16_t length);
|
2018-07-25 22:24:25 +02:00
|
|
|
void frameBytesReceived(uint8_t* buffer, uint16_t length);
|
2018-08-08 00:34:15 +02:00
|
|
|
void resetChip();
|
|
|
|
void stopChip();
|
2018-09-07 23:25:16 +02:00
|
|
|
void sendAck(AddressType type, uint16_t address);
|
2018-06-05 00:32:26 +02:00
|
|
|
};
|