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

Commit

Permalink
build: device-grove updates for CSDK v1.3 (#50)
Browse files Browse the repository at this point in the history
Signed-off-by: Iain Anderson <iain@iotechsys.com>
  • Loading branch information
iain-anderson committed Oct 28, 2020
1 parent a2aaf4b commit dabf1de
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ clean:
rm -f $(MICROSERVICES)

./VERSION:
@git describe --abbrev=0 > ./VERSION
@git describe --abbrev=0 | sed 's/^v//' > ./VERSION

version: ./VERSION
echo ${VERSION}
Expand Down
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,3 @@ By default, the configuration and profile file used by the service are available
2. --device=/dev/ < i2c-device > to map host device to the container. For Raspberry PI, it is i2c-1.

**Note:** On Raspberry PI, make sure that i2c_arm=on is set. This enables i2c-1 device, required for communication between Grove PI & Raspberry PI boards.














8 changes: 5 additions & 3 deletions scripts/build_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ set -e -x

BUILD_CSDK=$1

CSDK_VER=1.3.0-dev.10

# Dependencies
if [ ! -d deps ]
then
Expand Down Expand Up @@ -34,9 +36,9 @@ then
make
make install

wget https://github.com/edgexfoundry/device-sdk-c/archive/v1.2.2.zip
unzip v1.2.2.zip
cd device-sdk-c-1.2.2
wget https://github.com/edgexfoundry/device-sdk-c/archive/v${CSDK_VER}.zip
unzip v${CSDK_VER}.zip
cd device-sdk-c-${CSDK_VER}
./scripts/build.sh
cp -rf include/* /usr/include/
cp build/release/c/libcsdk.so /usr/lib/
Expand Down
19 changes: 17 additions & 2 deletions src/c/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ static bool grove_init (void *impl, struct iot_logger_t *lc, const iot_data_t *c

mraa_add_subplatform (MRAA_GROVEPI, "0");

BME680_Temp_Offset = (config) ? strtof (iot_data_string_map_get_string (config, "BME680_Temp_Offset"), NULL) : 0.0;
BME680_Temp_Offset = iot_data_f32 (iot_data_string_map_get (config, "BME680_Temp_Offset"));

/* read the attributes from the device profile to initialize the driver */
profiles = edgex_profiles (impln->svc);
Expand Down Expand Up @@ -360,6 +360,12 @@ static bool grove_init (void *impl, struct iot_logger_t *lc, const iot_data_t *c
return (status == MRAA_SUCCESS);
}

static void grove_reconfigure (void *impl, const iot_data_t *config)
{
grove_pidriver_t *driver = (grove_pidriver_t *) impl;
iot_log_error (driver->lc, "Grove [Driver] configuration cannot be updated while running. Please restart the service.");
}

static bool grove_gethandler
(
void *impl,
Expand Down Expand Up @@ -735,6 +741,7 @@ static void grove_stop (void *impl, bool force)

int main (int argc, char *argv[])
{
iot_data_t *defaults = NULL;
grove_pidriver_t *implObject = malloc (sizeof (grove_pidriver_t));
memset (implObject, 0, sizeof (grove_pidriver_t));
sem_init (&grove_sem, 0, 0);
Expand All @@ -746,6 +753,7 @@ int main (int argc, char *argv[])
devsdk_callbacks myImpls =
{
grove_init,
grove_reconfigure,
NULL,
grove_gethandler,
grove_puthandler,
Expand Down Expand Up @@ -775,8 +783,14 @@ int main (int argc, char *argv[])
}

implObject->svc = grove_service;

/* Setup default configuration */

defaults = iot_data_alloc_map (IOT_DATA_STRING);
iot_data_string_map_add (defaults, "BME680_Temp_Offset", iot_data_alloc_f32 (0.0));

/* Start the device service*/
devsdk_service_start (grove_service, &err);
devsdk_service_start (grove_service, defaults, &err);
GROVE_ERR_CHECK (err);

printf ("\nRunning - press ctrl-c to exit\n");
Expand All @@ -791,6 +805,7 @@ int main (int argc, char *argv[])

sem_destroy (&grove_sem);
devsdk_service_free (grove_service);
iot_data_free (defaults);
free (implObject);

return 0;
Expand Down

0 comments on commit dabf1de

Please sign in to comment.