-
Notifications
You must be signed in to change notification settings - Fork 46
Support for sink provisioning #305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2fbbdcd
721772b
5304d1c
3b24a19
f711a7b
18084e0
ff50011
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +0,0 @@ | ||
| [submodule "sink_service/c-mesh-api"] | ||
| path = sink_service/c-mesh-api | ||
| url = https://github.com/wirepas/c-mesh-api | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| # wirepas | ||
| wirepas_mesh_messaging==1.3.0rc1 | ||
| wirepas_mesh_messaging==1.3.0rc3 | ||
|
|
||
| # dbus bindings | ||
| pydbus==0.6.0 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -229,8 +229,7 @@ def _set_param(self, dic, key, attribute): | |
| # Exception raised when setting attribute | ||
| error = ReturnCode.error_from_dbus_exception(str(e)) | ||
| logging.error( | ||
| "Cannot set %s for param %s on sink %s: %s (%s)", | ||
| value, | ||
| "Cannot set param %s on sink %s: %s (%s)", | ||
| key, | ||
| self.sink_id, | ||
| error.name, | ||
|
|
@@ -241,12 +240,54 @@ def _set_param(self, dic, key, attribute): | |
| except OverflowError: | ||
| # It may happens as protobuf has bigger container value | ||
| logging.error( | ||
| "Invalid range value for param %s with value %s", key, value | ||
| "Invalid range value for param %s", key | ||
| ) | ||
| return wmm.GatewayResultCode.GW_RES_INVALID_PARAM | ||
|
|
||
| return wmm.GatewayResultCode.GW_RES_OK | ||
|
|
||
| def _set_network_keys(self, config): | ||
| if "network_keys" in config: | ||
| try: | ||
| cipher = config["network_keys"]["cipher"] | ||
| auth = config["network_keys"]["authentication"] | ||
| seq = config["network_keys"]["sequence"] | ||
| logging.info(f"Setting network security keys with sequence {seq}") | ||
| self.proxy.SetNetworkSecurityKeys(cipher, auth, seq) | ||
| except GLib.Error as e: | ||
| error_code = ReturnCode.error_from_dbus_exception(str(e)) | ||
| logging.error("Error when setting network keys: %s", error_code.name) | ||
| return error_code | ||
| except OverflowError: | ||
| logging.error("Invalid sequence when setting network keys") | ||
| return wmm.GatewayResultCode.GW_RES_INVALID_PARAM | ||
| except Exception: | ||
| logging.exception("Unknown error when setting network keys") | ||
| return wmm.GatewayResultCode.GW_RES_INTERNAL_ERROR | ||
|
|
||
| return wmm.GatewayResultCode.GW_RES_OK | ||
|
|
||
| def _set_management_keys(self, config): | ||
| if "management_keys" in config: | ||
| try: | ||
| cipher = config["management_keys"]["cipher"] | ||
| auth = config["management_keys"]["authentication"] | ||
| seq = config["management_keys"]["sequence"] | ||
| logging.info(f"Setting management security keys with sequence {seq}") | ||
| self.proxy.SetManagementSecurityKeys(cipher, auth, seq) | ||
| except GLib.Error as e: | ||
| error_code = ReturnCode.error_from_dbus_exception(str(e)) | ||
| logging.error("Error when setting management keys: %s", error_code.name) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (88 > 79 characters) |
||
| return error_code | ||
| except OverflowError: | ||
| logging.error("Invalid sequence when setting management keys") | ||
| return wmm.GatewayResultCode.GW_RES_INVALID_PARAM | ||
| except Exception: | ||
| logging.exception("Unknown error when setting management keys") | ||
| return wmm.GatewayResultCode.GW_RES_INTERNAL_ERROR | ||
|
|
||
| return wmm.GatewayResultCode.GW_RES_OK | ||
|
|
||
| def write_config(self, config): | ||
| # Force the node address if used | ||
| try: | ||
|
|
@@ -296,11 +337,11 @@ def write_config(self, config): | |
| diag = config["app_config_diag"] | ||
| data = config["app_config_data"] | ||
|
|
||
| logging.info("Set app config with %s", config) | ||
| logging.info(f"Set app config with seq: {seq}, diag: {diag}, data: {data}") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (87 > 79 characters) |
||
| self.proxy.SetAppConfig(seq, diag, data) | ||
| except KeyError: | ||
| # App config not defined in new config | ||
| logging.debug("Missing key app_config key in config: %s", config) | ||
| logging.debug("Missing app config related key in config; will not set app config") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (94 > 79 characters) |
||
| except GLib.Error as e: | ||
| res = ReturnCode.error_from_dbus_exception(str(e)) | ||
| logging.error("Cannot set App Config: %s", res.name) | ||
|
|
@@ -309,6 +350,14 @@ def write_config(self, config): | |
| res = wmm.GatewayResultCode.GW_RES_INVALID_PARAM | ||
| logging.error("Invalid range value") | ||
|
|
||
| res_network_keys = self._set_network_keys(config) | ||
| if res_network_keys != wmm.GatewayResultCode.GW_RES_OK: | ||
| res = res_network_keys | ||
|
|
||
| res_management_keys = self._set_management_keys(config) | ||
| if res_management_keys != wmm.GatewayResultCode.GW_RES_OK: | ||
| res = res_management_keys | ||
|
|
||
| # Set stack in state defined by new config or set it as it was | ||
| # previously | ||
| try: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| cmake_minimum_required(VERSION 3.18) | ||
|
|
||
| project(sinkService LANGUAGES C) | ||
|
|
||
| set(CMAKE_C_STANDARD 99) | ||
| if(NOT CMAKE_BUILD_TYPE) | ||
| set(CMAKE_BUILD_TYPE RelWithDebInfo) | ||
| endif() | ||
| set(CMAKE_C_FLAGS_RELEASE "-O2") | ||
|
|
||
| add_compile_options(-Wall -Werror -Wextra -Wno-unused-parameter) | ||
|
|
||
| include(FetchContent) | ||
| FetchContent_Declare( | ||
| c-mesh-api | ||
| GIT_REPOSITORY https://github.com/wirepas/c-mesh-api/ | ||
| GIT_TAG c566fdbd693eb3fb6027286679f53db9f9958e0a | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder whether this should be extracted from here to some "config" file? Also should we use some explicit tags instead of commit hashes?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think tags would be good too. There are some tags/releases for c-mesh-api from the past(2022) which were using the same version as gateway. I don't know if there would be an advantage to use the same version numbers, but we can start creating releases for c-mesh-api again. |
||
| SOURCE_SUBDIR lib | ||
| ) | ||
| FetchContent_MakeAvailable(c-mesh-api) | ||
|
|
||
| find_package(PkgConfig REQUIRED) | ||
| pkg_check_modules(systemd REQUIRED IMPORTED_TARGET libsystemd) | ||
|
|
||
| add_executable(${CMAKE_PROJECT_NAME} | ||
| source/main.c | ||
| source/config.c | ||
| source/data.c | ||
| source/otap.c | ||
| ) | ||
|
|
||
| target_link_libraries(${CMAKE_PROJECT_NAME} wpc PkgConfig::systemd) | ||
|
|
||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.