Skip to content

Commit ed36b23

Browse files
authored
RDKEMW-4309 : Modify Remote Control plugin for RF4CE support (#6323)
* Adding first changes * Adding md update * updating legacy control service * reverting this file * Remove netType parameter
1 parent cc82612 commit ed36b23

File tree

4 files changed

+236
-23
lines changed

4 files changed

+236
-23
lines changed

RemoteControl/RemoteControl.cpp

Lines changed: 68 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
using namespace std;
3434

3535
#define API_VERSION_NUMBER_MAJOR 1
36-
#define API_VERSION_NUMBER_MINOR 4
37-
#define API_VERSION_NUMBER_PATCH 1
36+
#define API_VERSION_NUMBER_MINOR 5
37+
#define API_VERSION_NUMBER_PATCH 0
3838

3939
namespace WPEFramework {
4040

@@ -66,6 +66,7 @@ namespace WPEFramework {
6666

6767
Register("getApiVersionNumber", &RemoteControl::getApiVersionNumber, this);
6868
Register("startPairing", &RemoteControl::startPairing, this);
69+
Register("stopPairing", &RemoteControl::stopPairing, this);
6970
Register("getNetStatus", &RemoteControl::getNetStatus, this);
7071
Register("getIRDBManufacturers", &RemoteControl::getIRDBManufacturers, this);
7172
Register("getIRDBModels", &RemoteControl::getIRDBModels, this);
@@ -114,9 +115,7 @@ namespace WPEFramework {
114115
IARM_CHECK( IARM_Bus_RegisterEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_RCU_STATUS, remoteEventHandler) );
115116
IARM_CHECK( IARM_Bus_RegisterEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_FIRMWARE_UPDATE_PROGRESS, remoteEventHandler) );
116117
// Register for ControlMgr pairing-related events
117-
IARM_CHECK( IARM_Bus_RegisterEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_VALIDATION_BEGIN, remoteEventHandler) );
118-
IARM_CHECK( IARM_Bus_RegisterEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_VALIDATION_KEY_PRESS, remoteEventHandler) );
119-
IARM_CHECK( IARM_Bus_RegisterEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_VALIDATION_END, remoteEventHandler) );
118+
IARM_CHECK( IARM_Bus_RegisterEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_VALIDATION_STATUS, remoteEventHandler) );
120119
IARM_CHECK( IARM_Bus_RegisterEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_CONFIGURATION_COMPLETE, remoteEventHandler) );
121120
IARM_CHECK( IARM_Bus_RegisterEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_RF4CE_PAIRING_WINDOW_TIMEOUT, remoteEventHandler) );
122121
}
@@ -132,9 +131,7 @@ namespace WPEFramework {
132131
IARM_Result_t res;
133132
IARM_CHECK( IARM_Bus_RemoveEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_RCU_STATUS, remoteEventHandler) );
134133
// Remove handlers for ControlMgr pairing-related events
135-
IARM_CHECK( IARM_Bus_RemoveEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_VALIDATION_BEGIN, remoteEventHandler) );
136-
IARM_CHECK( IARM_Bus_RemoveEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_VALIDATION_KEY_PRESS, remoteEventHandler) );
137-
IARM_CHECK( IARM_Bus_RemoveEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_VALIDATION_END, remoteEventHandler) );
134+
IARM_CHECK( IARM_Bus_RemoveEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_VALIDATION_STATUS, remoteEventHandler) );
138135
IARM_CHECK( IARM_Bus_RemoveEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_CONFIGURATION_COMPLETE, remoteEventHandler) );
139136
IARM_CHECK( IARM_Bus_RemoveEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_RF4CE_PAIRING_WINDOW_TIMEOUT, remoteEventHandler) );
140137

@@ -171,9 +168,6 @@ namespace WPEFramework {
171168

172169
switch(eventId) {
173170
case CTRLM_RCU_IARM_EVENT_RCU_STATUS:
174-
case CTRLM_RCU_IARM_EVENT_VALIDATION_BEGIN:
175-
case CTRLM_RCU_IARM_EVENT_VALIDATION_KEY_PRESS:
176-
case CTRLM_RCU_IARM_EVENT_VALIDATION_END:
177171
case CTRLM_RCU_IARM_EVENT_CONFIGURATION_COMPLETE:
178172
case CTRLM_RCU_IARM_EVENT_RF4CE_PAIRING_WINDOW_TIMEOUT:
179173
LOGWARN("Got CTRLM_RCU_IARM_EVENT event.");
@@ -183,6 +177,10 @@ namespace WPEFramework {
183177
LOGWARN("Got CTRLM_RCU_IARM_FIRMWARE_EVENT event.");
184178
onFirmwareUpdateProgress(eventData);
185179
break;
180+
case CTRLM_RCU_IARM_EVENT_VALIDATION_STATUS:
181+
LOGWARN("Got CTRLM_RCU_IARM_VALIDATION_STATUS event.");
182+
onValidation(eventData);
183+
break;
186184
default:
187185
LOGERR("ERROR - unexpected ctrlm event: eventId: %d, data: %p, size: %d.",
188186
(int)eventId, data, len);
@@ -246,6 +244,54 @@ namespace WPEFramework {
246244
returnResponse(bSuccess);
247245
}
248246

247+
uint32_t RemoteControl::stopPairing(const JsonObject& parameters, JsonObject& response)
248+
{
249+
LOGINFOMETHOD();
250+
251+
ctrlm_main_iarm_call_json_t *call = NULL;
252+
IARM_Result_t res;
253+
string jsonParams;
254+
bool bSuccess = false;
255+
size_t totalsize = 0;
256+
257+
parameters.ToString(jsonParams);
258+
totalsize = sizeof(ctrlm_main_iarm_call_json_t) + jsonParams.size() + 1;
259+
call = (ctrlm_main_iarm_call_json_t*)calloc(1, totalsize);
260+
261+
if (call == NULL)
262+
{
263+
LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize);
264+
bSuccess = false;
265+
returnResponse(bSuccess);
266+
}
267+
268+
call->api_revision = CTRLM_MAIN_IARM_BUS_API_REVISION;
269+
size_t len = jsonParams.copy(call->payload, jsonParams.size());
270+
call->payload[len] = '\0';
271+
272+
res = IARM_Bus_Call(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_MAIN_IARM_CALL_STOP_PAIRING, (void *)call, totalsize);
273+
if (res != IARM_RESULT_SUCCESS)
274+
{
275+
LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_STOP_PAIRING Bus Call FAILED, res: %d.", (int)res);
276+
bSuccess = false;
277+
free(call);
278+
returnResponse(bSuccess);
279+
}
280+
281+
JsonObject result;
282+
result.FromString(call->result);
283+
bSuccess = result["success"].Boolean();
284+
response = result;
285+
free(call);
286+
287+
if (bSuccess)
288+
LOGINFO("STOP PAIRING call SUCCESS!");
289+
else
290+
LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_STOP_PAIRING returned FAILURE!");
291+
292+
returnResponse(bSuccess);
293+
}
294+
249295
uint32_t RemoteControl::getNetStatus(const JsonObject& parameters, JsonObject& response)
250296
{
251297
LOGINFOMETHOD();
@@ -1025,7 +1071,7 @@ namespace WPEFramework {
10251071
}
10261072
//End methods
10271073

1028-
//Begin ble events
1074+
//Begin events
10291075
void RemoteControl::onStatus(ctrlm_main_iarm_event_json_t* eventData)
10301076
{
10311077
JsonObject params;
@@ -1043,7 +1089,16 @@ namespace WPEFramework {
10431089

10441090
sendNotify("onFirmwareUpdateProgress", params);
10451091
}
1046-
//End ble events
1092+
1093+
void RemoteControl::onValidation(ctrlm_main_iarm_event_json_t* eventData)
1094+
{
1095+
JsonObject params;
1096+
1097+
params.FromString(eventData->payload);
1098+
1099+
sendNotify("onValidation", params);
1100+
}
1101+
//End events
10471102

10481103
//Begin local private utility methods
10491104
void RemoteControl::setApiVersionNumber(unsigned int apiVersionNumber)

RemoteControl/RemoteControl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ namespace WPEFramework {
6262
//Begin methods
6363
uint32_t getApiVersionNumber(const JsonObject& parameters, JsonObject& response);
6464
uint32_t startPairing(const JsonObject& parameters, JsonObject& response);
65+
uint32_t stopPairing(const JsonObject& parameters, JsonObject& response);
6566
uint32_t getNetStatus(const JsonObject& parameters, JsonObject& response);
6667
uint32_t getIRDBManufacturers(const JsonObject& parameters, JsonObject& response);
6768
uint32_t getIRDBModels(const JsonObject& parameters, JsonObject& response);
@@ -83,6 +84,7 @@ namespace WPEFramework {
8384
//Begin events
8485
void onStatus(ctrlm_main_iarm_event_json_t* eventData);
8586
void onFirmwareUpdateProgress(ctrlm_main_iarm_event_json_t* eventData);
87+
void onValidation(ctrlm_main_iarm_event_json_t* eventData);
8688
//End events
8789

8890
public:

RemoteControl/RemoteControl.json

Lines changed: 90 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,37 @@
157157
]
158158
}
159159
},
160+
"validationStatus": {
161+
"summary": "The validation status of the manual pairing request.",
162+
"type": "string",
163+
"enum": [
164+
"SUCCESS",
165+
"PENDING",
166+
"TIMEOUT",
167+
"COLLISION",
168+
"FAILURE",
169+
"ABORT",
170+
"FULL_ABORT",
171+
"FAILED",
172+
"BIND_TABLE_FULL",
173+
"IN_PROGRESS",
174+
"CTRLM_RESTART"
175+
],
176+
"example": "SUCCESS"
177+
},
178+
"validationCode": {
179+
"summary": "The pairing code for manual pairing which consists of 3 key codes (KEY_*).",
180+
"type": "array",
181+
"items": {
182+
"type":"integer",
183+
"example": "[2, 3, 4] -> [KEY_1, KEY_2, KEY_3]"
184+
}
185+
},
186+
"validationKey": {
187+
"summary": "A single key code (KEY_*) that is used to validate against the manual pair code in manual pairing mode.",
188+
"type": "integer",
189+
"example": "2 -> KEY_1"
190+
},
160191
"avDevType": {
161192
"summary": "Whether the device is a video (TV) or audio (AVR, amplifier, or soundbar) device",
162193
"type": "string",
@@ -319,9 +350,6 @@
319350
"params": {
320351
"type": "object",
321352
"properties": {
322-
"netType": {
323-
"$ref": "#/definitions/netType"
324-
},
325353
"timeout": {
326354
"summary": "The amount of time, in seconds, to attempt pairing before timing out. If this parameter is not present, an STB-defined default is used for the specified network. A value of `0` indicates no timeout.",
327355
"type": "integer",
@@ -330,11 +358,45 @@
330358
},
331359
"macAddressList": {
332360
"$ref": "#/definitions/macAddressList"
361+
},
362+
"screenBindEnable": {
363+
"summary": "Whether to enable screen bind mode. If this parameter is not present, the default value is `true`.",
364+
"type": "boolean",
365+
"default": true,
366+
"example": true
367+
},
368+
"scanEnable": {
369+
"summary": "Whether to enable scanning for remotes. If this parameter is not present, the default value is `true`.",
370+
"type": "boolean",
371+
"default": true,
372+
"example": true
333373
}
334374
},
335-
"required": [
336-
"netType"
337-
]
375+
"required": []
376+
},
377+
"result": {
378+
"$ref": "#/definitions/result"
379+
}
380+
},
381+
"stopPairing": {
382+
"summary": "Cancels pairing a remote with the STB on the specified network.",
383+
"params": {
384+
"type": "object",
385+
"properties": {
386+
"screenBindDisable": {
387+
"summary": "Whether to disable screen bind mode. If this parameter is not present, the default value is `true`.",
388+
"type": "boolean",
389+
"default": true,
390+
"example": true
391+
},
392+
"scanDisable": {
393+
"summary": "Whether to disable scanning for remotes. If this parameter is not present, the default value is `true`.",
394+
"type": "boolean",
395+
"default": true,
396+
"example": true
397+
}
398+
},
399+
"required": []
338400
},
339401
"result": {
340402
"$ref": "#/definitions/result"
@@ -960,6 +1022,27 @@
9601022
"status"
9611023
]
9621024
}
1025+
},
1026+
"onValidation": {
1027+
"summary": "Generated for manual pairing validation.",
1028+
"params": {
1029+
"type": "object",
1030+
"properties": {
1031+
"status": {
1032+
"$ref": "#/definitions/validationStatus"
1033+
},
1034+
"code": {
1035+
"$ref": "#/definitions/validationCode"
1036+
},
1037+
"key": {
1038+
"$ref": "#/definitions/validationKey"
1039+
}
1040+
},
1041+
"required": [
1042+
"status"
1043+
]
1044+
}
1045+
9631046
}
9641047
}
965-
}
1048+
}

0 commit comments

Comments
 (0)