The simulator acts as a coap device, sends alarm messages and is able to handling a PSK set command.
- The simulator sends a coap alarm message to the coap-http proxy, from a
while(true)
loop in a separate virtual thread, started from theSimulator.kt
class, that extendsCommandLineRunner
. - If the response received contains a
PSK:SET
command, then:- Handle the PSK change:
- The new key is saved with status
PENDING
. - Send a success message.
- The pending key gets status
ACTIVE
and the previous active key gets statusINACTIVE
.
- The new key is saved with status
- If an error occurs during the PSK change handling:
- Send a failure message.
- If a pending key was already saved, set the status of this key as
INVALID
.
- The thread sleeps for
simulatorProperties.sleepDuration
seconds and then the flow starts again.
- Handle the PSK change: