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: wolk_gateway_module.model.message.Message) → str[source]

Extract device key from message.

Parameters:message (Message) – Message received
Returns:device_key
Return type:str
get_inbound_topics_for_device(device_key: str) → List[str][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: wolk_gateway_module.model.message.Message) → bool[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: wolk_gateway_module.model.message.Message) → bool[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: wolk_gateway_module.model.message.Message) → bool[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: wolk_gateway_module.model.message.Message) → bool[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: wolk_gateway_module.model.message.Message) → wolk_gateway_module.model.actuator_command.ActuatorCommand[source]

Make actuator command from message.

Parameters:message (Message) – Message received
Returns:actuator_command
Return type:ActuatorCommand
make_actuator_status_message(device_key: str, actuator_status: wolk_gateway_module.model.actuator_status.ActuatorStatus) → wolk_gateway_module.model.message.Message[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: str, alarm: wolk_gateway_module.model.alarm.Alarm) → wolk_gateway_module.model.message.Message[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: wolk_gateway_module.model.message.Message) → wolk_gateway_module.model.configuration_command.ConfigurationCommand[source]

Make configuration command from message.

Parameters:message (Message) – Message received
Returns:configuration_command
Return type:ConfigurationCommand
make_configuration_message(device_key: str, configuration: Dict[str, Union[int, float, bool, str, Tuple[int, int], Tuple[int, int, int], Tuple[float, float], Tuple[float, float, float], Tuple[str, str], Tuple[str, str, str]]]) → wolk_gateway_module.model.message.Message[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: str, sensor_reading: wolk_gateway_module.model.sensor_reading.SensorReading) → wolk_gateway_module.model.message.Message[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: str, sensor_readings: List[wolk_gateway_module.model.sensor_reading.SensorReading], timestamp: Optional[int] = None) → wolk_gateway_module.model.message.Message[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: wolk_gateway_module.model.message.Message) → str[source]

Return device key from message.

Parameters:message (Message) – Message received
Returns:device_key
Return type:str
get_inbound_topics_for_device(device_key: str) → List[str][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: wolk_gateway_module.model.message.Message) → bool[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: wolk_gateway_module.model.message.Message) → bool[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: wolk_gateway_module.model.message.Message) → str[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: str, status: wolk_gateway_module.model.firmware_update_status.FirmwareUpdateStatus) → wolk_gateway_module.model.message.Message[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: str, firmware_verison: str) → wolk_gateway_module.model.message.Message[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: wolk_gateway_module.model.message.Message) → str[source]

Return device key from message.

Parameters:message (Message) – Message received
Returns:device_key
Return type:str
get_inbound_topics_for_device(device_key: str) → List[str][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: wolk_gateway_module.model.message.Message) → bool[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: wolk_gateway_module.model.device_registration_request.DeviceRegistrationRequest) → wolk_gateway_module.model.message.Message[source]

Make message from device registration request.

Parameters:request (DeviceRegistrationRequest) – Device registration request
Returns:message
Return type:Message
make_registration_response(message: wolk_gateway_module.model.message.Message) → wolk_gateway_module.model.device_registration_response.DeviceRegistrationResponse[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: wolk_gateway_module.model.message.Message) → str[source]

Extract device key from message.

Parameters:message (Message) – Message received
Returns:device_key
Return type:str
get_inbound_topics_for_device(device_key: str) → List[str][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: wolk_gateway_module.model.message.Message) → bool[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: wolk_gateway_module.model.device_status.DeviceStatus, device_key: str) → wolk_gateway_module.model.message.Message[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: wolk_gateway_module.model.device_status.DeviceStatus, device_key: str) → wolk_gateway_module.model.message.Message[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: List[str]) → wolk_gateway_module.model.message.Message[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() → Optional[wolk_gateway_module.model.message.Message][source]

Get the first message from storage without removing it.

Returns:message
Return type:Message, None
get_messages_for_device(device_key: str) → List[wolk_gateway_module.model.message.Message][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: wolk_gateway_module.model.message.Message) → bool[source]

Place a message in storage.

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

Return current number of messages in storage.

Returns:size
Return type:int
remove(message: wolk_gateway_module.model.message.Message) → bool[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: List[str]) → None[source]

Add subscription topics.

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

Establish connection with WolkGateway.

connected() → bool[source]

Return if currently connected.

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

Terminate connection with WolkGateway.

publish(message: wolk_gateway_module.model.message.Message) → bool[source]

Publish serialized data to WolkGateway.

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

Reestablish connection with WolkGateway.

remove_topics_for_device(device_key: str) → None[source]

Remove topics for device from subscription topics.

Parameters:device_key (str) – Device identifier
set_inbound_message_listener(on_inbound_message: Callable[[wolk_gateway_module.model.message.Message], None]) → None[source]

Set the callback function to handle inbound messages.

Parameters:on_inbound_message (Callable[[Message], None]) – Callable that handles inbound messages
set_lastwill_message(message: wolk_gateway_module.model.message.Message) → None[source]

Send offline state for module devices on disconnect.

Parameters:message (Message) – Message to be published