Abstract base classes

Data Protocol

class wolk_gateway_module.protocol.data_protocol.DataProtocol[source]

Parse inbound messages and serialize outbound messages.

extract_key_from_message(message)[source]

Extract device key from message.

Parameters:message (Message) – Message received
Returns:device_key
Return type:str
get_inbound_topics_for_device(device_key)[source]

Return list of inbound topics for given device key.

Parameters:device_key (str) – Device key for which to create topics
Returns:inbound_topics
Return type:list
is_actuator_get_message(message)[source]

Check if message is actuator get command.

Parameters:message (Message) – Message received
Returns:is_actuator_get_message
Return type:bool
is_actuator_set_message(message)[source]

Check if message is actuator set command.

Parameters:message (Message) – Message received
Returns:is_actuator_set_message
Return type:bool
is_configuration_get_message(message)[source]

Check if message is configuration get command.

Parameters:message (Message) – Message received
Returns:is_configuration_get_message
Return type:bool
is_configuration_set_message(message)[source]

Check if message is configuration set command.

Parameters:message (Message) – Message received
Returns:is_configuration_set_message
Return type:bool
make_actuator_command(message)[source]

Make actuator command from message.

Parameters:message (Message) – Message received
Returns:actuator_command
Return type:ActuatorCommand
make_actuator_status_message(device_key, actuator_status)[source]

Make message from actuator status for device key.

Parameters:
  • device_key (str) – Device on which the actuator status occurred
  • actuator_status (ActuatorStatus) – Actuator status data
Returns:

message

Return type:

Message

make_alarm_message(device_key, alarm)[source]

Make message from alarm for device key.

Parameters:
  • device_key (str) – Device on which the alarm occurred
  • alarm (Alarm) – Alarm data
Returns:

message

Return type:

Message

make_configuration_command(message)[source]

Make configuration command from message.

Parameters:message (Message) – Message received
Returns:configuration_command
Return type:ConfigurationCommand
make_configuration_message(device_key, configuration)[source]

Make message from configuration for device key.

Parameters:
  • device_key (str) – Device to which the configuration belongs to.
  • configuration (dict) – Current configuration data
Returns:

message

Return type:

Message

make_sensor_reading_message(device_key, sensor_reading)[source]

Make message from sensor reading for device key.

Parameters:
  • device_key (str) – Device on which the sensor reading occurred
  • sensor_reading (SensorReading) – Sensor reading data
Returns:

message

Return type:

Message

make_sensor_readings_message(device_key, sensor_readings, timestamp=None)[source]

Make message from multiple sensor readings for device key.

Parameters:
  • device_key (str) – Device on which the sensor reading occurred
  • sensor_readings (List[SensorReading]) – List of sensor readings data
  • timestamp (Optional[int]) – Timestamp
Returns:

message

Return type:

Message

Firmware Update Protocol

class wolk_gateway_module.protocol.firmware_update_protocol.FirmwareUpdateProtocol[source]

Parse inbound messages and serialize outbound firmware messages.

extract_key_from_message(message)[source]

Return device key from message.

Parameters:message (Message) – Message received
Returns:device_key
Return type:str
get_inbound_topics_for_device(device_key)[source]

Return list of inbound topics for given device key.

Parameters:device_key (str) – Device key for which to create topics
Returns:inbound_topics
Return type:list
is_firmware_abort_command(message)[source]

Check if received message is firmware abort command.

Parameters:message (Message) – Message received
Returns:is_firmware_abort_command
Return type:bool
is_firmware_install_command(message)[source]

Check if received message is firmware install command.

Parameters:message (Message) – Message received
Returns:is_firmware_install_command
Return type:bool
make_firmware_file_path(message)[source]

Extract file path from firmware install message.

Parameters:message (Message) – Message received
Returns:firmware_file_path
Return type:str
make_update_message(device_key, status)[source]

Make message from device firmware update status.

Parameters:
  • device_key (str) – Device key to which the firmware update belongs to
  • status (FirmwareUpdateStatus) – Device firmware update status
Returns:

message

Return type:

Message

make_version_message(device_key, firmware_verison)[source]

Make message from device firmware update version.

Parameters:
  • device_key (str) – Device key to which the firmware update belongs to
  • firmware_verison (str) – Current firmware version
Returns:

message

Return type:

Message

Registration Protocol

class wolk_gateway_module.protocol.registration_protocol.RegistrationProtocol[source]

Parse inbound messages and serialize outbound registration messages.

extract_key_from_message(message)[source]

Return device key from message.

Parameters:message (Message) – Message received
Returns:device_key
Return type:str
get_inbound_topics_for_device(device_key)[source]

Return list of inbound topics for given device key.

Parameters:device_key (str) – Device key for which to create topics
Returns:inbound_topics
Return type:list
is_registration_response_message(message)[source]

Check if message is device registration response.

Parameters:message (Message) – Message received
Returns:is_device_registration_response
Return type:bool
make_registration_message(request)[source]

Make message from device registration request.

Parameters:request (DeviceRegistrationRequest) – Device registration request
Returns:message
Return type:Message
make_registration_response(message)[source]

Make device registration response from message.

Parameters:message – Message received
Rtpe message:Message
Returns:device_registration_response
Return type:DeviceRegistrationResponse

Status Protocol

class wolk_gateway_module.protocol.status_protocol.StatusProtocol[source]

Parse inbound messages and serialize device status messages.

extract_key_from_message(message)[source]

Extract device key from message.

Parameters:message (Message) – Message received
Returns:device_key
Return type:str
get_inbound_topics_for_device(device_key)[source]

Return list of inbound topics for given device key.

Parameters:device_key (str) – Device key for which to create topics
Returns:inbound_topics
Return type:list
is_device_status_request_message(message)[source]

Check if message is device status request.

Parameters:message (Message) – Message received
Returns:is_device_status_request
Return type:bool
make_device_status_response_message(device_status, device_key)[source]

Make message from device status response.

Parameters:
  • device_status (DeviceStatus) – Device’s current status
  • device_key (str) – Device to which the status belongs to
Returns:

message

Return type:

Message

make_device_status_update_message(device_status, device_key)[source]

Make message from device status update.

Parameters:
  • device_status (DeviceStatus) – Device’s current status
  • device_key (str) – Device to which the status belongs to
Returns:

message

Return type:

Message

make_last_will_message(device_keys)[source]

Make last will message from list of device keys.

Parameters:device_keys (list(str)) – List of device keys
Returns:message
Return type:Message

Outbound Message Queue

class wolk_gateway_module.persistence.outbound_message_queue.OutboundMessageQueue[source]

Responsible for storing messages before being sent to WolkGateway.

get()[source]

Get the first message from storage without removing it.

Returns:message
Return type:Message, None
get_messages_for_device(device_key)[source]

Return a list of messages that belong to a certain device.

Does not remove from storage.

Parameters:device_key (str) – Device identifier
Returns:messages
Return type:List[Message]
put(message)[source]

Place a message in storage.

Parameters:message (Message) – Message to be stored
Returns:result
Return type:bool
queue_size()[source]

Return current number of messages in storage.

Returns:size
Return type:int
remove(message)[source]

Remove specific message from storage.

Returns:result
Return type:bool

Connectivity Service

class wolk_gateway_module.connectivity.connectivity_service.ConnectivityService[source]

Responsible for exchanging data with WolkGateway.

add_subscription_topics(topics)[source]

Add subscription topics.

Parameters:topics (List[str]) – List of topics
connect()[source]

Establish connection with WolkGateway.

connected()[source]

Return if currently connected.

Returns:connected
Return type:bool
disconnect()[source]

Terminate connection with WolkGateway.

publish(message)[source]

Publish serialized data to WolkGateway.

Parameters:message (Message) – Message to be published
Returns:result
Return type:bool
reconnect()[source]

Reestablish connection with WolkGateway.

remove_topics_for_device(device_key)[source]

Remove topics for device from subscription topics.

Parameters:device_key (str) – Device identifier
set_inbound_message_listener(on_inbound_message)[source]

Set the callback function to handle inbound messages.

Parameters:on_inbound_message (Callable[[str], None]) – Callable that handles inbound messages
set_lastwill_message(message)[source]

Send offline state for module devices on disconnect.

Parameters:message (Message) – Message to be published