-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from JPHutchins/feature/more-groups
Feature/more groups
- Loading branch information
Showing
7 changed files
with
596 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
"""The Simple Management Protocol (SMP) Settings Management group.""" | ||
|
||
from __future__ import annotations | ||
|
||
from enum import IntEnum, unique | ||
|
||
import smp.error as smperr | ||
import smp.header as smphdr | ||
import smp.message as smpmsg | ||
|
||
|
||
class ReadSettingRequest(smpmsg.ReadRequest): | ||
"""Read setting.""" | ||
|
||
_GROUP_ID = smphdr.GroupId.SETTINGS_MANAGEMENT | ||
_COMMAND_ID = smphdr.CommandId.SettingsManagement.READ_WRITE_SETTING | ||
|
||
name: str | ||
"""The name of the setting to read.""" | ||
|
||
max_size: int | None = None | ||
"""The maximum size of the data to read.""" | ||
|
||
|
||
class ReadSettingResponse(smpmsg.ReadResponse): | ||
"""Read setting success response.""" | ||
|
||
_GROUP_ID = smphdr.GroupId.SETTINGS_MANAGEMENT | ||
_COMMAND_ID = smphdr.CommandId.SettingsManagement.READ_WRITE_SETTING | ||
|
||
val: bytes | ||
"""Binary string of the returned data. | ||
Note that the underlying data type cannot be specified through this and must | ||
be known by the client. | ||
""" | ||
|
||
max_size: int | None = None | ||
"""The SMP server supports a smaller size than requested. | ||
Will be set if the maximum supported data size is smaller than the maximum | ||
requested data size, and contains the maximum data size which the device | ||
supports, equivalent to `CONFIG_MCUMGR_GRP_SETTINGS_NAME_LEN`. | ||
""" | ||
|
||
|
||
class WriteSettingRequest(smpmsg.WriteRequest): | ||
"""Write setting.""" | ||
|
||
_GROUP_ID = smphdr.GroupId.SETTINGS_MANAGEMENT | ||
_COMMAND_ID = smphdr.CommandId.SettingsManagement.READ_WRITE_SETTING | ||
|
||
name: str | ||
"""The name of the setting to write.""" | ||
|
||
val: bytes | ||
"""Binary data to write.""" | ||
|
||
|
||
class WriteSettingResponse(smpmsg.WriteResponse): | ||
"""Write setting success response.""" | ||
|
||
_GROUP_ID = smphdr.GroupId.SETTINGS_MANAGEMENT | ||
_COMMAND_ID = smphdr.CommandId.SettingsManagement.READ_WRITE_SETTING | ||
|
||
|
||
class DeleteSettingRequest(smpmsg.WriteRequest): | ||
"""Delete setting.""" | ||
|
||
_GROUP_ID = smphdr.GroupId.SETTINGS_MANAGEMENT | ||
_COMMAND_ID = smphdr.CommandId.SettingsManagement.DELETE_SETTING | ||
|
||
name: str | ||
"""The name of the setting to delete.""" | ||
|
||
|
||
class DeleteSettingResponse(smpmsg.WriteResponse): | ||
"""Delete setting success response.""" | ||
|
||
_GROUP_ID = smphdr.GroupId.SETTINGS_MANAGEMENT | ||
_COMMAND_ID = smphdr.CommandId.SettingsManagement.DELETE_SETTING | ||
|
||
|
||
class CommitSettingsRequest(smpmsg.WriteRequest): | ||
"""Commit pending settings. | ||
Commit settings command allows committing all settings that have been set | ||
but not yet applied on a device. | ||
""" | ||
|
||
_GROUP_ID = smphdr.GroupId.SETTINGS_MANAGEMENT | ||
_COMMAND_ID = smphdr.CommandId.SettingsManagement.COMMIT_SETTINGS | ||
|
||
|
||
class CommitSettingsResponse(smpmsg.WriteResponse): | ||
"""Commit pending settings success response.""" | ||
|
||
_GROUP_ID = smphdr.GroupId.SETTINGS_MANAGEMENT | ||
_COMMAND_ID = smphdr.CommandId.SettingsManagement.COMMIT_SETTINGS | ||
|
||
|
||
class LoadSettingsRequest(smpmsg.ReadRequest): | ||
"""Load settings from persistent storage.""" | ||
|
||
_GROUP_ID = smphdr.GroupId.SETTINGS_MANAGEMENT | ||
_COMMAND_ID = smphdr.CommandId.SettingsManagement.LOAD_SAVE_SETTINGS | ||
|
||
|
||
class LoadSettingsResponse(smpmsg.ReadResponse): | ||
"""Load settings from persistent storage success response.""" | ||
|
||
_GROUP_ID = smphdr.GroupId.SETTINGS_MANAGEMENT | ||
_COMMAND_ID = smphdr.CommandId.SettingsManagement.LOAD_SAVE_SETTINGS | ||
|
||
|
||
class SaveSettingsRequest(smpmsg.WriteRequest): | ||
"""Save settings to persistent storage.""" | ||
|
||
_GROUP_ID = smphdr.GroupId.SETTINGS_MANAGEMENT | ||
_COMMAND_ID = smphdr.CommandId.SettingsManagement.LOAD_SAVE_SETTINGS | ||
|
||
|
||
class SaveSettingsResponse(smpmsg.WriteResponse): | ||
"""Save settings to persistent storage success response.""" | ||
|
||
_GROUP_ID = smphdr.GroupId.SETTINGS_MANAGEMENT | ||
_COMMAND_ID = smphdr.CommandId.SettingsManagement.LOAD_SAVE_SETTINGS | ||
|
||
|
||
@unique | ||
class SETTINGS_MGMT_ERR(IntEnum): | ||
OK = 0 | ||
"""No error, this is implied if there is no ret value in the response.""" | ||
|
||
UNKNOWN = 1 | ||
"""Unknown error occurred.""" | ||
|
||
KEY_TOO_LONG = 2 | ||
"""The provided key name is too long to be used.""" | ||
|
||
KEY_NOT_FOUND = 3 | ||
"""The provided key name does not exist.""" | ||
|
||
READ_NOT_SUPPORTED = 4 | ||
"""The provided key name does not support being read.""" | ||
|
||
ROOT_KEY_NOT_FOUND = 5 | ||
"""The provided root key name does not exist.""" | ||
|
||
WRITE_NOT_SUPPORTED = 6 | ||
"""The provided key name does not support being written.""" | ||
|
||
DELETE_NOT_SUPPORTED = 7 | ||
"""The provided key name does not support being deleted.""" | ||
|
||
|
||
class SettingsManagementErrorV1(smperr.ErrorV1): | ||
_GROUP_ID = smphdr.GroupId.SETTINGS_MANAGEMENT | ||
|
||
|
||
class SettingsManagementErrorV2(smperr.ErrorV2[SETTINGS_MGMT_ERR]): | ||
_GROUP_ID = smphdr.GroupId.SETTINGS_MANAGEMENT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
"""The Simple Management Protocol (SMP) Statistics Management group.""" | ||
|
||
|
||
from enum import IntEnum, unique | ||
from typing import Dict, Tuple | ||
|
||
import smp.error as smperr | ||
import smp.header as smphdr | ||
import smp.message as smpmsg | ||
|
||
|
||
class GroupDataRequest(smpmsg.ReadRequest): | ||
_GROUP_ID = smphdr.GroupId.STATISTICS_MANAGEMENT | ||
_COMMAND_ID = smphdr.CommandId.StatisticsManagement.GROUP_DATA | ||
|
||
name: str | ||
|
||
|
||
class GroupDataResponse(smpmsg.ReadResponse): | ||
_GROUP_ID = smphdr.GroupId.STATISTICS_MANAGEMENT | ||
_COMMAND_ID = smphdr.CommandId.StatisticsManagement.GROUP_DATA | ||
|
||
name: str | ||
fields: Dict[str, int] | ||
|
||
|
||
class ListOfGroupsRequest(smpmsg.ReadRequest): | ||
_GROUP_ID = smphdr.GroupId.STATISTICS_MANAGEMENT | ||
_COMMAND_ID = smphdr.CommandId.StatisticsManagement.LIST_OF_GROUPS | ||
|
||
|
||
class ListOfGroupsResponse(smpmsg.ReadResponse): | ||
_GROUP_ID = smphdr.GroupId.STATISTICS_MANAGEMENT | ||
_COMMAND_ID = smphdr.CommandId.StatisticsManagement.LIST_OF_GROUPS | ||
|
||
stat_list: Tuple[str, ...] | ||
|
||
|
||
@unique | ||
class STAT_MGMT_ERR(IntEnum): | ||
OK = 0 | ||
"""No error, this is implied if there is no ret value in the response.""" | ||
|
||
UNKNOWN = 1 | ||
"""Unknown error occurred.""" | ||
|
||
ERR_INVALID_GROUP = 2 | ||
"""The provided statistic group name was not found.""" | ||
|
||
ERR_INVALID_STAT_NAME = 3 | ||
"""The provided statistic name was not found.""" | ||
|
||
ERR_INVALID_STAT_SIZE = 4 | ||
"""The size of the statistic cannot be handled.""" | ||
|
||
ERR_WALK_ABORTED = 5 | ||
"""Walk through of statistics was aborted.""" | ||
|
||
|
||
class StatisticsManagementErrorV1(smperr.ErrorV1): | ||
_GROUP_ID = smphdr.GroupId.STATISTICS_MANAGEMENT | ||
|
||
|
||
class StatisticsManagementErrorV2(smperr.ErrorV2[STAT_MGMT_ERR]): | ||
_GROUP_ID = smphdr.GroupId.STATISTICS_MANAGEMENT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""The Simple Management Protocol (SMP) Zephyr Management group.""" | ||
|
||
|
||
from enum import IntEnum, unique | ||
|
||
import smp.error as smperr | ||
import smp.header as smphdr | ||
import smp.message as smpmsg | ||
|
||
|
||
class EraseStorageRequest(smpmsg.WriteRequest): | ||
_GROUP_ID = smphdr.GroupId.ZEPHYR_MANAGEMENT | ||
_COMMAND_ID = smphdr.CommandId.ZephyrManagement.ERASE_STORAGE | ||
|
||
|
||
class EraseStorageResponse(smpmsg.WriteResponse): | ||
_GROUP_ID = smphdr.GroupId.ZEPHYR_MANAGEMENT | ||
_COMMAND_ID = smphdr.CommandId.ZephyrManagement.ERASE_STORAGE | ||
|
||
|
||
@unique | ||
class ZEPHYRBASIC_MGMT_ERR(IntEnum): | ||
OK = 0 | ||
"""No error, this is implied if there is no ret value in the response""" | ||
|
||
UNKNOWN = 1 | ||
"""Unknown error occurred.""" | ||
|
||
FLASH_OPEN_FAILED = 2 | ||
"""Opening of the flash area has failed.""" | ||
|
||
FLASH_CONFIG_QUERY_FAIL = 3 | ||
"""Querying the flash area parameters has failed.""" | ||
|
||
FLASH_ERASE_FAILED = 4 | ||
"""Erasing the flash area has failed.""" | ||
|
||
|
||
class ZephyrManagementErrorV1(smperr.ErrorV1): | ||
_GROUP_ID = smphdr.GroupId.ZEPHYR_MANAGEMENT | ||
|
||
|
||
class ZephyrManagementErrorV2(smperr.ErrorV2[ZEPHYRBASIC_MGMT_ERR]): | ||
_GROUP_ID = smphdr.GroupId.ZEPHYR_MANAGEMENT |
Oops, something went wrong.