April 2020
Intermediate to advanced
294 pages
7h 53m
English
We are now able to receive and parse commands, but we also need to be able to send status information back to the server. In order to do this, we are going to create a system status task that will call the IotDevice object's sample method and then package the data up and send it in JSON format to the socket server. This system_status task will be added to the asyncio task list when we write the main application code. The task code can be seen as follows:
def system_status(): while True: # Sample Sensors or get the latest result Device.sample() data = {} data['id'] = Device.ID data['temperature'] = Device.Temperature data['humidity'] = Device.Humidity data['led1'] = Device.LED1 data['led2'] = Device.LED2 data['led3'] ...Read now
Unlock full access