save work

This commit is contained in:
Nanosonde 2020-07-16 21:21:33 +02:00
parent f46778c176
commit fb87828881
10 changed files with 28 additions and 1 deletions

View File

@ -29,6 +29,7 @@ class DataLinkLayer
virtual void loop() = 0;
virtual void enabled(bool value) = 0;
virtual bool enabled() const = 0;
virtual bool isOpenMedium() const = 0;
protected:
void frameRecieved(CemiFrame& frame);

View File

@ -99,6 +99,10 @@ bool IpDataLinkLayer::enabled() const
return _enabled;
}
bool IpDataLinkLayer::isOpenMedium() const
{
return false;
}
bool IpDataLinkLayer::sendBytes(uint8_t* bytes, uint16_t length)
{

View File

@ -17,6 +17,7 @@ class IpDataLinkLayer : public DataLinkLayer
void loop();
void enabled(bool value);
bool enabled() const;
virtual bool isOpenMedium() const override;
private:
bool _enabled = false;

View File

@ -1,5 +1,6 @@
#include "network_layer.h"
#include "device_object.h"
#include "data_link_layer.h"
#include "tpdu.h"
#include "cemi_frame.h"
#include "bits.h"
@ -108,8 +109,10 @@ void NetworkLayer::broadcastIndication(AckType ack, FrameFormat format, NPDU& np
{
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
DataLinkLayer& dlLayer = getEntity(npdu.frame().sourceInterface()).dataLinkLayer();
// for closed media like TP1 and IP
if (isApciSystemBroadcast(npdu.tpdu().apdu()))
if (!dlLayer.isOpenMedium() && isApciSystemBroadcast(npdu.tpdu().apdu()))
{
npdu.frame().systemBroadcast(SysBroadcast);
_transportLayer.dataSystemBroadcastIndication(hopType, priority, source, npdu.tpdu());

View File

@ -14,6 +14,11 @@ void NetworkLayerEntity::dataLinkLayer(DataLinkLayer& layer)
_dataLinkLayer = &layer;
}
DataLinkLayer& NetworkLayerEntity::dataLinkLayer()
{
return *_dataLinkLayer;
}
void NetworkLayerEntity::dataIndication(AckType ack, AddressType addrType, uint16_t destination, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source)
{
npdu.frame().sourceInterface(_entityIndex);

View File

@ -16,6 +16,7 @@ class NetworkLayerEntity
NetworkLayerEntity(NetworkLayer &netLayer, uint8_t entityIndex);
void dataLinkLayer(DataLinkLayer& layer);
DataLinkLayer& dataLinkLayer();
// from data link layer
void dataIndication(AckType ack, AddressType addType, uint16_t destination, FrameFormat format, NPDU& npdu,

View File

@ -269,6 +269,11 @@ bool RfDataLinkLayer::enabled() const
return _enabled;
}
bool RfDataLinkLayer::isOpenMedium() const
{
return true;
}
void RfDataLinkLayer::fillRfFrame(CemiFrame& frame, uint8_t* data)
{
uint16_t crc;

View File

@ -25,6 +25,7 @@ class RfDataLinkLayer : public DataLinkLayer
void loop();
void enabled(bool value);
bool enabled() const;
virtual bool isOpenMedium() const override;
private:
bool _enabled = false;

View File

@ -505,6 +505,11 @@ bool TpUartDataLinkLayer::enabled() const
return _enabled;
}
bool TpUartDataLinkLayer::isOpenMedium() const
{
return false;
}
bool TpUartDataLinkLayer::sendSingleFrameByte()
{
uint8_t cmd[2];

View File

@ -24,6 +24,7 @@ class TpUartDataLinkLayer : public DataLinkLayer
void loop();
void enabled(bool value);
bool enabled() const;
virtual bool isOpenMedium() const override;
private:
bool _enabled = false;