13 const uint8_t SecurityInterfaceObject::_fdsk[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F };
14 uint8_t SecurityInterfaceObject::_secReport[] = { 0x00, 0x00, 0x00 };
15 uint8_t SecurityInterfaceObject::_secReportCtrl[] = { 0x00, 0x00, 0x00 };
28 data[0] = obj->_state;
38 [](
SecurityInterfaceObject * obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) ->
void {
39 uint8_t serviceId = data[1] & 0xff;
50 uint8_t mode = data[2];
59 obj->setSecurityMode(mode == 1);
61 resultData[1] = serviceId;
69 [](
SecurityInterfaceObject * obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) ->
void {
70 uint8_t serviceId = data[1] & 0xff;
83 resultData[1] = serviceId;
96 [](
SecurityInterfaceObject * obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) ->
void {
104 uint8_t
id = data[1];
105 uint8_t info = data[2];
107 if (
id == 0 && info == 0)
109 obj->clearFailureLog();
119 [](
SecurityInterfaceObject * obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) ->
void {
127 uint8_t
id = data[1];
128 uint8_t info = data[2];
131 if (
id == 0 && info == 0)
136 resultData[2] = info;
137 obj->getFailureCounters(&resultData[3]);
138 resultLength = 3 + 8;
144 uint8_t maxBufferSize = resultLength;
145 uint8_t index = info;
146 uint8_t numBytes = obj->getFromFailureLogByIndex(index, &resultData[2], maxBufferSize);
152 resultData[2] = index;
153 resultLength += numBytes;
154 resultLength = 3 + numBytes;
182 buffer =
pushByte(_securityModeEnabled, buffer);
193 uint8_t securityModeEnabled = 0;
194 buffer =
popByte(securityModeEnabled, buffer);
195 _securityModeEnabled = securityModeEnabled;
205 void SecurityInterfaceObject::setSecurityMode(
bool enabled)
207 print(
"Security mode set to: ");
208 println(enabled ?
"enabled" :
"disabled");
209 _securityModeEnabled = enabled;
214 return _securityModeEnabled;
217 void SecurityInterfaceObject::clearFailureLog()
222 void SecurityInterfaceObject::getFailureCounters(uint8_t* data)
225 println(
"getFailureCounters()");
228 uint8_t SecurityInterfaceObject::getFromFailureLogByIndex(uint8_t index, uint8_t* data, uint8_t maxDataLen)
230 print(
"getFromFailureLogByIndex(): Index: ");
245 void SecurityInterfaceObject::loadEvent(
const uint8_t* data)
250 loadEventUnloaded(data);
254 loadEventLoading(data);
258 loadEventLoaded(data);
262 loadEventError(data);
271 void SecurityInterfaceObject::loadEventUnloaded(
const uint8_t* data)
273 uint8_t
event = data[0];
293 void SecurityInterfaceObject::loadEventLoading(
const uint8_t* data)
295 uint8_t
event = data[0];
318 void SecurityInterfaceObject::loadEventLoaded(
const uint8_t* data)
320 uint8_t
event = data[0];
347 void SecurityInterfaceObject::loadEventError(
const uint8_t* data)
349 uint8_t
event = data[0];
371 if (newState == _state)
378 void SecurityInterfaceObject::errorCode(
ErrorCode errorCode)
380 uint8_t data = errorCode;
390 println(
"Factory reset of security interface object requested.");
391 setSecurityMode(
false);
416 uint8_t entry[elementSize];
418 for (
int i = 1; i <= numElements; i++)
421 uint16_t index = (entry[0] << 8) | entry[1];
423 if (index > addressIndex)
428 if (index == addressIndex)
451 uint8_t entry[elementSize];
453 for (
int i = 1; i <= numElements; i++)
456 uint16_t index = ((entry[0] << 8) | entry[1]);
458 if (index > addressIndex)
463 if (index == addressIndex)
483 uint8_t entry[elementSize];
485 for (
int i = 1; i <= numElements; i++)
488 uint16_t addr = (entry[0] << 8) | entry[1];
503 uint8_t seqBytes[6] = {0x00};
516 uint16_t SecurityInterfaceObject::getNumberOfElements(
PropertyID propId)
519 uint16_t numElements = 0;
521 uint8_t data[
sizeof(uint16_t)];
542 uint8_t entry[elementSize];
544 for (
int i = 1; i <= numElements; i++)
547 uint16_t addr = (entry[0] << 8) | entry[1];
549 if (addr == deviceAddr)
569 uint8_t entry[elementSize];
571 for (
int i = 1; i <= numElements; i++)
574 uint16_t addr = (entry[0] << 8) | entry[1];
576 if (addr == deviceAddr)
596 bool conf = (data[0] & 2) == 2;
597 bool auth = (data[0] & 1) == 1;
const uint8_t * popByte(uint8_t &b, const uint8_t *data)
void sixBytesFromUInt64(uint64_t num, uint8_t *toByteArray)
uint8_t * pushByte(uint8_t b, uint8_t *data)
uint64_t sixBytesToUInt64(uint8_t *data)
const uint8_t * popWord(uint16_t &w, const uint8_t *data)
uint8_t * save(uint8_t *buffer) override
This method is called when the object should save its state to the buffer.
const uint8_t * propertyData(PropertyID id)
const uint8_t * restore(const uint8_t *buffer) override
This method is called when the object should restore its state from the buffer.
virtual uint8_t propertySize(PropertyID id)
Gets the size of of property in bytes.
virtual void state(PropertyID id, uint8_t *data, uint8_t length, uint8_t *resultData, uint8_t &resultLength)
Get state of a function property of the interface object.
virtual void initializeProperties(size_t propertiesSize, Property **properties)
Intializes the Property-array the the supplied values.
uint16_t saveSize() override
Property * property(PropertyID id)
Gets property with PropertyID id if it exists and nullptr otherwise.
virtual uint8_t read(uint16_t start, uint8_t count, uint8_t *data) const =0
virtual uint8_t write(uint16_t start, uint8_t count, const uint8_t *data)=0
const uint8_t * groupKey(uint16_t addressIndex)
bool isSecurityModeEnabled()
uint64_t getLastValidSequenceNumber(uint16_t deviceAddr)
void masterReset(EraseCode eraseCode, uint8_t channel) override
SecurityInterfaceObject()
uint8_t * save(uint8_t *buffer) override
This method is called when the object should save its state to the buffer.
void setLastValidSequenceNumber(uint16_t deviceAddr, uint64_t seqNum)
uint16_t saveSize() override
void setSequenceNumber(bool toolAccess, uint64_t seqNum)
const uint8_t * toolKey()
const uint8_t * p2pKey(uint16_t addressIndex)
const uint8_t * restore(const uint8_t *buffer) override
This method is called when the object should restore its state from the buffer.
uint16_t indAddressIndex(uint16_t indAddr)
DataSecurity getGroupObjectSecurity(uint16_t index)
@ OT_SECURITY
Security Interface Object.
@ LE_ADDITIONAL_LOAD_CONTROLS
@ PID_SECURITY_FAILURES_LOG
@ PID_OBJECT_TYPE
Interface Object Type independent Properties.
@ PID_SECURITY_INDIVIDUAL_ADDRESS_TABLE
@ PID_SECURITY_REPORT_CONTROL
@ PID_TOOL_SEQUENCE_NUMBER_SENDING
@ PID_SECURITY_MODE
Security Interface Object.
@ PID_SEQUENCE_NUMBER_SENDING
@ PDT_CONTROL
length: 1 read, 10 write
@ PDT_GENERIC_16
length: 16
@ PDT_GENERIC_08
length: 8
@ PDT_GENERIC_18
length: 18
@ PDT_BINARY_INFORMATION
length: 3
@ PDT_GENERIC_06
length: 6
@ PDT_GENERIC_19
length: 19
@ PDT_GENERIC_20
length: 20
@ PDT_UNSIGNED_INT
length: 2
@ PDT_GENERIC_01
length: 1