From ac1a09c073ebc0270fba4af890a3457090776428 Mon Sep 17 00:00:00 2001 From: br Date: Thu, 31 Oct 2019 14:57:58 +0000 Subject: [PATCH 1/2] Update to use csdk 1.1.0 Signed-off-by: br --- CHANGES | 4 +++ VERSION | 3 +- res/configuration.toml | 2 +- scripts/Dockerfile.alpine-3.9 | 4 +-- scripts/build_deps.sh | 6 ++-- src/c/device_grove.h | 2 +- src/c/main.c | 64 +++++++++++------------------------ 7 files changed, 32 insertions(+), 53 deletions(-) diff --git a/CHANGES b/CHANGES index 5c7a351..0106c35 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +Changes for Fuji release: + +- Device service updated to use C SDK (v1.1.0) + Changes for Edinburgh release: - Device service updated to use C SDK (v1.0.0) diff --git a/VERSION b/VERSION index 7dea76e..653f458 100644 --- a/VERSION +++ b/VERSION @@ -1 +1,2 @@ -1.0.1 +1.1.0 + diff --git a/res/configuration.toml b/res/configuration.toml index e2ff1c7..539fc55 100644 --- a/res/configuration.toml +++ b/res/configuration.toml @@ -29,7 +29,7 @@ SendReadingsOnChanged = true [Driver] - BME680_Temp_Offset = -1.0 + BME680_Temp_Offset = "-1.0" [Logging] RemoteURL = "" diff --git a/scripts/Dockerfile.alpine-3.9 b/scripts/Dockerfile.alpine-3.9 index 14b1641..ff2b689 100644 --- a/scripts/Dockerfile.alpine-3.9 +++ b/scripts/Dockerfile.alpine-3.9 @@ -1,6 +1,6 @@ FROM alpine:3.9 as builder MAINTAINER Bindu Rao -RUN apk add --update --no-cache build-base git gcc cmake make linux-headers yaml-dev libmicrohttpd-dev curl-dev util-linux-dev +RUN apk add --update --no-cache build-base git gcc cmake make linux-headers yaml-dev libmicrohttpd-dev curl-dev util-linux-dev ncurses-dev COPY scripts /device-grove/scripts COPY src /device-grove/src/ @@ -30,4 +30,4 @@ COPY res /res COPY profiles /profiles ENTRYPOINT ["/device-grove"] -CMD ["--confdir=/res"] +CMD ["--confdir=/res", "--registry=consul://edgex-core-consul:8500"] diff --git a/scripts/build_deps.sh b/scripts/build_deps.sh index 6f1a04e..b9f0cc4 100755 --- a/scripts/build_deps.sh +++ b/scripts/build_deps.sh @@ -34,9 +34,9 @@ then make make install - wget https://github.com/edgexfoundry/device-sdk-c/archive/edinburgh.tar.gz - tar -xzf edinburgh.tar.gz - cd device-sdk-c-edinburgh + wget https://github.com/edgexfoundry/device-sdk-c/archive/fuji.tar.gz + tar -xzf fuji.tar.gz + cd device-sdk-c-fuji ./scripts/build.sh cp -rf include/* /usr/include/ cp build/release/c/libcsdk.so /usr/lib/ diff --git a/src/c/device_grove.h b/src/c/device_grove.h index 3108c27..e9c41b7 100644 --- a/src/c/device_grove.h +++ b/src/c/device_grove.h @@ -37,7 +37,7 @@ extern "C" { #define GROVE_ADC_REF 5 #define GROVE_SVC "Device-Grove" -#define VERSION "1.0.1" +#define GROVE_VERSION "1.1.0" typedef enum { diff --git a/src/c/main.c b/src/c/main.c index 0de5fe3..b60ff77 100644 --- a/src/c/main.c +++ b/src/c/main.c @@ -23,16 +23,6 @@ static void grove_inthandler (int i) sem_post (&grove_sem); } -static void usage (void) -{ - printf ("Options: \n"); - printf (" -h, --help : Show this text\n"); - printf (" --registry= : Use the registry service\n"); - printf (" --profile= : Set the profile name\n"); - printf (" --confdir= : Set the configuration directory\n"); - printf (" --name= : Set the service name\n"); -} - static grove_attributes_t *get_groveattributes (const edgex_nvpairs *device_attr) { grove_attributes_t *grove_attr = (grove_attributes_t *) malloc (sizeof (grove_attributes_t)); @@ -291,7 +281,7 @@ static mraa_result_t grove_i2c_init (grove_pidriver_t *impln, char *pin, char *t else { status = MRAA_ERROR_UNSPECIFIED; - iot_log_warning (impln->lc, "Invalid Type, Ignore I2C initialization"); + iot_log_warn (impln->lc, "Invalid Type, Ignore I2C initialization"); } return status; } @@ -732,53 +722,35 @@ static void grove_stop (void *impl, bool force) int main (int argc, char *argv[]) { - const char *profile = ""; - char *confdir = ""; - char *regURL = NULL; - char *service_name = GROVE_SVC; - edgex_error err; + edgex_device_svcparams params = { GROVE_SVC, "", NULL, "" }; grove_pidriver_t *implObject = malloc (sizeof (grove_pidriver_t)); memset (implObject, 0, sizeof (grove_pidriver_t)); sem_init (&grove_sem, 0, 0); + if (!edgex_device_service_processparams (&argc, argv, ¶ms)) + { + return 0; + } + int n = 1; while (n < argc) { if (strcmp (argv[n], "-h") == 0 || strcmp (argv[n], "--help") == 0) { - usage (); + printf ("Options:\n"); + printf (" -h, --help\t\t: Show this text\n"); + edgex_device_service_usage (); return 0; } - if (strstr (argv[n], "--registry=") != NULL) - { - regURL = argv[n] + strlen ("--registry="); - n++; - continue; - } - if (strstr (argv[n], "--profile=") != NULL) - { - profile = argv[n] + strlen ("--profile="); - n++; - continue; - } - if (strstr (argv[n], "--confdir=") != NULL) - { - confdir = argv[n] + strlen ("--confdir="); - n++; - continue; - } - if (strstr (argv[n], "--name=") != NULL) + else { - service_name = argv[n] + strlen ("--name="); - n++; - continue; + printf ("%s: Unrecognized option %s\n", argv[0], argv[n]); + return 0; } - printf ("Unknown option %s\n", argv[n]); - usage (); - return 0; } + edgex_error err; err.code = 0; edgex_device_callbacks myImpls = @@ -791,12 +763,12 @@ int main (int argc, char *argv[]) grove_stop }; - edgex_device_service *grove_service = edgex_device_service_new (service_name, VERSION, implObject, myImpls, &err); + edgex_device_service *grove_service = edgex_device_service_new (params.svcname, GROVE_VERSION, implObject, myImpls, &err); GROVE_ERR_CHECK (err); implObject->svc = grove_service; err.code = 0; - edgex_device_service_start (grove_service, regURL, profile, confdir, &err); + edgex_device_service_start (grove_service, params.regURL, params.profile, params.confdir, &err); GROVE_ERR_CHECK (err); printf ("\nRunning - press ctrl-c to exit\n"); @@ -810,7 +782,9 @@ int main (int argc, char *argv[]) edgex_device_service_stop (grove_service, true, &err); GROVE_ERR_CHECK (err); - free (implObject); sem_destroy (&grove_sem); + edgex_device_service_free (grove_service); + free (implObject); + return 0; } From d3b56d11cefd4a06004e502eb1a4f78e740b8544 Mon Sep 17 00:00:00 2001 From: br Date: Thu, 31 Oct 2019 16:09:07 +0000 Subject: [PATCH 2/2] Updates for Fuji release Signed-off-by: br --- res/configuration.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/configuration.toml b/res/configuration.toml index 539fc55..e2ff1c7 100644 --- a/res/configuration.toml +++ b/res/configuration.toml @@ -29,7 +29,7 @@ SendReadingsOnChanged = true [Driver] - BME680_Temp_Offset = "-1.0" + BME680_Temp_Offset = -1.0 [Logging] RemoteURL = ""