RDK Documentation (Open Sourced RDK Components)
personalityReset.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 power
25  * @{
26  **/
27 
28 
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include "resetModes.h"
32 #include "pwrlogger.h"
33 
34 #ifdef ENABLE_PERSONALITY_SWITCH
35 extern "C" {
36 typedef enum svcs_transPersonalityResult {
37  TRANS_PERS_SUCCESS = 0, /* if personality set/get is successful */
38  TRANS_PERS_MOCA_ERROR = 1, /* If personality check cannot be completed due to network/moca connectivity */
39  TRANS_PERS_ACS_CONNECT_ERROR = 2, /* If personality check cannot be completed due to ACS connection error */
40  TRANS_PERS_TR069_ERROR = 3
41 } svcs_transPersonalityResult;
42 svcs_transPersonalityResult svcs_transSetPersonalityFlag(char * newTransPersonalityFlag);
43 unsigned int svcs_transGetPersonalityFlag( char ** personalityFlag );
44 }
45 #endif
46 
47 int processPersonalityReset()
48 {
49  int result = 0;
50  char *personalityFlag = NULL;
51  LOG("\n Reset: Processing personality reset\n");
52  fflush(stdout);
53 #ifdef ENABLE_PERSONALITY_SWITCH
54  svcs_transGetPersonalityFlag(&personalityFlag);
55  LOG("Current personality is %s\n", personalityFlag);
56  free(personalityFlag);
57  result = svcs_transSetPersonalityFlag("DTA");
58  LOG("Personality reset returned %d\n", result);
59  svcs_transGetPersonalityFlag(&personalityFlag);
60  LOG("Current personality is %s\n", personalityFlag);
61  free(personalityFlag);
62  if(0 == result)
63  {
64  /*Execute the script for personality reset*/
65  system("sh /lib/rdk/deviceReset.sh personality");
66 
67  system("echo 0 > /opt/.rebootFlag");
68  system(" echo `/bin/timestamp` ------------- Rebooting due to personality reset process --------------- >> /opt/logs/receiver.log");
69  system("sleep 5; /rebootNow.sh -s PowerMgr_PersonalityReset -o 'Rebooting the box due to personality reset process ...'");
70  }
71 #else
72  LOG("\n Reset: personality reset is not supported on this device.\n");
73  fflush(stdout);
74 #endif //ENABLE_PERSONALITY_SWITCH
75  return result;
76 }
77 
78 
79 
80 /** @} */
81 /** @} */