RDK Documentation (Open Sourced RDK Components)
test_mode_change_client.c
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 
21 /**
22 * @defgroup iarmmgrs
23 * @{
24 * @defgroup test
25 * @{
26 **/
27 
28 
29 #include "libIBus.h"
30 #include "libIBusDaemon.h"
31 #include "libIARMCore.h"
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <unistd.h>
35 
36 IARM_Bus_Daemon_SysMode_t currentMode = IARM_BUS_SYS_MODE_NORMAL;
37  #define IARM_BUS_DAEMON_API_SysModeChange "DaemonSysModeChange" /*!< Well known name for Sys mode change*/
38 
39 IARM_Result_t _SysModeChange(void *arg)
40 {
41  IARM_Bus_CommonAPI_SysModeChange_Param_t *param = (IARM_Bus_CommonAPI_SysModeChange_Param_t *)arg;
42  printf("Sys Mode Change::New mode --> %d, Old mode --> %d\n",param->newMode,param->oldMode);
43  return IARM_RESULT_SUCCESS;
44 }
45 
46 int main()
47 {
48  int x = 'y';
49  IARM_Bus_CommonAPI_SysModeChange_Param_t sysModeParam;
50 
51  printf("SysClient Entering %d\r\n", getpid());
52  IARM_Bus_Init("Client");
54 
55  IARM_Bus_RegisterCall(IARM_BUS_COMMON_API_SysModeChange,_SysModeChange);
56 
57  printf("Enter 'x' to exit, 'e' to send EAS and 'w' to send warehouse and 'n' to send normal Sys mode changes\n");
58 
59  while(x != 'x') {
60 
61  switch(x)
62  {
63  case 'e':
64  sysModeParam.oldMode = currentMode;
65  sysModeParam.newMode = IARM_BUS_SYS_MODE_EAS;
66  IARM_Bus_Call(IARM_BUS_DAEMON_NAME,
68  &sysModeParam,
69  sizeof(sysModeParam));
70  break;
71  case 'w':
72  sysModeParam.oldMode = currentMode;
73  sysModeParam.newMode = IARM_BUS_SYS_MODE_WAREHOUSE;
74  IARM_Bus_Call(IARM_BUS_DAEMON_NAME,
76  &sysModeParam,
77  sizeof(sysModeParam));
78  break;
79  case 'n':
80  sysModeParam.oldMode = currentMode;
81  sysModeParam.newMode = IARM_BUS_SYS_MODE_NORMAL;
82  IARM_Bus_Call(IARM_BUS_DAEMON_NAME,
84  &sysModeParam,
85  sizeof(sysModeParam));
86  break;
87  }
88  x = getchar();
89  }
91  IARM_Bus_Term();
92  printf("Client Exiting\r\n");
93 }
94 
95 
96 /** @} */
97 /** @} */
IARM_Bus_Term
IARM_Result_t IARM_Bus_Term(void)
This API is used to terminate the IARM-Bus library.
IARM_Bus_Call
IARM_Result_t IARM_Bus_Call(const char *ownerName, const char *methodName, void *arg, size_t argLen)
This API is used to Invoke RPC method by its application name and method name.
Definition: iarm_bus.c:57
IARM_Bus_RegisterCall
IARM_Result_t IARM_Bus_RegisterCall(const char *methodName, IARM_BusCall_t handler)
This API is used to register an RPC method that can be invoked by other applications.
IARM_Bus_Disconnect
IARM_Result_t IARM_Bus_Disconnect(void)
This API disconnect Application from IARM Bus so the application will not receive any IARM event or R...
libIBus.h
RDK IARM-Bus API Declarations.
IARM_Bus_Connect
IARM_Result_t IARM_Bus_Connect(void)
This API is used to connect application to the IARM bus daemon. After connected, the application can ...
Definition: iarmMgrMocks.cpp:33
IARM_Bus_Init
IARM_Result_t IARM_Bus_Init(const char *name)
This API is used to initialize the IARM-Bus library.
Definition: iarmMgrMocks.cpp:38
IARM_BUS_DAEMON_API_SysModeChange
#define IARM_BUS_DAEMON_API_SysModeChange
Definition: test_mode_change_client.c:37