default_ep = "http://localhost:8000" # args parser parser = ArgumentParser( description="An IPE called TestApplication6", prog="TestApplication6", formatter_class=ArgumentDefaultsHelpFormatter) parser.add_argument("-n", "--name", help="Name used for the AE.") parser.add_argument("-s", "--ep", help="URL of the local Endpoint.") # args, config and logging args, config = prepare_app(parser, __loader__, __name__, "config.json") # variables nm = get_value("name", (unicode, str), default_name, args, config) cb = config.get("cse_base", "onem2m") # ep = get_value("ep", (unicode, str), default_ep, args, config) ep = "http://eds-base:8000" poas = config.get("poas", ["http://auto:22639"]) originator_pre = config.get("originator_pre", "//openmtc.org/mn-cse-1") ssl_certs = config.get("ssl_certs", {}) # start app = TestApplication6( name=nm, cse_base=cb, poas=poas, originator_pre=originator_pre, **ssl_certs ) Runner(app).run(ep) print ("Exiting....")
value_offset = self.temp_offset else: value_range = self.humi_range value_offset = self.humi_offset # generate random sensor data value = int(random() * value_range + value_offset) self.handle_sensor_data(sensor, value) def handle_sensor_data(self, sensor, value): # initialize sensor structure if never done before if sensor not in self._recognized_sensors: self.create_sensor_structure(sensor) self.push_sensor_data(sensor, value) def create_sensor_structure(self, sensor): print('I need to create a structure for the sensor %s.' % sensor) self._recognized_sensors[sensor] = 'something useful' def push_sensor_data(self, sensor, value): print('I would push the content %i of %s to the gateway.' % (value, sensor)) if __name__ == '__main__': from openmtc_app.runner import AppRunner as Runner host = 'http://localhost:8000' app = TestIPE() Runner(app).run(host)