Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Commit

Permalink
Update to use csdk 1.1.0
Browse files Browse the repository at this point in the history
Signed-off-by: br <bindu@iotechsys.com>
  • Loading branch information
BinduRao2018 committed Oct 31, 2019
1 parent cfde098 commit ac1a09c
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 53 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
3 changes: 2 additions & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
1.0.1
1.1.0

2 changes: 1 addition & 1 deletion res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
SendReadingsOnChanged = true

[Driver]
BME680_Temp_Offset = -1.0
BME680_Temp_Offset = "-1.0"

[Logging]
RemoteURL = ""
Expand Down
4 changes: 2 additions & 2 deletions scripts/Dockerfile.alpine-3.9
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM alpine:3.9 as builder
MAINTAINER Bindu Rao <bindu@iotechsys.com>
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/
Expand Down Expand Up @@ -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"]
6 changes: 3 additions & 3 deletions scripts/build_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
2 changes: 1 addition & 1 deletion src/c/device_grove.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
64 changes: 19 additions & 45 deletions src/c/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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=<URL> : Use the registry service\n");
printf (" --profile=<name> : Set the profile name\n");
printf (" --confdir=<dir> : Set the configuration directory\n");
printf (" --name=<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));
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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, &params))
{
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 =
Expand All @@ -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");
Expand All @@ -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;
}

0 comments on commit ac1a09c

Please sign in to comment.