Skip to content

Commit

Permalink
Update to current iotech-c-utils
Browse files Browse the repository at this point in the history
Signed-off-by: Iain Anderson <[email protected]>
  • Loading branch information
iain-anderson committed Apr 30, 2019
1 parent 87f6ff4 commit 76b6c10
Show file tree
Hide file tree
Showing 28 changed files with 178 additions and 168 deletions.
8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ build
deps
src/c/toml.c
src/c/toml.h
src/c/thpool.c
src/c/logging.c
src/c/scheduler.c
include/thpool.h
src/c/iot/
include/edgex/csdk-defs.h
include/iot/logging.h
include/iot/scheduler.h
include/iot/
*~
TAGS
test_results/
Expand Down
2 changes: 1 addition & 1 deletion include/edgex/devsdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ typedef struct edgex_device_commandresult
typedef bool (*edgex_device_device_initialize)
(
void *impl,
struct iot_logging_client *lc,
struct iot_logger_t *lc,
const edgex_nvpairs *config
);

Expand Down
6 changes: 3 additions & 3 deletions include/edgex/edgex_logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
#define _EDGEX_LOGGING_H_ 1

#include "edgex/os.h"
#include "iot/logging.h"
#include "iot/logger.h"

/* Built-in logger: post to an EdgeX logging service */

extern bool edgex_log_torest
(
const char *destination,
const char *subsystem,
iot_loglevel l,
iot_loglevel_t l,
time_t timestamp,
const char *message
);
Expand All @@ -29,7 +29,7 @@ extern bool edgex_log_tofile
(
const char *destination,
const char *subsystem,
iot_loglevel l,
iot_loglevel_t l,
time_t timestamp,
const char *message
);
Expand Down
16 changes: 8 additions & 8 deletions include/edgex/registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/

typedef bool (*edgex_registry_ping_impl)
(iot_logging_client *lc, void *location, edgex_error *err);
(iot_logger_t *lc, void *location, edgex_error *err);

/**
* @brief Retrieve configuration values from the registry.
Expand All @@ -44,7 +44,7 @@ typedef bool (*edgex_registry_ping_impl)

typedef edgex_nvpairs *(*edgex_registry_get_config_impl)
(
iot_logging_client *lc,
iot_logger_t *lc,
void *location,
const char *servicename,
const char *profile,
Expand All @@ -63,7 +63,7 @@ typedef edgex_nvpairs *(*edgex_registry_get_config_impl)

typedef void (*edgex_registry_put_config_impl)
(
iot_logging_client *lc,
iot_logger_t *lc,
void *location,
const char *servicename,
const char *profile,
Expand All @@ -85,7 +85,7 @@ typedef void (*edgex_registry_put_config_impl)

typedef void (*edgex_registry_register_service_impl)
(
iot_logging_client *lc,
iot_logger_t *lc,
void *location,
const char *servicename,
const char *hostname,
Expand All @@ -107,7 +107,7 @@ typedef void (*edgex_registry_register_service_impl)

typedef void (*edgex_registry_query_service_impl)
(
iot_logging_client *lc,
iot_logger_t *lc,
void *location,
const char *servicename,
char **hostname,
Expand All @@ -124,7 +124,7 @@ typedef void (*edgex_registry_query_service_impl)
*/

typedef void *(*edgex_registry_parse_location_impl)
(iot_logging_client *lc, const char *location);
(iot_logger_t *lc, const char *location);

/**
* @brief Free the memory used in a location structure.
Expand Down Expand Up @@ -152,7 +152,7 @@ typedef struct
uint16_t port;
} edgex_registry_hostport;

void *edgex_registry_parse_simple_url (iot_logging_client *lc, const char *url);
void *edgex_registry_parse_simple_url (iot_logger_t *lc, const char *url);
void edgex_registry_free_simple_url (void *location);

/* Client functions */
Expand Down Expand Up @@ -182,7 +182,7 @@ bool edgex_registry_add_impl (const char *name, edgex_registry_impl impl);
*/

edgex_registry *edgex_registry_get_registry
(struct iot_logging_client *lc, const char *url);
(struct iot_logger_t *lc, const char *url);

/**
* @brief Determine whether the registry service is running.
Expand Down
37 changes: 26 additions & 11 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ set -e -x
CPPCHECK=false
DOCGEN=false

IOTECH=IOTechSystems
CUTILNAME=iotech-c-utils
CUTILREF=1a0be9f
CUTILDIR=$IOTECH-$CUTILNAME-$CUTILREF

# Process arguments

while [ $# -gt 0 ]
Expand Down Expand Up @@ -39,20 +44,30 @@ then
wget -O - https://github.com/IOTechSystems/tomlc99/archive/SDK-0.2.tar.gz | tar -C deps -z -x -f -
cp deps/tomlc99-SDK-0.2/toml.* src/c

# Thread Pool

wget -O - https://github.com/IOTechSystems/C-Thread-Pool/archive/SDK-0.1.tar.gz | tar -C deps -z -x -f -
cp deps/C-Thread-Pool-SDK-0.1/thpool.c src/c
cp deps/C-Thread-Pool-SDK-0.1/thpool.h include/

# C Utils

wget -O - https://github.com/IOTechSystems/iotech-c-utils/archive/v0.1.3.tar.gz | tar -C deps -z -x -f -
cp deps/iotech-c-utils-0.1.3/src/c/scheduler.c src/c/scheduler.c
cp deps/iotech-c-utils-0.1.3/src/c/logging.c src/c/logging.c
wget -O - https://github.com/$IOTECH/$CUTILNAME/tarball/$CUTILREF | tar -C deps -z -x -f -
mkdir -p src/c/iot
cp deps/$CUTILDIR/src/c/scheduler.c src/c/iot
cp deps/$CUTILDIR/src/c/logger.c src/c/iot
cp deps/$CUTILDIR/src/c/threadpool.c src/c/iot
cp deps/$CUTILDIR/src/c/thread.c src/c/iot
cp deps/$CUTILDIR/src/c/data.c src/c/iot
cp deps/$CUTILDIR/src/c/json.c src/c/iot
cp deps/$CUTILDIR/src/c/container.c src/c/iot
mkdir -p include/iot
cp deps/iotech-c-utils-0.1.3/include/iot/scheduler.h include/iot/scheduler.h
cp deps/iotech-c-utils-0.1.3/include/iot/logging.h include/iot/logging.h
cp deps/$CUTILDIR/include/iot/scheduler.h include/iot
cp deps/$CUTILDIR/include/iot/logger.h include/iot
cp deps/$CUTILDIR/include/iot/threadpool.h include/iot
cp deps/$CUTILDIR/include/iot/component.h include/iot
cp deps/$CUTILDIR/include/iot/data.h include/iot
cp deps/$CUTILDIR/include/iot/thread.h include/iot
cp deps/$CUTILDIR/include/iot/container.h include/iot
cp deps/$CUTILDIR/include/iot/json.h include/iot
cp deps/$CUTILDIR/include/iot/os.h include/iot
mkdir -p include/iot/os
cp deps/$CUTILDIR/include/iot/os/* include/iot/os

fi

# Cmake release build
Expand Down
2 changes: 1 addition & 1 deletion src/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ endif ()

# Set default files to compile and libraries

file (GLOB C_FILES *.c)
file (GLOB C_FILES *.c iot/*.c)
set (LINK_LIBRARIES ${LIBMICROHTTP_LIBRARIES} ${CURL_LIBRARIES} ${LIBYAML_LIBRARIES} ${LIBUUID_LIBRARIES})
configure_file ("defs.h.in" "${CMAKE_SOURCE_DIR}/../include/edgex/csdk-defs.h")

Expand Down
8 changes: 4 additions & 4 deletions src/c/autoevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ void edgex_device_autoevent_start (edgex_device_service *svc, edgex_device *dev)
}
if (ae->impl->svc->autoevstart)
{
thpool_add_work (svc->thpool, starter, ae->impl);
iot_threadpool_add_work (svc->thpool, starter, ae->impl, NULL);
}
else
{
ae->impl->handle = iot_schedule_create
(svc->scheduler, ae_runner, ae->impl, IOT_MS_TO_NS(ae->impl->interval), 0, 0);
(svc->scheduler, ae_runner, ae->impl, IOT_MS_TO_NS(ae->impl->interval), 0, 0, NULL);
iot_schedule_add (ae->impl->svc->scheduler, ae->impl->handle);
}
}
Expand All @@ -189,7 +189,7 @@ void edgex_device_autoevent_stop (edgex_device *dev)
for (edgex_device_autoevents *ae = dev->autos; ae; ae = ae->next)
{
edgex_autoimpl *ai = ae->impl;
thpool_add_work (ai->svc->thpool, stopper, ai);
iot_threadpool_add_work (ai->svc->thpool, stopper, ai, NULL);
}
}

Expand All @@ -210,7 +210,7 @@ void edgex_device_register_autoevent_handlers
if ((starter == NULL) || (stopper == NULL))
{
iot_log_error
(iot_log_default, "AutoEvent registration: must specify both handlers");
(iot_log_default (), "AutoEvent registration: must specify both handlers");
return;
}
svc->autoevstart = starter;
Expand Down
14 changes: 7 additions & 7 deletions src/c/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static void toml_rtos2 (const char *s, char **ret);

toml_table_t *edgex_device_loadConfig
(
iot_logging_client *lc,
iot_logger_t *lc,
const char *dir,
const char *profile,
edgex_error *err
Expand Down Expand Up @@ -104,7 +104,7 @@ static void toml_rtob2 (const char *raw, bool *ret)
/* Wrap toml_rtoi for uint16, uint32. */

static void toml_rtoui16
(const char *raw, uint16_t *ret, iot_logging_client *lc, edgex_error *err)
(const char *raw, uint16_t *ret, iot_logger_t *lc, edgex_error *err)
{
if (raw)
{
Expand All @@ -122,7 +122,7 @@ static void toml_rtoui16
}

static void toml_rtoui32
(const char *raw, uint32_t *ret, iot_logging_client *lc, edgex_error *err)
(const char *raw, uint32_t *ret, iot_logger_t *lc, edgex_error *err)
{
if (raw)
{
Expand Down Expand Up @@ -339,7 +339,7 @@ static char *get_nv_config_string

static uint32_t get_nv_config_uint32
(
iot_logging_client *lc,
iot_logger_t *lc,
const edgex_nvpairs *config,
const char *key,
edgex_error *err
Expand Down Expand Up @@ -369,7 +369,7 @@ static uint32_t get_nv_config_uint32

static uint16_t get_nv_config_uint16
(
iot_logging_client *lc,
iot_logger_t *lc,
const edgex_nvpairs *config,
const char *key,
edgex_error *err
Expand Down Expand Up @@ -584,9 +584,9 @@ void edgex_device_validateConfig (edgex_device_service *svc, edgex_error *err)
}
}

static void dumpArray (iot_logging_client *, const char *, char **);
static void dumpArray (iot_logger_t *, const char *, char **);

void dumpArray (iot_logging_client *log, const char *name, char **list)
void dumpArray (iot_logger_t *log, const char *name, char **list)
{
char *arr;
size_t arrlen = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/c/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ typedef struct edgex_device_config

toml_table_t *edgex_device_loadConfig
(
iot_logging_client *lc,
iot_logger_t *lc,
const char *dir,
const char *profile,
edgex_error *err
Expand Down
12 changes: 6 additions & 6 deletions src/c/consul.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

static edgex_nvpairs *read_pairs
(
iot_logging_client *lc,
iot_logger_t *lc,
const char *json,
edgex_error *err
)
Expand Down Expand Up @@ -110,7 +110,7 @@ static edgex_nvpairs *read_pairs

edgex_nvpairs *edgex_consul_client_get_config
(
iot_logging_client *lc,
iot_logger_t *lc,
void *location,
const char *servicename,
const char *profile,
Expand Down Expand Up @@ -160,7 +160,7 @@ edgex_nvpairs *edgex_consul_client_get_config

void edgex_consul_client_write_config
(
iot_logging_client *lc,
iot_logger_t *lc,
void *location,
const char *servicename,
const char *profile,
Expand Down Expand Up @@ -233,7 +233,7 @@ void edgex_consul_client_write_config

void edgex_consul_client_register_service
(
iot_logging_client *lc,
iot_logger_t *lc,
void *location,
const char *servicename,
const char *host,
Expand Down Expand Up @@ -286,7 +286,7 @@ void edgex_consul_client_register_service

void edgex_consul_client_query_service
(
iot_logging_client *lc,
iot_logger_t *lc,
void *location,
const char *servicename,
char **host,
Expand Down Expand Up @@ -350,7 +350,7 @@ void edgex_consul_client_query_service

bool edgex_consul_client_ping
(
iot_logging_client *lc,
iot_logger_t *lc,
void *location,
edgex_error *err
)
Expand Down
10 changes: 5 additions & 5 deletions src/c/consul.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@

bool edgex_consul_client_ping
(
iot_logging_client *lc,
iot_logger_t *lc,
void *location,
edgex_error *err
);

edgex_nvpairs *edgex_consul_client_get_config
(
iot_logging_client *lc,
iot_logger_t *lc,
void *location,
const char *servicename,
const char *profile,
Expand All @@ -31,7 +31,7 @@ edgex_nvpairs *edgex_consul_client_get_config

void edgex_consul_client_write_config
(
iot_logging_client *lc,
iot_logger_t *lc,
void *location,
const char *servicename,
const char *profile,
Expand All @@ -41,7 +41,7 @@ void edgex_consul_client_write_config

void edgex_consul_client_register_service
(
iot_logging_client *lc,
iot_logger_t *lc,
void *location,
const char *servicename,
const char *host,
Expand All @@ -52,7 +52,7 @@ void edgex_consul_client_register_service

void edgex_consul_client_query_service
(
iot_logging_client *lc,
iot_logger_t *lc,
void *location,
const char *servicename,
char **host,
Expand Down
Loading

0 comments on commit 76b6c10

Please sign in to comment.