def write_sample(self, temperature): temperature_v = IotValue() temperature_v.float32 = temperature sensor_data = IotNvpSeq() sensor_data.append(IotNvp('temperature', temperature_v)) self._thing.write('temperature', sensor_data)
def write_sample(self, temperature): temperature_v = IotValue() temperature_v.float32 = temperature sensor_data = IotNvpSeq() sensor_data.append(IotNvp('temperature', temperature_v)) try: self._thing.write('temperature', sensor_data) except RuntimeError as e: print('Error writing data: ' + str(e))
def write_distance(self, my_location_flow_id, distance, eta, timestamp): dist_v = IotValue() dist_v.float64 = distance eta_v = IotValue() eta_v.float32 = eta timestamp_v = IotValue() timestamp_v.uint64 = timestamp distance_data = IotNvpSeq() distance_data.append(IotNvp('distance', dist_v)) distance_data.append(IotNvp('eta', eta_v)) distance_data.append(IotNvp('timestampUtc', timestamp_v)) # Write distance to DataRiver using flow ID from incoming location sample self._thing.write('distance', my_location_flow_id, distance_data)