mirror of
https://github.com/thelsing/knx.git
synced 2025-11-07 01:20:20 +01:00
Nikwest (#100)
* fixed tipo: RepititionAllowed * fixed typo: frameRecieved * fixed typo: individualAddressDuplication * fixed typo: induvidualAddress * fixded Typo: InduvidualAddress Co-authored-by: Dominik Westner <nikwest@github.com>
This commit is contained in:
parent
ffa2eea65b
commit
5451235368
@ -51,7 +51,7 @@ void setup()
|
|||||||
srand((unsigned int)time(NULL));
|
srand((unsigned int)time(NULL));
|
||||||
knx.readMemory();
|
knx.readMemory();
|
||||||
|
|
||||||
if (knx.induvidualAddress() == 0)
|
if (knx.individualAddress() == 0)
|
||||||
knx.progMode(true);
|
knx.progMode(true);
|
||||||
|
|
||||||
if (knx.configured())
|
if (knx.configured())
|
||||||
|
|||||||
@ -97,7 +97,7 @@ void setup()
|
|||||||
srand((unsigned int)time(NULL));
|
srand((unsigned int)time(NULL));
|
||||||
knx.readMemory();
|
knx.readMemory();
|
||||||
|
|
||||||
if (knx.induvidualAddress() == 0)
|
if (knx.individualAddress() == 0)
|
||||||
knx.progMode(true);
|
knx.progMode(true);
|
||||||
|
|
||||||
if (knx.configured())
|
if (knx.configured())
|
||||||
|
|||||||
@ -75,7 +75,7 @@ void setup(void)
|
|||||||
// read adress table, association table, groupobject table and parameters from eeprom
|
// read adress table, association table, groupobject table and parameters from eeprom
|
||||||
knx.readMemory();
|
knx.readMemory();
|
||||||
|
|
||||||
if (knx.induvidualAddress() == 0)
|
if (knx.individualAddress() == 0)
|
||||||
knx.progMode(true);
|
knx.progMode(true);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -139,7 +139,7 @@ bool Bau07B0::isAckRequired(uint16_t address, bool isGrpAddr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Also ACK for our own individual address
|
// Also ACK for our own individual address
|
||||||
if (address == _deviceObj.induvidualAddress())
|
if (address == _deviceObj.individualAddress())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -441,7 +441,7 @@ void BauSystemB::individualAddressReadIndication(HopCountType hopType, const Sec
|
|||||||
void BauSystemB::individualAddressWriteIndication(HopCountType hopType, const SecurityControl &secCtrl, uint16_t newaddress)
|
void BauSystemB::individualAddressWriteIndication(HopCountType hopType, const SecurityControl &secCtrl, uint16_t newaddress)
|
||||||
{
|
{
|
||||||
if (_deviceObj.progMode())
|
if (_deviceObj.progMode())
|
||||||
_deviceObj.induvidualAddress(newaddress);
|
_deviceObj.individualAddress(newaddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BauSystemB::individualAddressSerialNumberWriteIndication(Priority priority, HopCountType hopType, const SecurityControl &secCtrl, uint16_t newIndividualAddress,
|
void BauSystemB::individualAddressSerialNumberWriteIndication(Priority priority, HopCountType hopType, const SecurityControl &secCtrl, uint16_t newIndividualAddress,
|
||||||
@ -450,7 +450,7 @@ void BauSystemB::individualAddressSerialNumberWriteIndication(Priority priority,
|
|||||||
// If the received serial number matches our serial number
|
// If the received serial number matches our serial number
|
||||||
// then store the received new individual address in the device object
|
// then store the received new individual address in the device object
|
||||||
if (!memcmp(knxSerialNumber, _deviceObj.propertyData(PID_SERIAL_NUMBER), 6))
|
if (!memcmp(knxSerialNumber, _deviceObj.propertyData(PID_SERIAL_NUMBER), 6))
|
||||||
_deviceObj.induvidualAddress(newIndividualAddress);
|
_deviceObj.individualAddress(newIndividualAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BauSystemB::individualAddressSerialNumberReadIndication(Priority priority, HopCountType hopType, const SecurityControl &secCtrl, uint8_t* knxSerialNumber)
|
void BauSystemB::individualAddressSerialNumberReadIndication(Priority priority, HopCountType hopType, const SecurityControl &secCtrl, uint8_t* knxSerialNumber)
|
||||||
|
|||||||
@ -219,12 +219,12 @@ void CemiFrame::frameType(FrameFormat type)
|
|||||||
|
|
||||||
Repetition CemiFrame::repetition() const
|
Repetition CemiFrame::repetition() const
|
||||||
{
|
{
|
||||||
return (Repetition)(_ctrl1[0] & RepititionAllowed);
|
return (Repetition)(_ctrl1[0] & RepetitionAllowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CemiFrame::repetition(Repetition rep)
|
void CemiFrame::repetition(Repetition rep)
|
||||||
{
|
{
|
||||||
_ctrl1[0] &= ~RepititionAllowed;
|
_ctrl1[0] &= ~RepetitionAllowed;
|
||||||
_ctrl1[0] |= rep;
|
_ctrl1[0] |= rep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@ CemiServer::CemiServer(BauSystemB& bau)
|
|||||||
{
|
{
|
||||||
// The cEMI server will hand out the device address + 1 to the cEMI client (e.g. ETS),
|
// The cEMI server will hand out the device address + 1 to the cEMI client (e.g. ETS),
|
||||||
// so that the device and the cEMI client/server connection(tunnel) can operate simultaneously.
|
// so that the device and the cEMI client/server connection(tunnel) can operate simultaneously.
|
||||||
_clientAddress = _bau.deviceObject().induvidualAddress() + 1;
|
_clientAddress = _bau.deviceObject().individualAddress() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CemiServer::dataLinkLayer(DataLinkLayer& layer)
|
void CemiServer::dataLinkLayer(DataLinkLayer& layer)
|
||||||
|
|||||||
@ -25,7 +25,7 @@ void DataLinkLayer::dataRequestFromTunnel(CemiFrame& frame)
|
|||||||
frame.messageCode(L_data_ind);
|
frame.messageCode(L_data_ind);
|
||||||
|
|
||||||
// Send to local stack
|
// Send to local stack
|
||||||
frameRecieved(frame);
|
frameReceived(frame);
|
||||||
|
|
||||||
// Send to KNX medium
|
// Send to KNX medium
|
||||||
sendFrame(frame);
|
sendFrame(frame);
|
||||||
@ -82,7 +82,7 @@ void DataLinkLayer::dataConReceived(CemiFrame& frame, bool success)
|
|||||||
frame.messageCode(backupMsgCode);
|
frame.messageCode(backupMsgCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataLinkLayer::frameRecieved(CemiFrame& frame)
|
void DataLinkLayer::frameReceived(CemiFrame& frame)
|
||||||
{
|
{
|
||||||
AckType ack = frame.ack();
|
AckType ack = frame.ack();
|
||||||
AddressType addrType = frame.addressType();
|
AddressType addrType = frame.addressType();
|
||||||
@ -91,7 +91,7 @@ void DataLinkLayer::frameRecieved(CemiFrame& frame)
|
|||||||
FrameFormat type = frame.frameType();
|
FrameFormat type = frame.frameType();
|
||||||
Priority priority = frame.priority();
|
Priority priority = frame.priority();
|
||||||
NPDU& npdu = frame.npdu();
|
NPDU& npdu = frame.npdu();
|
||||||
uint16_t ownAddr = _deviceObject.induvidualAddress();
|
uint16_t ownAddr = _deviceObject.individualAddress();
|
||||||
SystemBroadcast systemBroadcast = frame.systemBroadcast();
|
SystemBroadcast systemBroadcast = frame.systemBroadcast();
|
||||||
|
|
||||||
#ifdef USE_CEMI_SERVER
|
#ifdef USE_CEMI_SERVER
|
||||||
@ -103,7 +103,7 @@ void DataLinkLayer::frameRecieved(CemiFrame& frame)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (source == ownAddr)
|
if (source == ownAddr)
|
||||||
_deviceObject.induvidualAddressDuplication(true);
|
_deviceObject.individualAddressDuplication(true);
|
||||||
|
|
||||||
if (addrType == GroupAddress && destination == 0)
|
if (addrType == GroupAddress && destination == 0)
|
||||||
{
|
{
|
||||||
@ -126,7 +126,7 @@ bool DataLinkLayer::sendTelegram(NPDU & npdu, AckType ack, uint16_t destinationA
|
|||||||
frame.sourceAddress(sourceAddr);
|
frame.sourceAddress(sourceAddr);
|
||||||
frame.addressType(addrType);
|
frame.addressType(addrType);
|
||||||
frame.priority(priority);
|
frame.priority(priority);
|
||||||
frame.repetition(RepititionAllowed);
|
frame.repetition(RepetitionAllowed);
|
||||||
frame.systemBroadcast(systemBroadcast);
|
frame.systemBroadcast(systemBroadcast);
|
||||||
|
|
||||||
if (npdu.octetCount() <= 15)
|
if (npdu.octetCount() <= 15)
|
||||||
|
|||||||
@ -32,7 +32,7 @@ class DataLinkLayer
|
|||||||
virtual DptMedium mediumType() const = 0;
|
virtual DptMedium mediumType() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void frameRecieved(CemiFrame& frame);
|
void frameReceived(CemiFrame& frame);
|
||||||
void dataConReceived(CemiFrame& frame, bool success);
|
void dataConReceived(CemiFrame& frame, bool success);
|
||||||
bool sendTelegram(NPDU& npdu, AckType ack, uint16_t destinationAddr, AddressType addrType, uint16_t sourceAddr, FrameFormat format, Priority priority, SystemBroadcast systemBroadcast);
|
bool sendTelegram(NPDU& npdu, AckType ack, uint16_t destinationAddr, AddressType addrType, uint16_t sourceAddr, FrameFormat format, Priority priority, SystemBroadcast systemBroadcast);
|
||||||
virtual bool sendFrame(CemiFrame& frame) = 0;
|
virtual bool sendFrame(CemiFrame& frame) = 0;
|
||||||
|
|||||||
@ -113,12 +113,12 @@ uint16_t DeviceObject::saveSize()
|
|||||||
return 2 + InterfaceObject::saveSize();
|
return 2 + InterfaceObject::saveSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t DeviceObject::induvidualAddress()
|
uint16_t DeviceObject::individualAddress()
|
||||||
{
|
{
|
||||||
return _ownAddress;
|
return _ownAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceObject::induvidualAddress(uint16_t value)
|
void DeviceObject::individualAddress(uint16_t value)
|
||||||
{
|
{
|
||||||
_ownAddress = value;
|
_ownAddress = value;
|
||||||
}
|
}
|
||||||
@ -129,7 +129,7 @@ void DeviceObject::induvidualAddress(uint16_t value)
|
|||||||
#define SAFE_STATE 0x8
|
#define SAFE_STATE 0x8
|
||||||
|
|
||||||
|
|
||||||
void DeviceObject::induvidualAddressDuplication(bool value)
|
void DeviceObject::individualAddressDuplication(bool value)
|
||||||
{
|
{
|
||||||
Property* prop = property(PID_DEVICE_CONTROL);
|
Property* prop = property(PID_DEVICE_CONTROL);
|
||||||
uint8_t data;
|
uint8_t data;
|
||||||
|
|||||||
@ -12,10 +12,10 @@ public:
|
|||||||
const uint8_t* restore(const uint8_t* buffer) override;
|
const uint8_t* restore(const uint8_t* buffer) override;
|
||||||
uint16_t saveSize() override;
|
uint16_t saveSize() override;
|
||||||
|
|
||||||
uint16_t induvidualAddress();
|
uint16_t individualAddress();
|
||||||
void induvidualAddress(uint16_t value);
|
void individualAddress(uint16_t value);
|
||||||
|
|
||||||
void induvidualAddressDuplication(bool value);
|
void individualAddressDuplication(bool value);
|
||||||
bool verifyMode();
|
bool verifyMode();
|
||||||
void verifyMode(bool value);
|
void verifyMode(bool value);
|
||||||
bool progMode();
|
bool progMode();
|
||||||
|
|||||||
@ -58,7 +58,7 @@ void IpDataLinkLayer::loop()
|
|||||||
case RoutingIndication:
|
case RoutingIndication:
|
||||||
{
|
{
|
||||||
KnxIpRoutingIndication routingIndication(buffer, len);
|
KnxIpRoutingIndication routingIndication(buffer, len);
|
||||||
frameRecieved(routingIndication.frame());
|
frameReceived(routingIndication.frame());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SearchRequest:
|
case SearchRequest:
|
||||||
@ -79,7 +79,7 @@ void IpDataLinkLayer::loop()
|
|||||||
void IpDataLinkLayer::enabled(bool value)
|
void IpDataLinkLayer::enabled(bool value)
|
||||||
{
|
{
|
||||||
// _print("own address: ");
|
// _print("own address: ");
|
||||||
// _println(_deviceObject.induvidualAddress());
|
// _println(_deviceObject.individualAddress());
|
||||||
if (value && !_enabled)
|
if (value && !_enabled)
|
||||||
{
|
{
|
||||||
_platform.setupMultiCast(_ipParameters.propertyValue<uint32_t>(PID_ROUTING_MULTICAST_ADDRESS), KNXIP_MULTICAST_PORT);
|
_platform.setupMultiCast(_ipParameters.propertyValue<uint32_t>(PID_ROUTING_MULTICAST_ADDRESS), KNXIP_MULTICAST_PORT);
|
||||||
|
|||||||
@ -26,12 +26,12 @@ IpParameterObject::IpParameterObject(DeviceObject& deviceObject, Platform& platf
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
// TODO: get property of deviceobject and use it
|
// TODO: get property of deviceobject and use it
|
||||||
pushWord(io->_deviceObject.induvidualAddress(), data);
|
pushWord(io->_deviceObject.individualAddress(), data);
|
||||||
return 1;
|
return 1;
|
||||||
},
|
},
|
||||||
[](IpParameterObject* io, uint16_t start, uint8_t count, const uint8_t* data) -> uint8_t
|
[](IpParameterObject* io, uint16_t start, uint8_t count, const uint8_t* data) -> uint8_t
|
||||||
{
|
{
|
||||||
io->_deviceObject.induvidualAddress(getWord(data));
|
io->_deviceObject.individualAddress(getWord(data));
|
||||||
return 1;
|
return 1;
|
||||||
}),
|
}),
|
||||||
new DataProperty(PID_IP_ASSIGNMENT_METHOD, true, PDT_UNSIGNED_CHAR, 1, ReadLv3 | WriteLv3),
|
new DataProperty(PID_IP_ASSIGNMENT_METHOD, true, PDT_UNSIGNED_CHAR, 1, ReadLv3 | WriteLv3),
|
||||||
|
|||||||
@ -22,7 +22,7 @@ enum AckType
|
|||||||
|
|
||||||
enum AddressType
|
enum AddressType
|
||||||
{
|
{
|
||||||
InduvidualAddress = 0,
|
IndividualAddress = 0,
|
||||||
GroupAddress = 0x80,
|
GroupAddress = 0x80,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ enum Repetition
|
|||||||
{
|
{
|
||||||
NoRepitiion = 0,
|
NoRepitiion = 0,
|
||||||
WasRepeated = 0,
|
WasRepeated = 0,
|
||||||
RepititionAllowed = 0x20,
|
RepetitionAllowed = 0x20,
|
||||||
WasNotRepeated = 0x20,
|
WasNotRepeated = 0x20,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ NetworkLayerCoupler::NetworkLayerCoupler(DeviceObject &deviceObj,
|
|||||||
NetworkLayer(deviceObj, layer),
|
NetworkLayer(deviceObj, layer),
|
||||||
_netLayerEntities { {*this, kPrimaryIfIndex}, {*this, kSecondaryIfIndex} }
|
_netLayerEntities { {*this, kPrimaryIfIndex}, {*this, kSecondaryIfIndex} }
|
||||||
{
|
{
|
||||||
_currentAddress = deviceObj.induvidualAddress();
|
_currentAddress = deviceObj.individualAddress();
|
||||||
evaluateCouplerType();
|
evaluateCouplerType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,11 +43,11 @@ void NetworkLayerCoupler::rtObjSecondary(RouterObject& rtObjSecondary)
|
|||||||
void NetworkLayerCoupler::evaluateCouplerType()
|
void NetworkLayerCoupler::evaluateCouplerType()
|
||||||
{
|
{
|
||||||
// Check coupler mode
|
// Check coupler mode
|
||||||
if ((_deviceObj.induvidualAddress() & 0x00FF) == 0x00)
|
if ((_deviceObj.individualAddress() & 0x00FF) == 0x00)
|
||||||
{
|
{
|
||||||
// Device is a router
|
// Device is a router
|
||||||
// Check if line coupler or backbone coupler
|
// Check if line coupler or backbone coupler
|
||||||
if ((_deviceObj.induvidualAddress() & 0x0F00) == 0x0)
|
if ((_deviceObj.individualAddress() & 0x0F00) == 0x0)
|
||||||
{
|
{
|
||||||
// Device is a backbone coupler -> individual address: x.0.0
|
// Device is a backbone coupler -> individual address: x.0.0
|
||||||
_couplerType = BackboneCoupler;
|
_couplerType = BackboneCoupler;
|
||||||
@ -99,7 +99,7 @@ bool NetworkLayerCoupler::isRoutedIndividualAddress(uint16_t individualAddress)
|
|||||||
// too. A typical use case is the protection of a Subnetwork that is located outside a building)
|
// too. A typical use case is the protection of a Subnetwork that is located outside a building)
|
||||||
|
|
||||||
// Also ACK for our own individual address
|
// Also ACK for our own individual address
|
||||||
if (individualAddress == _deviceObj.induvidualAddress())
|
if (individualAddress == _deviceObj.individualAddress())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// use 2 for now
|
// use 2 for now
|
||||||
@ -158,7 +158,7 @@ void NetworkLayerCoupler::routeDataIndividual(AckType ack, uint16_t destination,
|
|||||||
{
|
{
|
||||||
// TODO: improve: we have to be notified about anything that might affect routing decision
|
// TODO: improve: we have to be notified about anything that might affect routing decision
|
||||||
// Ugly: we could ALWAYS evaluate coupler type for every received frame
|
// Ugly: we could ALWAYS evaluate coupler type for every received frame
|
||||||
if (_currentAddress != _deviceObj.induvidualAddress())
|
if (_currentAddress != _deviceObj.individualAddress())
|
||||||
{
|
{
|
||||||
evaluateCouplerType();
|
evaluateCouplerType();
|
||||||
}
|
}
|
||||||
@ -172,8 +172,8 @@ void NetworkLayerCoupler::routeDataIndividual(AckType ack, uint16_t destination,
|
|||||||
* Z high nibble of high order octet of the Destination Address, i.e. Area Address
|
* Z high nibble of high order octet of the Destination Address, i.e. Area Address
|
||||||
* ZS high order octet of the Destination Address, i.e. hierarchy information part: Area Address + Line Address
|
* ZS high order octet of the Destination Address, i.e. hierarchy information part: Area Address + Line Address
|
||||||
*/
|
*/
|
||||||
uint16_t ownSNA = _deviceObj.induvidualAddress() & 0xFF00; // Own subnetwork address (area + line)
|
uint16_t ownSNA = _deviceObj.individualAddress() & 0xFF00; // Own subnetwork address (area + line)
|
||||||
uint16_t ownAA = _deviceObj.induvidualAddress() & 0xF000; // Own area address
|
uint16_t ownAA = _deviceObj.individualAddress() & 0xF000; // Own area address
|
||||||
uint16_t ZS = destination & 0xFF00; // destination subnetwork address (area + line)
|
uint16_t ZS = destination & 0xFF00; // destination subnetwork address (area + line)
|
||||||
uint16_t Z = destination & 0xF000; // destination area address
|
uint16_t Z = destination & 0xF000; // destination area address
|
||||||
uint16_t D = destination & 0x00FF; // destination device address (without subnetwork part)
|
uint16_t D = destination & 0x00FF; // destination device address (without subnetwork part)
|
||||||
@ -198,7 +198,7 @@ void NetworkLayerCoupler::routeDataIndividual(AckType ack, uint16_t destination,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // ROUTE_XXX
|
{ // ROUTE_XXX
|
||||||
sendMsgHopCount(ack, AddressType::InduvidualAddress, destination, npdu, priority, Broadcast, srcIfIndex, source);
|
sendMsgHopCount(ack, AddressType::IndividualAddress, destination, npdu, priority, Broadcast, srcIfIndex, source);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -209,7 +209,7 @@ void NetworkLayerCoupler::routeDataIndividual(AckType ack, uint16_t destination,
|
|||||||
if (ZS != ownSNA)
|
if (ZS != ownSNA)
|
||||||
{
|
{
|
||||||
// ROUTE_XXX
|
// ROUTE_XXX
|
||||||
sendMsgHopCount(ack, AddressType::InduvidualAddress, destination, npdu, priority, Broadcast, srcIfIndex, source);
|
sendMsgHopCount(ack, AddressType::IndividualAddress, destination, npdu, priority, Broadcast, srcIfIndex, source);
|
||||||
}
|
}
|
||||||
else if (D == 0)
|
else if (D == 0)
|
||||||
{
|
{
|
||||||
@ -229,7 +229,7 @@ void NetworkLayerCoupler::routeDataIndividual(AckType ack, uint16_t destination,
|
|||||||
{
|
{
|
||||||
// if destination is not within our subnet then send via primary interface, else via secondary interface
|
// if destination is not within our subnet then send via primary interface, else via secondary interface
|
||||||
uint8_t destIfidx = (ZS != ownSNA) ? kPrimaryIfIndex : kSecondaryIfIndex;
|
uint8_t destIfidx = (ZS != ownSNA) ? kPrimaryIfIndex : kSecondaryIfIndex;
|
||||||
_netLayerEntities[destIfidx].sendDataRequest(npdu, ack, destination, source, priority, AddressType::InduvidualAddress, Broadcast);
|
_netLayerEntities[destIfidx].sendDataRequest(npdu, ack, destination, source, priority, AddressType::IndividualAddress, Broadcast);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,7 +254,7 @@ void NetworkLayerCoupler::routeDataIndividual(AckType ack, uint16_t destination,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// ROUTE_XXX
|
// ROUTE_XXX
|
||||||
sendMsgHopCount(ack, AddressType::InduvidualAddress, destination, npdu, priority, Broadcast, srcIfIndex, source);
|
sendMsgHopCount(ack, AddressType::IndividualAddress, destination, npdu, priority, Broadcast, srcIfIndex, source);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -265,7 +265,7 @@ void NetworkLayerCoupler::routeDataIndividual(AckType ack, uint16_t destination,
|
|||||||
if (Z != ownAA)
|
if (Z != ownAA)
|
||||||
{
|
{
|
||||||
// ROUTE_XXX
|
// ROUTE_XXX
|
||||||
sendMsgHopCount(ack, AddressType::InduvidualAddress, destination, npdu, priority, Broadcast, srcIfIndex, source);
|
sendMsgHopCount(ack, AddressType::IndividualAddress, destination, npdu, priority, Broadcast, srcIfIndex, source);
|
||||||
}
|
}
|
||||||
else if(SD == 0)
|
else if(SD == 0)
|
||||||
{
|
{
|
||||||
@ -285,7 +285,7 @@ void NetworkLayerCoupler::routeDataIndividual(AckType ack, uint16_t destination,
|
|||||||
{
|
{
|
||||||
// if destination is not within our area then send via primary interface, else via secondary interface
|
// if destination is not within our area then send via primary interface, else via secondary interface
|
||||||
uint8_t destIfidx = (Z != ownAA) ? kPrimaryIfIndex : kSecondaryIfIndex;
|
uint8_t destIfidx = (Z != ownAA) ? kPrimaryIfIndex : kSecondaryIfIndex;
|
||||||
_netLayerEntities[destIfidx].sendDataRequest(npdu, ack, destination, source, priority, AddressType::InduvidualAddress, Broadcast);
|
_netLayerEntities[destIfidx].sendDataRequest(npdu, ack, destination, source, priority, AddressType::IndividualAddress, Broadcast);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -294,7 +294,7 @@ void NetworkLayerCoupler::routeDataIndividual(AckType ack, uint16_t destination,
|
|||||||
void NetworkLayerCoupler::dataIndication(AckType ack, AddressType addrType, uint16_t destination, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source, uint8_t srcIfIdx)
|
void NetworkLayerCoupler::dataIndication(AckType ack, AddressType addrType, uint16_t destination, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source, uint8_t srcIfIdx)
|
||||||
{
|
{
|
||||||
// routing for individual addresses
|
// routing for individual addresses
|
||||||
if (addrType == InduvidualAddress)
|
if (addrType == IndividualAddress)
|
||||||
{
|
{
|
||||||
routeDataIndividual(ack, destination, npdu, priority, source, srcIfIdx);
|
routeDataIndividual(ack, destination, npdu, priority, source, srcIfIdx);
|
||||||
return;
|
return;
|
||||||
@ -324,9 +324,9 @@ void NetworkLayerCoupler::dataConfirm(AckType ack, AddressType addrType, uint16_
|
|||||||
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
|
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
|
||||||
|
|
||||||
// Check if received frame is an echo from our sent frame, we are a normal device in this case
|
// Check if received frame is an echo from our sent frame, we are a normal device in this case
|
||||||
if (source == _deviceObj.induvidualAddress())
|
if (source == _deviceObj.individualAddress())
|
||||||
{
|
{
|
||||||
if (addrType == InduvidualAddress)
|
if (addrType == IndividualAddress)
|
||||||
{
|
{
|
||||||
_transportLayer.dataIndividualConfirm(ack, destination, hopType, priority, npdu.tpdu(), status);
|
_transportLayer.dataIndividualConfirm(ack, destination, hopType, priority, npdu.tpdu(), status);
|
||||||
return;
|
return;
|
||||||
@ -365,7 +365,7 @@ void NetworkLayerCoupler::broadcastConfirm(AckType ack, FrameFormat format, Prio
|
|||||||
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
|
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
|
||||||
|
|
||||||
// Check if received frame is an echo from our sent frame, we are a normal device in this case
|
// Check if received frame is an echo from our sent frame, we are a normal device in this case
|
||||||
if (source == _deviceObj.induvidualAddress())
|
if (source == _deviceObj.individualAddress())
|
||||||
{
|
{
|
||||||
_transportLayer.dataBroadcastConfirm(ack, hopType, priority, npdu.tpdu(), status);
|
_transportLayer.dataBroadcastConfirm(ack, hopType, priority, npdu.tpdu(), status);
|
||||||
}
|
}
|
||||||
@ -386,7 +386,7 @@ void NetworkLayerCoupler::systemBroadcastIndication(AckType ack, FrameFormat for
|
|||||||
void NetworkLayerCoupler::systemBroadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status, uint8_t srcIfIdx)
|
void NetworkLayerCoupler::systemBroadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status, uint8_t srcIfIdx)
|
||||||
{
|
{
|
||||||
// Check if received frame is an echo from our sent frame, we are a normal device in this case
|
// Check if received frame is an echo from our sent frame, we are a normal device in this case
|
||||||
if (source == _deviceObj.induvidualAddress())
|
if (source == _deviceObj.individualAddress())
|
||||||
{
|
{
|
||||||
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
|
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
|
||||||
_transportLayer.dataSystemBroadcastConfirm(ack, hopType, npdu.tpdu(), priority, status);
|
_transportLayer.dataSystemBroadcastConfirm(ack, hopType, npdu.tpdu(), priority, status);
|
||||||
@ -408,7 +408,7 @@ void NetworkLayerCoupler::dataIndividualRequest(AckType ack, uint16_t destinatio
|
|||||||
// print.print("-> NL ");
|
// print.print("-> NL ");
|
||||||
// tpdu.apdu().printPDU();
|
// tpdu.apdu().printPDU();
|
||||||
//}
|
//}
|
||||||
routeDataIndividual(ack, destination, npdu, priority, _deviceObj.induvidualAddress(), kLocalIfIndex);
|
routeDataIndividual(ack, destination, npdu, priority, _deviceObj.individualAddress(), kLocalIfIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkLayerCoupler::dataGroupRequest(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu)
|
void NetworkLayerCoupler::dataGroupRequest(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu)
|
||||||
@ -423,10 +423,10 @@ void NetworkLayerCoupler::dataGroupRequest(AckType ack, uint16_t destination, Ho
|
|||||||
// If the group address is in the filter table, then we route it to the primary side too
|
// If the group address is in the filter table, then we route it to the primary side too
|
||||||
if (isGroupAddressInFilterTable(destination))
|
if (isGroupAddressInFilterTable(destination))
|
||||||
{
|
{
|
||||||
_netLayerEntities[kPrimaryIfIndex].sendDataRequest(npdu, ack, destination, _deviceObj.induvidualAddress(), priority, GroupAddress, Broadcast);
|
_netLayerEntities[kPrimaryIfIndex].sendDataRequest(npdu, ack, destination, _deviceObj.individualAddress(), priority, GroupAddress, Broadcast);
|
||||||
}
|
}
|
||||||
// We send it to our sub line in any case
|
// We send it to our sub line in any case
|
||||||
_netLayerEntities[kSecondaryIfIndex].sendDataRequest(npdu, ack, destination, _deviceObj.induvidualAddress(), priority, GroupAddress, Broadcast);
|
_netLayerEntities[kSecondaryIfIndex].sendDataRequest(npdu, ack, destination, _deviceObj.individualAddress(), priority, GroupAddress, Broadcast);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkLayerCoupler::dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu)
|
void NetworkLayerCoupler::dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu)
|
||||||
@ -438,8 +438,8 @@ void NetworkLayerCoupler::dataBroadcastRequest(AckType ack, HopCountType hopType
|
|||||||
else
|
else
|
||||||
npdu.hopCount(hopCount());
|
npdu.hopCount(hopCount());
|
||||||
|
|
||||||
_netLayerEntities[kPrimaryIfIndex].sendDataRequest(npdu, ack, 0, _deviceObj.induvidualAddress(), priority, GroupAddress, Broadcast);
|
_netLayerEntities[kPrimaryIfIndex].sendDataRequest(npdu, ack, 0, _deviceObj.individualAddress(), priority, GroupAddress, Broadcast);
|
||||||
_netLayerEntities[kSecondaryIfIndex].sendDataRequest(npdu, ack, 0, _deviceObj.induvidualAddress(), priority, GroupAddress, Broadcast);
|
_netLayerEntities[kSecondaryIfIndex].sendDataRequest(npdu, ack, 0, _deviceObj.individualAddress(), priority, GroupAddress, Broadcast);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkLayerCoupler::dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu)
|
void NetworkLayerCoupler::dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu)
|
||||||
@ -451,6 +451,6 @@ void NetworkLayerCoupler::dataSystemBroadcastRequest(AckType ack, HopCountType h
|
|||||||
else
|
else
|
||||||
npdu.hopCount(hopCount());
|
npdu.hopCount(hopCount());
|
||||||
|
|
||||||
_netLayerEntities[kPrimaryIfIndex].sendDataRequest(npdu, ack, 0, _deviceObj.induvidualAddress(), priority, GroupAddress, SysBroadcast);
|
_netLayerEntities[kPrimaryIfIndex].sendDataRequest(npdu, ack, 0, _deviceObj.individualAddress(), priority, GroupAddress, SysBroadcast);
|
||||||
_netLayerEntities[kSecondaryIfIndex].sendDataRequest(npdu, ack, 0, _deviceObj.induvidualAddress(), priority, GroupAddress, SysBroadcast);
|
_netLayerEntities[kSecondaryIfIndex].sendDataRequest(npdu, ack, 0, _deviceObj.individualAddress(), priority, GroupAddress, SysBroadcast);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@ void NetworkLayerDevice::dataIndividualRequest(AckType ack, uint16_t destination
|
|||||||
// print.print("-> NL ");
|
// print.print("-> NL ");
|
||||||
// tpdu.apdu().printPDU();
|
// tpdu.apdu().printPDU();
|
||||||
//}
|
//}
|
||||||
_netLayerEntities[kInterfaceIndex].sendDataRequest(npdu, ack, destination, _deviceObj.induvidualAddress(), priority, InduvidualAddress, Broadcast);
|
_netLayerEntities[kInterfaceIndex].sendDataRequest(npdu, ack, destination, _deviceObj.individualAddress(), priority, IndividualAddress, Broadcast);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkLayerDevice::dataGroupRequest(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu)
|
void NetworkLayerDevice::dataGroupRequest(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu)
|
||||||
@ -41,7 +41,7 @@ void NetworkLayerDevice::dataGroupRequest(AckType ack, uint16_t destination, Hop
|
|||||||
else
|
else
|
||||||
npdu.hopCount(hopCount());
|
npdu.hopCount(hopCount());
|
||||||
|
|
||||||
_netLayerEntities[kInterfaceIndex].sendDataRequest(npdu, ack, destination, _deviceObj.induvidualAddress(), priority, GroupAddress, Broadcast);
|
_netLayerEntities[kInterfaceIndex].sendDataRequest(npdu, ack, destination, _deviceObj.individualAddress(), priority, GroupAddress, Broadcast);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkLayerDevice::dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu)
|
void NetworkLayerDevice::dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu)
|
||||||
@ -53,7 +53,7 @@ void NetworkLayerDevice::dataBroadcastRequest(AckType ack, HopCountType hopType,
|
|||||||
else
|
else
|
||||||
npdu.hopCount(hopCount());
|
npdu.hopCount(hopCount());
|
||||||
|
|
||||||
_netLayerEntities[kInterfaceIndex].sendDataRequest(npdu, ack, 0, _deviceObj.induvidualAddress(), priority, GroupAddress, Broadcast);
|
_netLayerEntities[kInterfaceIndex].sendDataRequest(npdu, ack, 0, _deviceObj.individualAddress(), priority, GroupAddress, Broadcast);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkLayerDevice::dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu)
|
void NetworkLayerDevice::dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu)
|
||||||
@ -69,16 +69,16 @@ void NetworkLayerDevice::dataSystemBroadcastRequest(AckType ack, HopCountType ho
|
|||||||
else
|
else
|
||||||
npdu.hopCount(hopCount());
|
npdu.hopCount(hopCount());
|
||||||
|
|
||||||
_netLayerEntities[kInterfaceIndex].sendDataRequest(npdu, ack, 0, _deviceObj.induvidualAddress(), priority, GroupAddress, broadcastType);
|
_netLayerEntities[kInterfaceIndex].sendDataRequest(npdu, ack, 0, _deviceObj.individualAddress(), priority, GroupAddress, broadcastType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkLayerDevice::dataIndication(AckType ack, AddressType addrType, uint16_t destination, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source, uint8_t srcIfIdx)
|
void NetworkLayerDevice::dataIndication(AckType ack, AddressType addrType, uint16_t destination, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source, uint8_t srcIfIdx)
|
||||||
{
|
{
|
||||||
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
|
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
|
||||||
|
|
||||||
if (addrType == InduvidualAddress)
|
if (addrType == IndividualAddress)
|
||||||
{
|
{
|
||||||
if (destination != _deviceObj.induvidualAddress())
|
if (destination != _deviceObj.individualAddress())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_transportLayer.dataIndividualIndication(destination, hopType, priority, source, npdu.tpdu());
|
_transportLayer.dataIndividualIndication(destination, hopType, priority, source, npdu.tpdu());
|
||||||
@ -96,7 +96,7 @@ void NetworkLayerDevice::dataIndication(AckType ack, AddressType addrType, uint1
|
|||||||
void NetworkLayerDevice::dataConfirm(AckType ack, AddressType addressType, uint16_t destination, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status, uint8_t srcIfIdx)
|
void NetworkLayerDevice::dataConfirm(AckType ack, AddressType addressType, uint16_t destination, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status, uint8_t srcIfIdx)
|
||||||
{
|
{
|
||||||
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
|
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
|
||||||
if (addressType == InduvidualAddress)
|
if (addressType == IndividualAddress)
|
||||||
{
|
{
|
||||||
_transportLayer.dataIndividualConfirm(ack, destination, hopType, priority, npdu.tpdu(), status);
|
_transportLayer.dataIndividualConfirm(ack, destination, hopType, priority, npdu.tpdu(), status);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -187,7 +187,7 @@ void RfDataLinkLayer::frameBytesReceived(uint8_t* rfPacketBuf, uint16_t length)
|
|||||||
// Get data link layer frame number (LFN field) from L/NPCI.LFN (bit 3..1)
|
// Get data link layer frame number (LFN field) from L/NPCI.LFN (bit 3..1)
|
||||||
uint8_t lfn = (_buffer[8] & 0x0E) >> 1;
|
uint8_t lfn = (_buffer[8] & 0x0E) >> 1;
|
||||||
// Get address type from L/NPCI.LFN (bit 7)
|
// Get address type from L/NPCI.LFN (bit 7)
|
||||||
AddressType addressType = (_buffer[8] & 0x80) ? GroupAddress:InduvidualAddress;
|
AddressType addressType = (_buffer[8] & 0x80) ? GroupAddress:IndividualAddress;
|
||||||
// Get routing counter from L/NPCI.LFN (bit 6..4) and map to hop count in Ctrl2.b6-4
|
// Get routing counter from L/NPCI.LFN (bit 6..4) and map to hop count in Ctrl2.b6-4
|
||||||
uint8_t hopCount = (_buffer[8] & 0x70) >> 4;
|
uint8_t hopCount = (_buffer[8] & 0x70) >> 4;
|
||||||
// Get AddrExtensionType from L/NPCI.LFN (bit 7) and map to system broadcast flag in Ctrl1.b4
|
// Get AddrExtensionType from L/NPCI.LFN (bit 7) and map to system broadcast flag in Ctrl1.b4
|
||||||
@ -233,7 +233,7 @@ void RfDataLinkLayer::frameBytesReceived(uint8_t* rfPacketBuf, uint16_t length)
|
|||||||
print(" data: ");
|
print(" data: ");
|
||||||
printHex(" data: ", _buffer, newLength);
|
printHex(" data: ", _buffer, newLength);
|
||||||
*/
|
*/
|
||||||
frameRecieved(frame);
|
frameReceived(frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -246,7 +246,7 @@ void RfDataLinkLayer::enabled(bool value)
|
|||||||
{
|
{
|
||||||
_enabled = true;
|
_enabled = true;
|
||||||
print("ownaddr ");
|
print("ownaddr ");
|
||||||
println(_deviceObject.induvidualAddress(), HEX);
|
println(_deviceObject.individualAddress(), HEX);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -307,7 +307,7 @@ void SecureApplicationLayer::dataGroupRequest(AckType ack, HopCountType hopType,
|
|||||||
|
|
||||||
if (secCtrl.dataSecurity != DataSecurity::none)
|
if (secCtrl.dataSecurity != DataSecurity::none)
|
||||||
{
|
{
|
||||||
apdu.frame().sourceAddress(_deviceObj.induvidualAddress());
|
apdu.frame().sourceAddress(_deviceObj.individualAddress());
|
||||||
apdu.frame().destinationAddress(_addrTab->getGroupAddress(tsap));
|
apdu.frame().destinationAddress(_addrTab->getGroupAddress(tsap));
|
||||||
apdu.frame().addressType(GroupAddress);
|
apdu.frame().addressType(GroupAddress);
|
||||||
|
|
||||||
@ -330,7 +330,7 @@ void SecureApplicationLayer::dataBroadcastRequest(AckType ack, HopCountType hopT
|
|||||||
|
|
||||||
if (secCtrl.dataSecurity != DataSecurity::none)
|
if (secCtrl.dataSecurity != DataSecurity::none)
|
||||||
{
|
{
|
||||||
apdu.frame().sourceAddress(_deviceObj.induvidualAddress());
|
apdu.frame().sourceAddress(_deviceObj.individualAddress());
|
||||||
apdu.frame().destinationAddress(0x0000);
|
apdu.frame().destinationAddress(0x0000);
|
||||||
apdu.frame().addressType(GroupAddress);
|
apdu.frame().addressType(GroupAddress);
|
||||||
apdu.frame().systemBroadcast(Broadcast);
|
apdu.frame().systemBroadcast(Broadcast);
|
||||||
@ -354,7 +354,7 @@ void SecureApplicationLayer::dataSystemBroadcastRequest(AckType ack, HopCountTyp
|
|||||||
|
|
||||||
if (secCtrl.dataSecurity != DataSecurity::none)
|
if (secCtrl.dataSecurity != DataSecurity::none)
|
||||||
{
|
{
|
||||||
apdu.frame().sourceAddress(_deviceObj.induvidualAddress());
|
apdu.frame().sourceAddress(_deviceObj.individualAddress());
|
||||||
apdu.frame().destinationAddress(0x0000);
|
apdu.frame().destinationAddress(0x0000);
|
||||||
apdu.frame().addressType(GroupAddress);
|
apdu.frame().addressType(GroupAddress);
|
||||||
apdu.frame().systemBroadcast(SysBroadcast);
|
apdu.frame().systemBroadcast(SysBroadcast);
|
||||||
@ -378,9 +378,9 @@ void SecureApplicationLayer::dataIndividualRequest(AckType ack, HopCountType hop
|
|||||||
|
|
||||||
if (secCtrl.dataSecurity != DataSecurity::none)
|
if (secCtrl.dataSecurity != DataSecurity::none)
|
||||||
{
|
{
|
||||||
apdu.frame().sourceAddress(_deviceObj.induvidualAddress());
|
apdu.frame().sourceAddress(_deviceObj.individualAddress());
|
||||||
apdu.frame().destinationAddress(destination);
|
apdu.frame().destinationAddress(destination);
|
||||||
apdu.frame().addressType(InduvidualAddress);
|
apdu.frame().addressType(IndividualAddress);
|
||||||
|
|
||||||
uint16_t secureApduLength = apdu.length() + 3 + 6 + 4; // 3(TPCI,APCI,SCF) + sizeof(seqNum) + apdu.length() + 4
|
uint16_t secureApduLength = apdu.length() + 3 + 6 + 4; // 3(TPCI,APCI,SCF) + sizeof(seqNum) + apdu.length() + 4
|
||||||
CemiFrame secureFrame(secureApduLength);
|
CemiFrame secureFrame(secureApduLength);
|
||||||
@ -401,9 +401,9 @@ void SecureApplicationLayer::dataConnectedRequest(uint16_t tsap, Priority priori
|
|||||||
|
|
||||||
if (secCtrl.dataSecurity != DataSecurity::none)
|
if (secCtrl.dataSecurity != DataSecurity::none)
|
||||||
{
|
{
|
||||||
apdu.frame().sourceAddress(_deviceObj.induvidualAddress());
|
apdu.frame().sourceAddress(_deviceObj.individualAddress());
|
||||||
apdu.frame().destinationAddress(_transportLayer->getConnectionAddress());
|
apdu.frame().destinationAddress(_transportLayer->getConnectionAddress());
|
||||||
apdu.frame().addressType(InduvidualAddress);
|
apdu.frame().addressType(IndividualAddress);
|
||||||
|
|
||||||
uint16_t secureApduLength = apdu.length() + 3 + 6 + 4; // 3(TPCI,APCI,SCF) + sizeof(seqNum) + apdu.length() + 4
|
uint16_t secureApduLength = apdu.length() + 3 + 6 + 4; // 3(TPCI,APCI,SCF) + sizeof(seqNum) + apdu.length() + 4
|
||||||
CemiFrame secureFrame(secureApduLength);
|
CemiFrame secureFrame(secureApduLength);
|
||||||
@ -568,7 +568,7 @@ uint64_t SecureApplicationLayer::lastValidSequenceNumber(bool toolAccess, uint16
|
|||||||
if (toolAccess)
|
if (toolAccess)
|
||||||
{
|
{
|
||||||
// TODO: check if we really have to support multiple tools at the same time
|
// TODO: check if we really have to support multiple tools at the same time
|
||||||
if (srcAddr == _deviceObj.induvidualAddress())
|
if (srcAddr == _deviceObj.individualAddress())
|
||||||
return _sequenceNumberToolAccess;
|
return _sequenceNumberToolAccess;
|
||||||
return _lastValidSequenceNumberTool;
|
return _lastValidSequenceNumberTool;
|
||||||
}
|
}
|
||||||
@ -621,7 +621,7 @@ void SecureApplicationLayer::sendSyncRequest(uint16_t dstAddr, bool dstAddrIsGro
|
|||||||
print("sendSyncRequest: TPCI: ");
|
print("sendSyncRequest: TPCI: ");
|
||||||
println(tpci, HEX);
|
println(tpci, HEX);
|
||||||
|
|
||||||
if(secure(request.data() + APDU_LPDU_DIFF, kSecureSyncRequest, _deviceObj.induvidualAddress(), dstAddr, dstAddrIsGroupAddr, tpci, asdu, sizeof(asdu), secCtrl, systemBcast))
|
if(secure(request.data() + APDU_LPDU_DIFF, kSecureSyncRequest, _deviceObj.individualAddress(), dstAddr, dstAddrIsGroupAddr, tpci, asdu, sizeof(asdu), secCtrl, systemBcast))
|
||||||
{
|
{
|
||||||
println("SyncRequest: ");
|
println("SyncRequest: ");
|
||||||
request.apdu().printPDU();
|
request.apdu().printPDU();
|
||||||
@ -681,7 +681,7 @@ void SecureApplicationLayer::sendSyncResponse(uint16_t dstAddr, bool dstAddrIsGr
|
|||||||
print("sendSyncResponse: TPCI: ");
|
print("sendSyncResponse: TPCI: ");
|
||||||
println(tpci, HEX);
|
println(tpci, HEX);
|
||||||
|
|
||||||
if(secure(response.data() + APDU_LPDU_DIFF, kSecureSyncResponse, _deviceObj.induvidualAddress(), dstAddr, dstAddrIsGroupAddr, tpci, asdu, sizeof(asdu), secCtrl, systemBcast))
|
if(secure(response.data() + APDU_LPDU_DIFF, kSecureSyncResponse, _deviceObj.individualAddress(), dstAddr, dstAddrIsGroupAddr, tpci, asdu, sizeof(asdu), secCtrl, systemBcast))
|
||||||
{
|
{
|
||||||
_lastSyncRes = millis();
|
_lastSyncRes = millis();
|
||||||
|
|
||||||
@ -823,7 +823,7 @@ bool SecureApplicationLayer::decrypt(uint8_t* plainApdu, uint16_t plainApduLengt
|
|||||||
|
|
||||||
if (service == kSecureDataPdu)
|
if (service == kSecureDataPdu)
|
||||||
{
|
{
|
||||||
if (srcAddr != _deviceObj.induvidualAddress())
|
if (srcAddr != _deviceObj.individualAddress())
|
||||||
{
|
{
|
||||||
uint64_t expectedSeqNumber = lastValidSequenceNumber(toolAccess, srcAddr) + 1;
|
uint64_t expectedSeqNumber = lastValidSequenceNumber(toolAccess, srcAddr) + 1;
|
||||||
|
|
||||||
@ -847,7 +847,7 @@ bool SecureApplicationLayer::decrypt(uint8_t* plainApdu, uint16_t plainApduLengt
|
|||||||
if (!memcmp(knxSerialNumber, _deviceObj.propertyData(PID_SERIAL_NUMBER), 6))
|
if (!memcmp(knxSerialNumber, _deviceObj.propertyData(PID_SERIAL_NUMBER), 6))
|
||||||
{
|
{
|
||||||
uint8_t emptySerialNumber[6] = {0};
|
uint8_t emptySerialNumber[6] = {0};
|
||||||
if (systemBroadcast || dstAddr != _deviceObj.induvidualAddress() || !memcmp(knxSerialNumber, emptySerialNumber, 6))
|
if (systemBroadcast || dstAddr != _deviceObj.individualAddress() || !memcmp(knxSerialNumber, emptySerialNumber, 6))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -970,7 +970,7 @@ bool SecureApplicationLayer::decrypt(uint8_t* plainApdu, uint16_t plainApduLengt
|
|||||||
|
|
||||||
// prevent a sync.req sent by us to trigger sync notification, this happens if we provide our own tool key
|
// prevent a sync.req sent by us to trigger sync notification, this happens if we provide our own tool key
|
||||||
// for decryption above
|
// for decryption above
|
||||||
if (syncReq && (srcAddr == _deviceObj.induvidualAddress()))
|
if (syncReq && (srcAddr == _deviceObj.individualAddress()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (syncReq)
|
if (syncReq)
|
||||||
@ -986,7 +986,7 @@ bool SecureApplicationLayer::decrypt(uint8_t* plainApdu, uint16_t plainApduLengt
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (srcAddr == _deviceObj.induvidualAddress())
|
if (srcAddr == _deviceObj.individualAddress())
|
||||||
{
|
{
|
||||||
print("Update our next ");
|
print("Update our next ");
|
||||||
print(toolAccess ? "tool access" : "");
|
print(toolAccess ? "tool access" : "");
|
||||||
|
|||||||
@ -424,7 +424,7 @@ void TpUartDataLinkLayer::frameBytesReceived(uint8_t* buffer, uint16_t length)
|
|||||||
//printHex("=>", buffer, length);
|
//printHex("=>", buffer, length);
|
||||||
CemiFrame frame(buffer, length);
|
CemiFrame frame(buffer, length);
|
||||||
|
|
||||||
frameRecieved(frame);
|
frameReceived(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TpUartDataLinkLayer::dataConBytesReceived(uint8_t* buffer, uint16_t length, bool success)
|
void TpUartDataLinkLayer::dataConBytesReceived(uint8_t* buffer, uint16_t length, bool success)
|
||||||
@ -444,7 +444,7 @@ void TpUartDataLinkLayer::enabled(bool value)
|
|||||||
{
|
{
|
||||||
_enabled = true;
|
_enabled = true;
|
||||||
print("ownaddr ");
|
print("ownaddr ");
|
||||||
println(_deviceObject.induvidualAddress(), HEX);
|
println(_deviceObject.individualAddress(), HEX);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -160,9 +160,9 @@ template <class P, class B> class KnxFacade : private SaveRestore
|
|||||||
_bau.writeMemory();
|
_bau.writeMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t induvidualAddress()
|
uint16_t individualAddress()
|
||||||
{
|
{
|
||||||
return _bau.deviceObject().induvidualAddress();
|
return _bau.deviceObject().individualAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user