Ejemplo n.º 1
0
    def __init__(self, config, logHandlers=None):
        self._config = DeviceClientConfig(**config)

        AbstractClient.__init__(self,
                                domain=self._config.domain,
                                organization=self._config.orgId,
                                clientId=self._config.clientId,
                                username=self._config.username,
                                password=self._config.password,
                                port=self._config.port,
                                transport=self._config.transport,
                                cleanStart=self._config.cleanStart,
                                sessionExpiry=self._config.sessionExpiry,
                                keepAlive=self._config.keepAlive,
                                caFile=self._config.caFile,
                                logLevel=self._config.logLevel,
                                logHandlers=logHandlers)

        # Add handler for commands if not connected to QuickStart
        if not self._config.isQuickstart():
            self.client.message_callback_add("iot-2/cmd/+/fmt/+",
                                             self._onCommand)

        # Initialize user supplied callback
        self.commandCallback = None

        # Register startup subscription list (only for non-Quickstart)
        if not self._config.isQuickstart():
            self._subscriptions[self._COMMAND_TOPIC] = 1
Ejemplo n.º 2
0
    def __init__(self, options, logHandlers=None):
        self._options = options

        ### DEFAULTS ###
        if "domain" not in self._options:
            # Default to the domain for the public cloud offering
            self._options['domain'] = "internetofthings.ibmcloud.com"
        if "clean-session" not in self._options:
            self._options['clean-session'] = "true"

        ### REQUIRED ###
        if self._options['org'] == None:
            raise ConfigurationException("Missing required property: org")
        if self._options['type'] == None:
            raise ConfigurationException("Missing required property: type")
        if self._options['id'] == None:
            raise ConfigurationException("Missing required property: id")

        if self._options['org'] != "quickstart":
            if self._options['auth-method'] == None:
                raise ConfigurationException(
                    "Missing required property: auth-method")

            if (self._options['auth-method'] == "token"):
                if self._options['auth-token'] == None:
                    raise ConfigurationException(
                        "Missing required property for token based authentication: auth-token"
                    )
            else:
                raise UnsupportedAuthenticationMethod(options['authMethod'])

        AbstractClient.__init__(
            self,
            domain=self._options['domain'],
            organization=self._options['org'],
            clientId="d:" + self._options['org'] + ":" +
            self._options['type'] + ":" + self._options['id'],
            username="******" if
            (self._options['auth-method'] == "token") else None,
            password=self._options['auth-token'],
            logHandlers=logHandlers,
            cleanSession=self._options['clean-session'])

        # Add handler for commands if not connected to QuickStart
        if self._options['org'] != "quickstart":
            self.client.message_callback_add("iot-2/cmd/+/fmt/+",
                                             self.__onCommand)

        self.subscriptionsAcknowledged = threading.Event()

        # Initialize user supplied callback
        self.commandCallback = None

        self.client.on_connect = self.on_connect

        self.setMessageEncoderModule('json', jsonCodec)
        self.setMessageEncoderModule('json-iotf', jsonIotfCodec)
Ejemplo n.º 3
0
    def __init__(self, options, logHandlers=None):
        self._options = options

        if self._options['org'] == None:
            raise ConfigurationException("Missing required property: org")
        if self._options['type'] == None:
            raise ConfigurationException("Missing required property: type")
        if self._options['id'] == None:
            raise ConfigurationException("Missing required property: id")

        if self._options['org'] != "quickstart":
            if self._options['auth-method'] == None:
                raise ConfigurationException(
                    "Missing required property: auth-method")

            if (self._options['auth-method'] == "token"):
                if self._options['auth-token'] == None:
                    raise ConfigurationException(
                        "Missing required property for token based authentication: auth-token"
                    )
            else:
                raise UnsupportedAuthenticationMethod(options['authMethod'])
        self._options['subscriptionList'] = {}

        AbstractClient.__init__(self,
                                organization=options['org'],
                                clientId="g:" + options['org'] + ":" +
                                options['type'] + ":" + options['id'],
                                username="******" if
                                (options['auth-method'] == "token") else None,
                                password=options['auth-token'],
                                logHandlers=logHandlers)

        # Add handler for commands if not connected to QuickStart
        if self._options['org'] != "quickstart":
            gatewayCommandTopic = "iot-2/type/" + options[
                'type'] + "/id/" + options['id'] + "/cmd/+/fmt/json"
            messageNotificationTopic = "iot-2/type/" + options[
                'type'] + "/id/" + options['id'] + "/notify"
            #localTopic = "iot-2/type/iotsample-raspberrypi2/id/89898889/cmd/greeting/fmt/json"
            self.client.message_callback_add(gatewayCommandTopic,
                                             self.__onCommand)
            self.client.message_callback_add("iot-2/type/+/id/+/cmd/+/fmt/+",
                                             self.__onDeviceCommand)
            self.client.message_callback_add(messageNotificationTopic,
                                             self.__onMessageNotification)

        self.subscriptionsAcknowledged = threading.Event()

        # Initialize user supplied callback
        self.commandCallback = None
        self.deviceCommandCallback = None
        self.notificationCallback = None
        self.client.on_connect = self.on_connect
        self.setMessageEncoderModule('json', jsonCodec)
        self.setMessageEncoderModule('json-iotf', jsonIotfCodec)
Ejemplo n.º 4
0
	def __init__(self, options, logHandlers=None):
		self._options = options

		if self._options['org'] == None:
			raise ConfigurationException("Missing required property: org")
		if self._options['type'] == None: 
			raise ConfigurationException("Missing required property: type")
		if self._options['id'] == None: 
			raise ConfigurationException("Missing required property: id")
				
		if self._options['org'] != "quickstart":
			if self._options['auth-method'] == None: 
				raise ConfigurationException("Missing required property: auth-method")
				
			if (self._options['auth-method'] == "token"):
				if self._options['auth-token'] == None: 
					raise ConfigurationException("Missing required property for token based authentication: auth-token")
			else:
				raise UnsupportedAuthenticationMethod(options['authMethod'])
		self._options['subscriptionList'] = {}

		# Include staging
		self._options['staging'] = options['staging'] if 'staging' in options else None
			
		AbstractClient.__init__(
			self, 
			organization = options['org'],
			clientId = "g:" + options['org'] + ":" + options['type'] + ":" + options['id'], 
			username = "******" if (options['auth-method'] == "token") else None,
			password = options['auth-token'],
			logHandlers = logHandlers,
			staging = options['staging']
		)


		# Add handler for commands if not connected to QuickStart
		if self._options['org'] != "quickstart":
			gatewayCommandTopic = "iot-2/type/" + options['type'] + "/id/" + options['id'] + "/cmd/+/fmt/json"
			messageNotificationTopic = "iot-2/type/" + options['type'] + "/id/" + options['id'] + "/notify"
			#localTopic = "iot-2/type/iotsample-raspberrypi2/id/89898889/cmd/greeting/fmt/json"
			self.client.message_callback_add(gatewayCommandTopic, self.__onCommand)
			self.client.message_callback_add("iot-2/type/+/id/+/cmd/+/fmt/+", self.__onDeviceCommand)
			self.client.message_callback_add(messageNotificationTopic, self.__onMessageNotification)
			

		self.subscriptionsAcknowledged = threading.Event()
		
		# Initialize user supplied callback
		self.commandCallback = None
		self.deviceCommandCallback = None
		self.notificationCallback = None
		self.client.on_connect = self.on_connect
		self.setMessageEncoderModule('json', jsonCodec)
		self.setMessageEncoderModule('json-iotf', jsonIotfCodec)
Ejemplo n.º 5
0
	def __init__(self, options, logHandlers=None):
		self._options = options

		### DEFAULTS ###
		if "domain" not in self._options:
			# Default to the domain for the public cloud offering
			self._options['domain'] = "internetofthings.ibmcloud.com"
		if "clean-session" not in self._options:
			self._options['clean-session'] = "true"

		### REQUIRED ###
		if self._options['org'] == None:
			raise ConfigurationException("Missing required property: org")
		if self._options['type'] == None:
			raise ConfigurationException("Missing required property: type")
		if self._options['id'] == None:
			raise ConfigurationException("Missing required property: id")

		if self._options['org'] != "quickstart":
			if self._options['auth-method'] == None:
				raise ConfigurationException("Missing required property: auth-method")

			if (self._options['auth-method'] == "token"):
				if self._options['auth-token'] == None:
					raise ConfigurationException("Missing required property for token based authentication: auth-token")
			else:
				raise UnsupportedAuthenticationMethod(options['authMethod'])


		AbstractClient.__init__(
			self,
			domain = self._options['domain'],
			organization = self._options['org'],
			clientId = "d:" + self._options['org'] + ":" + self._options['type'] + ":" + self._options['id'],
			username = "******" if (self._options['auth-method'] == "token") else None,
			password = self._options['auth-token'],
			logHandlers = logHandlers,
			cleanSession = self._options['clean-session']
		)

		# Add handler for commands if not connected to QuickStart
		if self._options['org'] != "quickstart":
			self.client.message_callback_add("iot-2/cmd/+/fmt/+", self.__onCommand)

		self.subscriptionsAcknowledged = threading.Event()

		# Initialize user supplied callback
		self.commandCallback = None

		self.client.on_connect = self.on_connect

		self.setMessageEncoderModule('json', jsonCodec)
		self.setMessageEncoderModule('json-iotf', jsonIotfCodec)
Ejemplo n.º 6
0
    def __init__(self, options, logHandlers=None):
        self._options = options

        if self._options['org'] == None:
            raise ConfigurationException("Missing required property: org")
        if self._options['type'] == None:
            raise ConfigurationException("Missing required property: type")
        if self._options['id'] == None:
            raise ConfigurationException("Missing required property: id")

        if self._options['org'] != "quickstart":
            if self._options['auth-method'] == None:
                raise ConfigurationException(
                    "Missing required property: auth-method")

            if (self._options['auth-method'] == "token"):
                if self._options['auth-token'] == None:
                    raise ConfigurationException(
                        "Missing required property for token based authentication: auth-token"
                    )
            else:
                raise UnsupportedAuthenticationMethod(options['authMethod'])

        # Include staging
        self._options[
            'staging'] = options['staging'] if 'staging' in options else None

        AbstractClient.__init__(self,
                                organization=options['org'],
                                clientId="d:" + options['org'] + ":" +
                                options['type'] + ":" + options['id'],
                                username="******" if
                                (options['auth-method'] == "token") else None,
                                password=options['auth-token'],
                                logHandlers=logHandlers,
                                staging=options['staging'])

        # Add handler for commands if not connected to QuickStart
        if self._options['org'] != "quickstart":
            self.client.message_callback_add("iot-2/cmd/+/fmt/+",
                                             self.__onCommand)

        self.subscriptionsAcknowledged = threading.Event()

        # Initialize user supplied callback
        self.commandCallback = None

        self.client.on_connect = self.on_connect

        self.setMessageEncoderModule('json', jsonCodec)
        self.setMessageEncoderModule('json-iotf', jsonIotfCodec)
Ejemplo n.º 7
0
	def __init__(self, options, logHandlers=None):
		self._options = options

		if self._options['org'] == None:
			raise ConfigurationException("Missing required property: org")
		if self._options['type'] == None: 
			raise ConfigurationException("Missing required property: type")
		if self._options['id'] == None: 
			raise ConfigurationException("Missing required property: id")
		
		if self._options['org'] != "quickstart":
			if self._options['auth-method'] == None: 
				raise ConfigurationException("Missing required property: auth-method")
				
			if (self._options['auth-method'] == "token"):
				if self._options['auth-token'] == None: 
					raise ConfigurationException("Missing required property for token based authentication: auth-token")
			else:
				raise UnsupportedAuthenticationMethod(options['authMethod'])

		# Include staging
		self._options['staging'] = options['staging'] if 'staging' in options else None

		AbstractClient.__init__(
			self, 
			organization = options['org'],
			clientId = "d:" + options['org'] + ":" + options['type'] + ":" + options['id'], 
			username = "******" if (options['auth-method'] == "token") else None,
			password = options['auth-token'],
			logHandlers = logHandlers,
			staging = options['staging']
		)


		# Add handler for commands if not connected to QuickStart
		if self._options['org'] != "quickstart":
			self.client.message_callback_add("iot-2/cmd/+/fmt/+", self.__onCommand)

		self.subscriptionsAcknowledged = threading.Event()
		
		# Initialize user supplied callback
		self.commandCallback = None

		self.client.on_connect = self.on_connect
		
		self.setMessageEncoderModule('json', jsonCodec)
		self.setMessageEncoderModule('json-iotf', jsonIotfCodec)
Ejemplo n.º 8
0
    def __init__(self, config, logHandlers=None):
        self._config = ApplicationClientConfig(**config)
        # Call parent constructor
        AbstractClient.__init__(self,
                                domain=self._config.domain,
                                organization=self._config.orgId,
                                clientId=self._config.clientId,
                                username=self._config.username,
                                password=self._config.password,
                                logHandlers=logHandlers,
                                cleanStart=self._config.cleanStart,
                                port=self._config.port,
                                transport=self._config.transport)

        # Add handlers for events and status
        self.client.message_callback_add("iot-2/type/+/id/+/evt/+/fmt/+",
                                         self._onDeviceEvent)
        self.client.message_callback_add("iot-2/type/+/id/+/mon",
                                         self._onDeviceStatus)
        self.client.message_callback_add("iot-2/app/+/mon", self._onAppStatus)

        # Add handler for commands if not connected to QuickStart
        if not self._config.isQuickstart():
            self.client.message_callback_add("iot-2/type/+/id/+/cmd/+/fmt/+",
                                             self._onDeviceCommand)

        # Attach fallback handler
        self.client.on_message = self._onUnsupportedMessage

        # Initialize user supplied callbacks
        self.deviceEventCallback = None
        self.deviceCommandCallback = None
        self.deviceStatusCallback = None
        self.appStatusCallback = None

        # Create an api client if not connected in QuickStart mode
        if not self._config.isQuickstart():
            apiClient = ApiClient(self._config, self.logger)
            self.registry = Registry(apiClient)
            self.status = Status(apiClient)
            self.usage = Usage(apiClient)
            self.lec = LEC(apiClient)
            self.mgmt = Mgmt(apiClient)
Ejemplo n.º 9
0
    def __init__(self, config, logHandlers=None):
        """
        Override the constructor
        """
        self._config = GatewayClientConfig(**config)

        AbstractClient.__init__(self,
                                domain=self._config.domain,
                                organization=self._config.orgId,
                                clientId=self._config.clientId,
                                username=self._config.username,
                                password=self._config.password,
                                port=self._config.port,
                                transport=self._config.transport,
                                cleanStart=self._config.cleanStart,
                                sessionExpiry=self._config.sessionExpiry,
                                keepAlive=self._config.keepAlive,
                                caFile=self._config.caFile,
                                logLevel=self._config.logLevel,
                                logHandlers=logHandlers)

        self.COMMAND_TOPIC = "iot-2/type/" + self._config.typeId + "/id/" + self._config.deviceId + "/cmd/+/fmt/+"

        gatewayCommandTopic = "iot-2/type/" + self._config.typeId + "/id/" + self._config.deviceId + "/cmd/+/fmt/json"
        deviceCommandTopic = "iot-2/type/+/id/+/cmd/+/fmt/+"
        messageNotificationTopic = "iot-2/type/" + self._config.typeId + "/id/" + self._config.deviceId + "/notify"

        self.client.message_callback_add(gatewayCommandTopic, self._onCommand)
        self.client.message_callback_add(deviceCommandTopic,
                                         self._onDeviceCommand)
        self.client.message_callback_add(messageNotificationTopic,
                                         self._onMessageNotification)

        # Initialize user supplied callback
        self.commandCallback = None
        self.deviceCommandCallback = None
        self.notificationCallback = None
        self.client.on_connect = self._onConnect
        self.client.on_disconnect = self._onDisconnect
Ejemplo n.º 10
0
    def __init__(self, options, logHandlers=None):
        self._options = options

        #Defaults
        if "domain" not in self._options:
            # Default to the domain for the public cloud offering
            self._options['domain'] = "internetofthings.ibmcloud.com"

        if "org" not in self._options:
            # Default to the quickstart ode
            self._options['org'] = "quickstart"

        if "clean-session" not in self._options:
            self._options['clean-session'] = "true"

        if "port" not in self._options and self._options["org"] != "quickstart":
            self._options["port"] = 8883

        if self._options["org"] == "quickstart":
            self._options["port"] = 1883

        #Check for any missing required properties
        if self._options['org'] == None:
            raise ConfigurationException("Missing required property: org")
        if self._options['type'] == None:
            raise ConfigurationException("Missing required property: type")
        if self._options['id'] == None:
            raise ConfigurationException("Missing required property: id")

        if self._options['org'] != "quickstart":
            if self._options['auth-method'] == None:
                raise ConfigurationException(
                    "Missing required property: auth-method")

            if (self._options['auth-method'] == "token"):
                if self._options['auth-token'] == None:
                    raise ConfigurationException(
                        "Missing required property for token based authentication: auth-token"
                    )
            else:
                raise UnsupportedAuthenticationMethod(options['authMethod'])
        self._options['subscriptionList'] = {}

        self.COMMAND_TOPIC = "iot-2/type/" + self._options[
            'type'] + "/id/" + self._options['id'] + "/cmd/+/fmt/+"

        AbstractClient.__init__(
            self,
            domain=self._options['domain'],
            organization=self._options['org'],
            clientId="g:" + self._options['org'] + ":" +
            self._options['type'] + ":" + self._options['id'],
            username="******" if
            (self._options['auth-method'] == "token") else None,
            password=self._options['auth-token'],
            logHandlers=logHandlers,
            port=self._options['port'])

        # Add handler for commands if not connected to QuickStart
        if self._options['org'] != "quickstart":
            gatewayCommandTopic = "iot-2/type/" + options[
                'type'] + "/id/" + options['id'] + "/cmd/+/fmt/json"
            messageNotificationTopic = "iot-2/type/" + options[
                'type'] + "/id/" + options['id'] + "/notify"
            #localTopic = "iot-2/type/iotsample-raspberrypi2/id/89898889/cmd/greeting/fmt/json"
            self.client.message_callback_add(gatewayCommandTopic,
                                             self.__onCommand)
            self.client.message_callback_add("iot-2/type/+/id/+/cmd/+/fmt/+",
                                             self.__onDeviceCommand)
            self.client.message_callback_add(messageNotificationTopic,
                                             self.__onMessageNotification)

        self.subscriptionsAcknowledged = threading.Event()

        # Initialize user supplied callback
        self.commandCallback = None
        self.deviceCommandCallback = None
        self.notificationCallback = None
        self.client.on_connect = self.on_connect
        self.setMessageEncoderModule('json', jsonCodec)
        self.setMessageEncoderModule('json-iotf', jsonIotfCodec)
        self.setMessageEncoderModule('xml', xmlCodec)

        # Create api key for gateway authentication
        self.gatewayApiKey = "g/" + self._options['org'] + '/' + self._options[
            'type'] + '/' + self._options['id']
        self.logger = logging.getLogger(self.__module__ + "." +
                                        self.__class__.__name__)
        self.logger.setLevel(logging.INFO)
        self.api = api.ApiClient(
            {
                "org": self._options['org'],
                "auth-token": self._options['auth-token'],
                "auth-key": self.gatewayApiKey
            }, self.logger)
Ejemplo n.º 11
0
    def __init__(self, config, logHandlers=None, deviceInfo=None):
        """
        Override the constructor
        """
        if config['identity']['orgId'] == "quickstart":
            raise ConfigurationException(
                "QuickStart does not support device management")

        self._config = GatewayClientConfig(**config)

        AbstractClient.__init__(self,
                                domain=self._config.domain,
                                organization=self._config.orgId,
                                clientId=self._config.clientId,
                                username=self._config.username,
                                password=self._config.password,
                                port=self._config.port,
                                transport=self._config.transport,
                                cleanStart=self._config.cleanStart,
                                sessionExpiry=self._config.sessionExpiry,
                                keepAlive=self._config.keepAlive,
                                caFile=self._config.caFile,
                                logLevel=self._config.logLevel,
                                logHandlers=logHandlers)

        self.COMMAND_TOPIC = "iot-2/type/" + self._config.typeId + "/id/" + self._config.deviceId + "/cmd/+/fmt/+"

        gatewayCommandTopic = "iot-2/type/" + self._config.typeId + "/id/" + self._config.deviceId + "/cmd/+/fmt/json"
        deviceCommandTopic = "iot-2/type/+/id/+/cmd/+/fmt/+"
        messageNotificationTopic = "iot-2/type/" + self._config.typeId + "/id/" + self._config.deviceId + "/notify"

        self.client.message_callback_add(gatewayCommandTopic, self._onCommand)
        self.client.message_callback_add(deviceCommandTopic,
                                         self._onDeviceCommand)
        self.client.message_callback_add(messageNotificationTopic,
                                         self._onMessageNotification)

        # Initialize user supplied callback
        self.deviceCommandCallback = None
        self.notificationCallback = None

        # ---------------------------------------------------------------------
        # Device Management Specific code starts here
        # ---------------------------------------------------------------------
        self.readyForDeviceMgmt = threading.Event()

        # Add handler for supported device management commands
        self.client.message_callback_add("iotdm-1/#",
                                         self.__onDeviceMgmtResponse)

        # List of DM requests that have not received a response yet
        self._deviceMgmtRequestsPendingLock = threading.Lock()
        self._deviceMgmtRequestsPending = {}

        # List of DM notify hook
        self._deviceMgmtObservationsLock = threading.Lock()
        self._deviceMgmtObservations = []

        # Initialize local device data model
        self.metadata = {}
        if deviceInfo is not None:
            self._deviceInfo = deviceInfo
        else:
            self._deviceInfo = DeviceInfo()

        self._location = None
        self._errorCode = None

        # Initialize subscription list
        self._subscriptions[self.DM_RESPONSE_TOPIC_TEMPLATE %
                            (self._config.typeId, self._config.deviceId)] = 1
        self._subscriptions[self.DM_OBSERVE_TOPIC_TEMPLATE %
                            (self._config.typeId, self._config.deviceId)] = 1
        self._subscriptions[self.COMMAND_TOPIC] = 1
Ejemplo n.º 12
0
	def __init__(self, options, logHandlers=None):
		self._options = options

		#Defaults
		if "domain" not in self._options:
			# Default to the domain for the public cloud offering
			self._options['domain'] = "internetofthings.ibmcloud.com"

		if "org" not in self._options:
			# Default to the quickstart ode
			self._options['org'] = "quickstart"

		if "clean-session" not in self._options:
			self._options['clean-session'] = "true"

		if "port" not in self._options and self._options["org"] != "quickstart":
			self._options["port"] = 8883;

		if self._options["org"] == "quickstart":
			self._options["port"] = 1883;

		#Check for any missing required properties
		if self._options['org'] == None:
			raise ConfigurationException("Missing required property: org")
		if self._options['type'] == None:
			raise ConfigurationException("Missing required property: type")
		if self._options['id'] == None:
			raise ConfigurationException("Missing required property: id")

		if self._options['org'] != "quickstart":
			if self._options['auth-method'] == None:
				raise ConfigurationException("Missing required property: auth-method")

			if (self._options['auth-method'] == "token"):
				if self._options['auth-token'] == None:
					raise ConfigurationException("Missing required property for token based authentication: auth-token")
			else:
				raise UnsupportedAuthenticationMethod(options['authMethod'])
		self._options['subscriptionList'] = {}

		
		COMMAND_TOPIC = "iot-2/type/" + self._options['type'] + "/id/" + self._options['id'] + "/cmd/+/fmt/+"
		
		AbstractClient.__init__(
			self,
			domain = self._options['domain'],
			organization = self._options['org'],
			clientId = "g:" + self._options['org'] + ":" + self._options['type'] + ":" + self._options['id'],
			username = "******" if (self._options['auth-method'] == "token") else None,
			password = self._options['auth-token'],
			logHandlers = logHandlers,
			port = self._options['port']
		)


		# Add handler for commands if not connected to QuickStart
		if self._options['org'] != "quickstart":
			gatewayCommandTopic = "iot-2/type/" + options['type'] + "/id/" + options['id'] + "/cmd/+/fmt/json"
			messageNotificationTopic = "iot-2/type/" + options['type'] + "/id/" + options['id'] + "/notify"
			#localTopic = "iot-2/type/iotsample-raspberrypi2/id/89898889/cmd/greeting/fmt/json"
			self.client.message_callback_add(gatewayCommandTopic, self.__onCommand)
			self.client.message_callback_add("iot-2/type/+/id/+/cmd/+/fmt/+", self.__onDeviceCommand)
			self.client.message_callback_add(messageNotificationTopic, self.__onMessageNotification)


		self.subscriptionsAcknowledged = threading.Event()

		# Initialize user supplied callback
		self.commandCallback = None
		self.deviceCommandCallback = None
		self.notificationCallback = None
		self.client.on_connect = self.on_connect
		self.setMessageEncoderModule('json', jsonCodec)
		self.setMessageEncoderModule('json-iotf', jsonIotfCodec)
		self.setMessageEncoderModule('xml', xmlCodec)

		# Create api key for gateway authentication
		self.gatewayApiKey = "g/" + self._options['org'] + '/' + self._options['type'] + '/' + self._options['id']
		self.logger = logging.getLogger(self.__module__+"."+self.__class__.__name__)
		self.logger.setLevel(logging.INFO)
		self.apiClient = api.ApiClient({"org": self._options['org'], "auth-token": self._options['auth-token'], "auth-key": self.gatewayApiKey },self.logger)