RDK Documentation (Open Sourced RDK Components)
btrMgr_Columbo.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  * @file btrMgr_SysDiag.c
21  *
22  * @description This file implements bluetooth manager's
23  *
24  */
25 
26 #ifdef HAVE_CONFIG_H
27 #include <config.h>
28 #endif
29 
30 /* System Headers */
31 #include <stdlib.h>
32 #include <stdbool.h>
33 #include <string.h>
34 #include <stdio.h>
35 
36 #include "btrMgr_Types.h"
37 #include "btrMgr_logger.h"
38 #include "btrMgr_Columbo.h"
39 
40 
41 /* Interfaces */
42 eBTRMgrRet BTRMGR_Columbo_GetData(BTRMGR_ColumboChar_t aenColumboChar, char* aData)
43 {
44  eBTRMgrRet rc = eBTRMgrSuccess;
45 
46  switch (aenColumboChar)
47  {
48  case BTRMGR_SYSDIAG_COLUMBO_STATUS:
49  {
50  strncpy(aData, "Getting Status", BTRMGR_COL_STR_LEN_MAX - 1);
51  }
52  break;
53  case BTRMGR_SYSDIAG_COLUMBO_REPORT:
54  {
55  strncpy(aData, "Getting Report", BTRMGR_COL_STR_LEN_MAX - 1);
56  }
57  break;
58  default:
59  {
60  rc = eBTRMgrFailure;
61  }
62  break;
63  }
64 
65  return rc;
66 }
67 
68 eBTRMgrRet BTRMGR_Columbo_SetData(BTRMGR_ColumboChar_t aenColumboChar, char* aData)
69 {
70  eBTRMgrRet rc = eBTRMgrSuccess;
71 
72  switch (aenColumboChar)
73  {
74  case BTRMGR_SYSDIAG_COLUMBO_START:
75  {
76  FILE *fPipe;
77  char lData[256];
78  fPipe = popen("/usr/bin/hwst_flex_demo.sh launch", "r");
79 
80  if (NULL == fPipe)
81  { /* check for errors */
82  rc = eBTRMgrFailure;
83  BTRMGRLOG_DEBUG("Pipe failed to open\n");
84  }
85  else
86  {
87  while(NULL != fgets(lData, 255, fPipe))
88  {
89  BTRMGRLOG_DEBUG("%s", lData);
90  }
91  BTRMGRLOG_DEBUG("Script has finished it's execution\n");
92  pclose(fPipe); //CID:135219 - Forward Null
93  }
94  }
95  break;
96  case BTRMGR_SYSDIAG_COLUMBO_STOP:
97  {
98  FILE *fPipe;
99  char lData[256];
100  fPipe = popen("/usr/bin/hwst_flex_demo.sh exit", "r");
101  if (NULL == fPipe)
102  { /* check for errors */
103  rc = eBTRMgrFailure;
104  BTRMGRLOG_DEBUG("Pipe failed to open\n");
105  }
106  else
107  {
108  while(NULL != fgets(lData, 255, fPipe))
109  {
110  BTRMGRLOG_DEBUG("%s", lData);
111  }
112  BTRMGRLOG_DEBUG("Script has finished it's execution\n");
113  pclose(fPipe);
114  }
115  }
116  break;
117  default:
118  {
119  rc = eBTRMgrFailure;
120  }
121  break;
122  }
123 
124  return rc;
125 }
126 
127 
btrMgr_Types.h
eBTRMgrRet
enum _eBTRMgrRet eBTRMgrRet
Represents the bluetooth manager return values.