summaryrefslogtreecommitdiffstats
path: root/external/meta-iot-cloud/recipes-ibm/ibm-iotf-embeddedc/files/Add-additional-options-to-sample-apps.patch
blob: de0522bf091172bd95cf522ad98cb79fbaa7f7e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
From 796c934b3294871cb8ccb566ff6a9ae78d3ea4df Mon Sep 17 00:00:00 2001
From: Vivek Chandra <vivek.chandrax.amancha@intel.com>
Date: Wed, 21 Mar 2018 19:45:48 +0530
Subject: [PATCH] Add additional options to sample apps

---
 samples/sampleDevice.c  | 15 +++++++++------
 samples/sampleGateway.c | 14 ++++++++++----
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/samples/sampleDevice.c b/samples/sampleDevice.c
index e1d78ea..5af14a2 100644
--- a/samples/sampleDevice.c
+++ b/samples/sampleDevice.c
@@ -40,7 +40,6 @@ int main(int argc, char const *argv[])
 	int rc = -1;
 
 	iotfclient  client;
-
 	//catch interrupt signal
 	signal(SIGINT, sigHandler);
 	signal(SIGTERM, sigHandler);
@@ -48,16 +47,20 @@ int main(int argc, char const *argv[])
 	char* configFilePath;
 
 	if(isEMBDCHomeDefined()){
-
 	    getSamplesPath(&configFilePath);
 	    configFilePath = realloc(configFilePath,strlen(configFilePath)+15);
 	    strcat(configFilePath,"device.cfg");
         }
-	else{
-	    printf("IOT_EMBDC_HOME is not defined\n");
-	    printf("Define IOT_EMBDC_HOME to client library path to execute samples\n");
+	//to handle if EMBDCHome not defined
+	else if(argc > 1) {
+	    configFilePath = (char*)malloc(sizeof(char)*(strlen(argv[1])+3));
+            strcpy(configFilePath,argv[1]);
+        } 
+	else {
+	    printf("Pass the absolute path of the config file as command line argument ex: ./sampleDevice <path-to-config>/<config-file-name> or ");
+	    printf("Please define IOT_EMBDC_HOME\n");
 	    return -1;
-        }
+	}
 
 	rc = initialize_configfile(&client, configFilePath,0);
 	free(configFilePath);
diff --git a/samples/sampleGateway.c b/samples/sampleGateway.c
index 0d98f53..202ad45 100644
--- a/samples/sampleGateway.c
+++ b/samples/sampleGateway.c
@@ -55,11 +55,17 @@ int main(int argc, char const *argv[])
 	    configFilePath = realloc(configFilePath,strlen(configFilePath)+15);
 	    strcat(configFilePath,"gateway.cfg");
         }
-	else{
-	    printf("IOT_EMBDC_HOME is not defined\n");
-	    printf("Define IOT_EMBDC_HOME to client library path to execute samples\n");
+	//to handle if EMBDCHome not defined
+	else if(argc > 1) {
+	    configFilePath = (char*)malloc(sizeof(char)*(strlen(argv[1])+3));
+	    strcpy(configFilePath,argv[1]); 
+        } 
+	else {
+	    printf("Pass the absolute path of the config file as command line argument ex: ./sampleGateway <path-to-config>/<config-file-name> or ");
+	    printf("Define IOT_EMBDC_HOME to client library path to execute samples\n");	
 	    return -1;
-        }
+	}
+
 
 	rc = initialize_configfile(&client, configFilePath,1);
 	free(configFilePath);
-- 
2.7.4