RDK Documentation (Open Sourced RDK Components)
test_mfr_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 mfr
25 * @{
26 **/
27 
28 
29 #include <stdio.h>
30 #include <malloc.h>
31 #include <stdlib.h>
32 #include <unistd.h>
33 #include <string.h>
34 #include "mfrMgr.h"
35 #include "mfrTypes.h"
36 #include "libIBus.h"
37 #include "safec_lib.h"
38 
39 mfrSerializedType_t getTypeFromMenu();
40 
41 int main()
42 {
43  char *pTmpStr;
44  int len;
45  mfrSerializedType_t type = mfrSERIALIZED_TYPE_MANUFACTURER;
47  mfrError_t Err;
48  errno_t safec_rc = -1;
49 
50  printf("mfrClient Entering %d\r\n", getpid());
51 
52 
53  IARM_Bus_Init("MFRClient");
55 
56 
57  Err = mfr_init();
58  if(Err != mfrERR_NONE)
59  {
60  printf("mfr_init failed:: %d \n",Err);
61  goto Error;
62  }
63 
64  printf("mfr_init success:: %d \n",Err);
65 
66  while(1)
67  {
68 
69  type = getTypeFromMenu();
70  if(mfrSERIALIZED_TYPE_MAX == type)
71  {
72  printf("Exiting the APP \r\n");
73  goto Error;
74  }
75 
76  Err = mfrGetSerializedData(type,&data,NULL);
77  if(Err != mfrERR_NONE)
78  {
79  printf("mfrgetserializedata failed:: %d \n",Err);
80  goto Error;
81  }
82  pTmpStr = (char *)malloc(data.bufLen + 1);
83  safec_rc = memset_s(pTmpStr, data.bufLen+1, 0, data.bufLen+1);
84  ERR_CHK(safec_rc);
85  safec_rc = memcpy_s(pTmpStr, data.bufLen+1, data.buf, data.bufLen);
86  if(safec_rc != EOK)
87  {
88  ERR_CHK(safec_rc);
89  if(pTmpStr)
90  free(pTmpStr);
91  continue;
92  }
93 
94  printf("Data length is = %d \r\n",data.bufLen);
95  printf("Serial number is = %s \r\n",pTmpStr);
96  free(pTmpStr);
97  printf("\n\n\n ");
98 
99  }
100 Error:
102  IARM_Bus_Term();
103 }
104 
105 mfrSerializedType_t getTypeFromMenu()
106 {
107  int input = mfrSERIALIZED_TYPE_MANUFACTURER;
108 
109  printf("Enter MFR Type for Query :: ");
110  scanf ("%d",&input);
111 
112 
113  switch (input)
114  {
115 
116  case mfrSERIALIZED_TYPE_MANUFACTURER:
117  printf("MFR Query made for mfrSERIALIZED_TYPE_MANUFACTURER \r\n");
118  return mfrSERIALIZED_TYPE_MANUFACTURER;
119 
120  case mfrSERIALIZED_TYPE_MANUFACTUREROUI:
121  printf("MFR Query made for mfrSERIALIZED_TYPE_MANUFACTUREROUI \r\n");
122  return mfrSERIALIZED_TYPE_MANUFACTUREROUI;
123 
124  case mfrSERIALIZED_TYPE_MODELNAME:
125  printf("MFR Query made for mfrSERIALIZED_TYPE_MODELNAME \r\n");
126  return mfrSERIALIZED_TYPE_MODELNAME;
127 
128  case mfrSERIALIZED_TYPE_DESCRIPTION:
129  printf("MFR Query made for mfrSERIALIZED_TYPE_DESCRIPTION \r\n");
130  return mfrSERIALIZED_TYPE_DESCRIPTION;
131 
132  case mfrSERIALIZED_TYPE_PRODUCTCLASS:
133  printf("MFR Query made for mfrSERIALIZED_TYPE_PRODUCTCLASS \r\n");
134  return mfrSERIALIZED_TYPE_PRODUCTCLASS;
135 
136  case mfrSERIALIZED_TYPE_SERIALNUMBER:
137  printf("MFR Query made for mfrSERIALIZED_TYPE_SERIALNUMBER \r\n");
138  return mfrSERIALIZED_TYPE_SERIALNUMBER;
139 
140  case mfrSERIALIZED_TYPE_HARDWAREVERSION:
141  printf("MFR Query made for mfrSERIALIZED_TYPE_HARDWAREVERSION \r\n");
142  return mfrSERIALIZED_TYPE_HARDWAREVERSION;
143 
144  case mfrSERIALIZED_TYPE_SOFTWAREVERSION:
145  printf("MFR Query made for mfrSERIALIZED_TYPE_SOFTWAREVERSION \r\n");
146  return mfrSERIALIZED_TYPE_SOFTWAREVERSION;
147 
148  case mfrSERIALIZED_TYPE_PROVISIONINGCODE:
149  printf("MFR Query made for mfrSERIALIZED_TYPE_PROVISIONINGCODE \r\n");
150  return mfrSERIALIZED_TYPE_PROVISIONINGCODE;
151 
152  case mfrSERIALIZED_TYPE_FIRSTUSEDATE:
153  printf("MFR Query made for mfrSERIALIZED_TYPE_FIRSTUSEDATE \r\n");
154  return mfrSERIALIZED_TYPE_FIRSTUSEDATE;
155 
156  case mfrSERIALIZED_TYPE_DEVICEMAC:
157  printf("MFR Query made for mfrSERIALIZED_TYPE_DEVICEMAC \r\n");
158  return mfrSERIALIZED_TYPE_DEVICEMAC;
159 
160  case mfrSERIALIZED_TYPE_MOCAMAC:
161  printf("MFR Query made for mfrSERIALIZED_TYPE_MOCAMAC \r\n");
162  return mfrSERIALIZED_TYPE_MOCAMAC;
163 
164  case mfrSERIALIZED_TYPE_HDMIHDCP:
165  printf("MFR Query made for mfrSERIALIZED_TYPE_HDMIHDCP \r\n");
166  return mfrSERIALIZED_TYPE_HDMIHDCP;
167 
168  case mfrSERIALIZED_TYPE_BOARDVERSION:
169  printf("MFR Query made for mfrSERIALIZED_TYPE_BOARDVERSION \r\n");
170  return mfrSERIALIZED_TYPE_BOARDVERSION;
171 
172  case mfrSERIALIZED_TYPE_BOARDSERIALNO:
173  printf("MFR Query made for mfrSERIALIZED_TYPE_BOARDSERIALNO \r\n");
174  return mfrSERIALIZED_TYPE_BOARDSERIALNO;
175 
176  case mfrSERIALIZED_TYPE_CMCHIPVERSION:
177  printf("MFR Query made for mfrSERIALIZED_TYPE_CMCHIPVERSION \r\n");
178  return mfrSERIALIZED_TYPE_CMCHIPVERSION;
179 
180  case mfrSERIALIZED_TYPE_DECODERSWVERSION:
181  printf("MFR Query made for mfrSERIALIZED_TYPE_DECODERSWVERSION \r\n");
182  return mfrSERIALIZED_TYPE_DECODERSWVERSION;
183 
184  case mfrSERIALIZED_TYPE_OSKERNELVERSION:
185  printf("MFR Query made for mfrSERIALIZED_TYPE_OSKERNELVERSION \r\n");
186  return mfrSERIALIZED_TYPE_OSKERNELVERSION;
187 
188  case mfrSERIALIZED_TYPE_MFRLIBVERSION:
189  printf("MFR Query made for mfrSERIALIZED_TYPE_MFRLIBVERSION \r\n");
190  return mfrSERIALIZED_TYPE_MFRLIBVERSION;
191 
192  case mfrSERIALIZED_TYPE_FRONTPANELVERSION:
193  printf("MFR Query made for mfrSERIALIZED_TYPE_FRONTPANELVERSION \r\n");
194  return mfrSERIALIZED_TYPE_FRONTPANELVERSION;
195 
196  case mfrSERIALIZED_TYPE_SOFTWAREIMAGEVERSION1:
197  printf("MFR Query made for mfrSERIALIZED_TYPE_SOFTWAREIMAGEVERSION1 \r\n");
198  return mfrSERIALIZED_TYPE_SOFTWAREIMAGEVERSION1;
199 
200  case mfrSERIALIZED_TYPE_OCHDVERSION:
201  printf("MFR Query made for mfrSERIALIZED_TYPE_OCHDVERSION \r\n");
202  return mfrSERIALIZED_TYPE_OCHDVERSION;
203 
204  case mfrSERIALIZED_TYPE_OCAPVERSION:
205  printf("MFR Query made for mfrSERIALIZED_TYPE_OCAPVERSION \r\n");
206  return mfrSERIALIZED_TYPE_OCAPVERSION;
207 
208 
209  case mfrSERIALIZED_TYPE_BOOTROMVERSION:
210  printf("MFR Query made for mfrSERIALIZED_TYPE_BOOTROMVERSION \r\n");
211  return mfrSERIALIZED_TYPE_BOOTROMVERSION;
212 
213  case mfrSERIALIZED_TYPE_MODELNUMBER:
214  printf("MFR Query made for mfrSERIALIZED_TYPE_MODELNUMBER \r\n");
215  return mfrSERIALIZED_TYPE_MODELNUMBER;
216 
217  case mfrSERIALIZED_TYPE_MODELSERIALNO:
218  printf("MFR Query made for mfrSERIALIZED_TYPE_MODELSERIALNO \r\n");
219  return mfrSERIALIZED_TYPE_MODELSERIALNO;
220 
221  case mfrSERIALIZED_TYPE_VENDORNAME:
222  printf("MFR Query made for mfrSERIALIZED_TYPE_VENDORNAME \r\n");
223  return mfrSERIALIZED_TYPE_VENDORNAME;
224 
225  //Failing
226  case mfrSERIALIZED_TYPE_VENDORSERIALNO:
227  printf("MFR Query made for mfrSERIALIZED_TYPE_VENDORSERIALNO \r\n");
228  return mfrSERIALIZED_TYPE_VENDORSERIALNO;
229 
230  //Failing
231  case mfrSERIALIZED_TYPE_MANUFACTUREDATE:
232  printf("MFR Query made for mfrSERIALIZED_TYPE_MANUFACTUREDATE \r\n");
233  return mfrSERIALIZED_TYPE_MANUFACTUREDATE;
234 
235  case mfrSERIALIZED_TYPE_CACPHOSTID:
236  printf("MFR Query made for mfrSERIALIZED_TYPE_MANUFACTUREDATE \r\n");
237  return mfrSERIALIZED_TYPE_CACPHOSTID;
238 
239  default:
240  printf("Error : Default choosen mfrSERIALIZED_TYPE_SERIALNUMBER \r\n");
241  return mfrSERIALIZED_TYPE_MAX;
242  }
243  }
244 
245 
246 /** @} */
247 /** @} */
IARM_Bus_Term
IARM_Result_t IARM_Bus_Term(void)
This API is used to terminate the IARM-Bus library.
mfrGetSerializedData
mfrError_t mfrGetSerializedData(mfrSerializedType_t type, mfrSerializedData_t *data, mfrEncryptFunction_t crypto)
Retrieve Serialized Read-Only data from device. The serialized data is returned as a byte stream....
Definition: mfrCli.c:98
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.
mfr_init
mfrError_t mfr_init(void)
Initialize the mfr library. This function should be call once before the functions in this API can ...
Definition: mfrCli.c:65
_mfrSerializedData_t
Definition: mfrTypes.h:50
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