forked from rdkcentral/rdkservices
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ControlService & SystemServices
- Loading branch information
Showing
24 changed files
with
7,685 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# If not stated otherwise in this file or this component's license file the | ||
# following copyright and licenses apply: | ||
# | ||
# Copyright 2020 RDK Management | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set(PLUGIN_NAME ControlService) | ||
set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) | ||
|
||
find_package(${NAMESPACE}Plugins REQUIRED) | ||
|
||
add_subdirectory(test) | ||
|
||
add_library(${MODULE_NAME} SHARED | ||
ControlService.cpp | ||
Module.cpp) | ||
|
||
set_target_properties(${MODULE_NAME} PROPERTIES | ||
CXX_STANDARD 11 | ||
CXX_STANDARD_REQUIRED YES) | ||
|
||
target_include_directories(${MODULE_NAME} PRIVATE ../helpers) | ||
|
||
find_package(CTRLM) | ||
if (CTRLM_FOUND) | ||
add_definitions(-DCTRLM_FOUND) | ||
target_include_directories(${MODULE_NAME} PRIVATE ${CTRLM_INCLUDE_DIRS}) | ||
find_package(IARMBus) | ||
target_include_directories(${MODULE_NAME} PRIVATE ${IARMBUS_INCLUDE_DIRS}) | ||
find_package(IRMGR) | ||
target_include_directories(${MODULE_NAME} PRIVATE ${IRMGR_INCLUDE_DIRS}) | ||
target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${IARMBUS_LIBRARIES}) | ||
else (CTRLM_FOUND) | ||
target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins) | ||
endif(CTRLM_FOUND) | ||
|
||
install(TARGETS ${MODULE_NAME} | ||
DESTINATION lib/${STORAGE_DIRECTORY}/plugins) | ||
|
||
write_config(${PLUGIN_NAME}) |
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,3 @@ | ||
set (autostart true) | ||
set (preconditions Platform) | ||
set (callsign "org.rdk.ControlService") |
Large diffs are not rendered by default.
Oops, something went wrong.
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,174 @@ | ||
/** | ||
* If not stated otherwise in this file or this component's LICENSE | ||
* file the following copyright and licenses apply: | ||
* | ||
* Copyright 2020 RDK Management | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
**/ | ||
|
||
#pragma once | ||
|
||
#include "Module.h" | ||
#include "utils.h" | ||
#include "AbstractPlugin.h" | ||
#include "libIBus.h" | ||
|
||
#include "ctrlm_ipc.h" | ||
#include "ctrlm_ipc_rcu.h" | ||
#include "ctrlm_ipc_key_codes.h" | ||
|
||
#include <mutex> | ||
|
||
#define IARM_CONTROLSERVICE_PLUGIN_NAME "Control_Service" | ||
|
||
// Substitute for the old AbstractService Status enumeration | ||
typedef enum { | ||
STATUS_OK = 0, | ||
STATUS_FAILURE, | ||
STATUS_INVALID_ARGUMENT, | ||
STATUS_INVALID_STATE, | ||
STATUS_METHOD_NOT_FOUND | ||
} StatusCode; | ||
|
||
namespace WPEFramework { | ||
|
||
namespace Plugin { | ||
|
||
// Class to aid in 3-digit validation during pairing | ||
class threeDigits | ||
{ | ||
public: | ||
threeDigits() { clear(); } | ||
void clear() { digit1 = digit2 = digit3 = -1; } | ||
int size() | ||
{ | ||
int size = 0; | ||
if (digit1 > -1) size++; | ||
if (digit2 > -1) size++; | ||
if (digit3 > -1) size++; | ||
return size; | ||
} | ||
int digit1; | ||
int digit2; | ||
int digit3; | ||
}; | ||
|
||
// This is a server for a JSONRPC communication channel. | ||
// For a plugin to be capable to handle JSONRPC, inherit from PluginHost::JSONRPC. | ||
// By inheriting from this class, the plugin realizes the interface PluginHost::IDispatcher. | ||
// This realization of this interface implements, by default, the following methods on this plugin | ||
// - exists | ||
// - register | ||
// - unregister | ||
// Any other method to be handled by this plugin can be added can be added by using the | ||
// templated methods Register on the PluginHost::JSONRPC class. | ||
// As the registration/unregistration of notifications is realized by the class PluginHost::JSONRPC, | ||
// this class exposes a public method called, Notify(), using this methods, all subscribed clients | ||
// will receive a JSONRPC message as a notification, in case this method is called. | ||
// Note that most of the above is now inherited from the AbstractPlugin class. | ||
class ControlService : public AbstractPlugin { | ||
private: | ||
typedef Core::JSON::String JString; | ||
typedef Core::JSON::ArrayType<JString> JStringArray; | ||
typedef Core::JSON::ArrayType<JsonObject> JObjectArray; | ||
typedef Core::JSON::Boolean JBool; | ||
|
||
// We do not allow this plugin to be copied !! | ||
ControlService(const ControlService&) = delete; | ||
ControlService& operator=(const ControlService&) = delete; | ||
|
||
//Begin methods | ||
uint32_t getApiVersionNumber(const JsonObject& parameters, JsonObject& response); | ||
|
||
uint32_t getAllRemoteDataWrapper(const JsonObject& parameters, JsonObject& response); | ||
uint32_t getSingleRemoteDataWrapper(const JsonObject& parameters, JsonObject& response); | ||
uint32_t getLastKeypressSourceWrapper(const JsonObject& parameters, JsonObject& response); | ||
uint32_t getLastPairedRemoteDataWrapper(const JsonObject& parameters, JsonObject& response); | ||
uint32_t setValuesWrapper(const JsonObject& parameters, JsonObject& response); | ||
uint32_t getValuesWrapper(const JsonObject& parameters, JsonObject& response); | ||
uint32_t startPairingModeWrapper(const JsonObject& parameters, JsonObject& response); | ||
uint32_t endPairingModeWrapper(const JsonObject& parameters, JsonObject& response); | ||
uint32_t findMyRemoteWrapper(const JsonObject& parameters, JsonObject& response); | ||
//End methods | ||
|
||
//Begin events | ||
void onControl(int remoteId, int keyCode, string& source, string& type, string& data); | ||
void onXRPairingStart(int remoteId, char* remoteType, int bindingType, threeDigits& validationDigits); | ||
void onXRValidationUpdate(int remoteId, char* remoteType, int bindingType, threeDigits& validationDigits); | ||
void onXRValidationComplete(int remoteId, char* remoteType, int bindingType, int validationStatus); | ||
void onXRConfigurationComplete(int remoteId, char* remoteType, int bindingType, int configurationStatus); | ||
//End events | ||
|
||
public: | ||
ControlService(); | ||
virtual ~ControlService(); | ||
//IPlugin methods | ||
virtual const string Initialize(PluginHost::IShell* service) override; | ||
virtual void Deinitialize(PluginHost::IShell* service) override; | ||
private: | ||
void InitializeIARM(); | ||
void DeinitializeIARM(); | ||
// Handlers for IARM events | ||
static void controlEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); | ||
void iarmEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); | ||
void irmgrHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); | ||
void ctrlmHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); | ||
void pairingHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); | ||
|
||
// Underlying private implementations for public wrapper methods | ||
StatusCode getAllRemoteData(JsonObject& response); | ||
StatusCode getSingleRemoteData(JsonObject& remoteInfo, int remoteId); | ||
StatusCode getLastPairedRemoteData(JsonObject& remoteInfo); | ||
StatusCode getLastKeypressSource(JsonObject& keypressInfo); | ||
StatusCode setValues(const JsonObject& parameters); | ||
StatusCode getValues(JsonObject& settings); | ||
StatusCode startPairingMode(int mode, int restrictions); | ||
StatusCode endPairingMode(int& bindStatus); | ||
StatusCode findMyRemote(int remoteId); | ||
|
||
// Local utility methods | ||
void setApiVersionNumber(uint32_t apiVersionNumber); | ||
int numericCtrlm2Int(ctrlm_key_code_t ctrlm_key); | ||
|
||
char* getRemoteModel(char *remoteType); | ||
char* getRemoteModelVersion(char *remoteType); | ||
const char* getPairingType(ctrlm_rcu_binding_type_t pairingType); | ||
|
||
bool getIrRemoteUsage(ctrlm_main_iarm_call_ir_remote_usage_t& irRemoteUsage); | ||
|
||
bool getRf4ceNetworkId(ctrlm_network_id_t& rf4ceId); | ||
bool getRf4ceNetworkStatus(ctrlm_main_iarm_call_network_status_t& netStatus); | ||
|
||
bool getRf4ceStbData(JsonObject& stbData); | ||
bool getRf4ceBindRemote(JsonObject& remoteInfo, ctrlm_rcu_iarm_call_controller_status_t& ctrlStatus); | ||
bool getAllRf4ceBindRemotes(void); | ||
bool getLastPairedRf4ceBindRemote(JsonObject& remoteInfo); | ||
|
||
public: | ||
static ControlService* _instance; | ||
private: | ||
uint32_t m_apiVersionNumber; | ||
bool m_hasOwnProcess; | ||
|
||
JsonObject m_remoteInfo[CTRLM_MAIN_MAX_BOUND_CONTROLLERS]; | ||
int m_numOfBindRemotes; | ||
|
||
std::mutex m_callMutex; | ||
|
||
// Used to remember the "golden" and "entered" digits, during 3-digit manual pairing validation | ||
threeDigits m_goldenValDigits; | ||
threeDigits m_enteredValDigits; | ||
}; | ||
} // namespace Plugin | ||
} // namespace WPEFramework |
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,22 @@ | ||
/** | ||
* If not stated otherwise in this file or this component's LICENSE | ||
* file the following copyright and licenses apply: | ||
* | ||
* Copyright 2020 RDK Management | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
**/ | ||
|
||
#include "Module.h" | ||
|
||
MODULE_NAME_DECLARATION(BUILD_REFERENCE) |
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,29 @@ | ||
/** | ||
* If not stated otherwise in this file or this component's LICENSE | ||
* file the following copyright and licenses apply: | ||
* | ||
* Copyright 2020 RDK Management | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
**/ | ||
|
||
#pragma once | ||
#ifndef MODULE_NAME | ||
#define MODULE_NAME VrexManager | ||
#endif | ||
|
||
#include <plugins/plugins.h> | ||
#include <tracing/tracing.h> | ||
|
||
#undef EXTERNAL | ||
#define EXTERNAL |
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,42 @@ | ||
----------------- | ||
Build: | ||
|
||
bitbake thunder-plugins | ||
|
||
----------------- | ||
Test: | ||
|
||
|
||
Methods common to typical plugins - getQuirks() and getApiVersionNumber() (not documented in official ControlService API) | ||
curl --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","id":"3","method": "org.rdk.ControlService.1.getQuirks"}' http://127.0.0.1:9998/jsonrpc | ||
|
||
curl -d '{"jsonrpc":"2.0","id":"4","method":"org.rdk.ControlService.1.getApiVersionNumber"}' http://127.0.0.1:9998/jsonrpc | ||
|
||
|
||
A couple of example setValue() method calls | ||
curl -d '{"jsonrpc":"2.0","id":"5","method":"org.rdk.ControlService.1.setValues","params": {"enableASB":"true","conversationalMode" : 3}}' http://127.0.0.1:9998/jsonrpc | ||
|
||
curl -d '{"jsonrpc":"2.0","id":"6","method":"org.rdk.ControlService.1.setValues","params": {"enableOpenChime": true,"chimeVolume" : 2}}' http://127.0.0.1:9998/jsonrpc | ||
|
||
|
||
An example getValues() method call (takes no parameters) | ||
curl -d '{"jsonrpc":"2.0","id":"7","method":"org.rdk.ControlService.1.getValues"}' http://127.0.0.1:9998/jsonrpc | ||
|
||
|
||
An example getLastKeypressSource() method call (takes no parameters) | ||
curl -d '{"jsonrpc":"2.0","id":"8","method":"org.rdk.ControlService.1.getLastKeypressSource"}' http://127.0.0.1:9998/jsonrpc | ||
|
||
|
||
An example getSingleRemoteData method call, for remoteId 2 | ||
curl -d '{"jsonrpc":"2.0","id":"9","method":"org.rdk.ControlService.1.getSingleRemoteData","params": {"remoteId" : 2}}' http://127.0.0.1:9998/jsonrpc | ||
|
||
|
||
An example getAllRemoteData method call (takes no parameters). If you have many paired XR remotes,the output can be HUGE! | ||
curl -d '{"jsonrpc":"2.0","id":"10","method":"org.rdk.ControlService.1.getAllRemoteData"}' http://127.0.0.1:9998/jsonrpc | ||
|
||
|
||
An example getLastPairedRemoteData() method call (takes no parameters) | ||
curl -d '{"jsonrpc":"2.0","id":"11","method":"org.rdk.ControlService.1.getLastPairedRemoteData"}' http://127.0.0.1:9998/jsonrpc | ||
|
||
|
||
|
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,36 @@ | ||
# If not stated otherwise in this file or this component's license file the | ||
# following copyright and licenses apply: | ||
# | ||
# Copyright 2020 RDK Management | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# - Try to find ControlManager | ||
# Once done this will define | ||
# CTRLM_FOUND - System has ControlManager | ||
# CTRLM_INCLUDE_DIRS - The ControlManager include directories | ||
# | ||
|
||
find_package(PkgConfig) | ||
|
||
find_path(CTRLM_INCLUDE_DIRS NAMES ctrlm_ipc.h) | ||
|
||
set(CTRLM_INCLUDE_DIRS ${CTRLM_INCLUDE_DIRS}) | ||
set(CTRLM_INCLUDE_DIRS ${CTRLM_INCLUDE_DIRS} CACHE PATH "Path to ControlManager include") | ||
|
||
include(FindPackageHandleStandardArgs) | ||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CTRLM DEFAULT_MSG CTRLM_INCLUDE_DIRS) | ||
|
||
mark_as_advanced( | ||
CTRLM_FOUND | ||
CTRLM_INCLUDE_DIRS) |
Oops, something went wrong.