iotcs.messaging.client.device.device module¶
-
class
iotcs.messaging.client.device.device.
DirectlyConnectedDeviceImpl
(path, passphrase, isGatewayDevice=False)¶ Bases:
iotcs.common.Closeable
This constructor is used internally and not intended for general use. :param path: :param passphrase: :param isGatewayDevice:
-
DIRECTLY_CONNECTED_DEVICE_CAPABILITIES
= ''¶
-
USE_DEFAULT_TIMEOUT_VALUE
= -1¶
-
activate
(deviceModels)¶ Parameters: deviceModels – Returns: Raises: ValueError – if device is already activated
-
close
()¶ Close the MessageDispatcher :return:
-
classmethod
closeStorageConnection
(secureConnection)¶
-
createSecureConnection
()¶
-
createSendReceiveImpl
()¶
-
createStorageObject
(uri, name=None, contentType=None)¶ Create a new StorageObject.
- if uri is not None, name and contentType are ignored…
- Create a new
StorageObject
from the uri for a named object in storage. - if uri is None…
The created storage object that will have a name with the given object name prefixed with the device’s endpoint ID and a directory separator. The prefix addition can be disabled by setting the
config
property disable_storage_object_prefix in section media_storage to True.if contentType is None, the mime-type defaults to application/octet-stream.
Parameters: - uri – the URI of the object in the storage cloud, if not None, name and contentType are ignored.
- name – the unique name to be used to reference the content in storage
- contentType – The mime-type of the content or None
Returns: a
StorageObject <.messaging.client.device.StorageObjectDelegate
# noqa: E501Raises: - TransportError – if exception raised by the runtime, or an abnormal response from the storage cloud
- SecurityException – if there is an exception establishing a secure connection to the storage cloud
-
dumpMessage
(message)¶
-
getDeviceModel
(urn)¶
-
getEndpointId
()¶
-
getLogger
()¶
-
classmethod
getStorageConnection
(secureConnection)¶ Return the
StorageConnection
with this secureConnection.Parameters: secureConnection – a SecureConnection
instanceReturns: return the StorageConnection
mapped to secureConnection
-
isActivated
()¶
-
isGatewayDevice
¶
-
isMqtt
¶
-
offer
(messages)¶ Offer messages to be sent to the server.
Whether or not the messages are sent depends on policies that have been configured for the attributes in the message. If there are no policies for the attributes in the message, then this call is equivalent to calling {@link #send(Message…)}. Depending on the policies, it is possible that all, some, or none of the messages will be sent.
If messages are sent, this call will block until the server responds to the message delivery, or a network timeout occurs. The network timeout can be configured by setting the
iotcs.config
property http_response_timeout in section device_messaging. :param messages: zero or moreDataMessage
,Raises: TransportException
if there is an I/O exception when trying to send messages.Raises: SecurityException
when key or signature algorithm class cannot be loaded, or the key is not in the trusted assets store, or the private key is invalidRaises: StateException
if the gateway device has not been authenticated with the server.
-
receive
(timeout=-1)¶ Get messages from the IOT Cloud Service :param timeout: the time to wait for a response from the cloud service :returns: :raises:
StateException
if device is not activated.
-
registerDevicePolicyResource
()¶
-
scheme
¶
-
secureConn
¶
-
send
(messages)¶ Send messages to the IOT Cloud Service :param messages: a list of Message :raises: ValueError if device is not activated
-
sendReceiveImpl
¶
-
tam
¶
-
-
class
iotcs.messaging.client.device.device.
GatewayDeviceImpl
(path, passphrase)¶ Bases:
iotcs.messaging.client.device.device.DirectlyConnectedDeviceImpl
Parameters: - path –
- passphrase –
Raises: GeneralSecurityException
-
registerDevice
(hardwareId, metaData: dict, deviceModels, restricted=False)¶ Register an indirectly-connected device with the cloud service and specify whether the gateway device is required to have the appropriate credentials for activating the indirectly-connected device.
The restricted parameter controls whether or not the client library is required to supply credentials for activating the indirectly-connected device. The client library will always supply credentials for an indirectly-connected device whose trusted assets have been provisioned to the client. If, however, the trusted assets of the indirectly-connected device have not been provisioned to the client, the client library can create credentials that attempt to restrict the indirectly connected device to this gateway device.
Pass True for the restricted parameter to ensure the indirectly-connected device cannot be activated by this gateway device without presenting credentials. If restricted is True, the client library will provide credentials to the server. The server will reject the activation request if the indirectly connected device is not allowed to roam to this gateway device.
Pass False to allow the indirectly-connected device to be activated without presenting credentials if the trusted assets of the indirectly-connected device have not been provisioned to the client. If restricted is False, the client library will provide credentials if, and only if, the credentials have been provisioned to the client. The server will reject the activation if credentials are required but not supplied, or if the provisioned credentials do not allow the indirectly connected device to roam to this gateway device.
The hardwareId is a unique identifier within the cloud service instance and may not be None. If one is not present for the device, it should be generated based on other metadata such as: model, manufacturer, serial number, etc.
The metaData Dictionary should typically contain all the standard metadata (the constants documented in this class) along with any other vendor defined metadata.
Parameters: - restricted – indicate whether or not credentials are required for activating the indirectly connected device
- hardwareId – an identifier unique within the Cloud Service instance
- metaData – The metadata of the device
- deviceModels – should contain the device model type URNs supported by the indirectly connected device. The {:code deviceModels} parameter is one or more, comma separated, device model URNs.
Returns: The endpoint id of the indirectly-connected device
Raise: IOError if the message could not be sent
Raise: ValueError when key or signature algorithm class cannot be loaded, or the key is not in the trusted assets store, or the private key is invalid or if hardwareId is None, or deviceModels is None or zero length