diff --git a/meta-digi-arm/conf/machine/include/digi-defaults.inc b/meta-digi-arm/conf/machine/include/digi-defaults.inc index 92885819d..8abd7f5c5 100644 --- a/meta-digi-arm/conf/machine/include/digi-defaults.inc +++ b/meta-digi-arm/conf/machine/include/digi-defaults.inc @@ -91,4 +91,4 @@ BOOT_SCRIPTS += "boot.scr:boot.scr" SWUPDATE_UBOOTIMG ?= "false" # ConnectCore Cloud Services packages to install -CCCS_PKGS ?= "cccs-gs-demo" +CCCS_PKGS ?= "cccs-gs-demo dey-examples-cccs" diff --git a/meta-digi-dey/recipes-digi/dey-examples/dey-examples-cccs.bb b/meta-digi-dey/recipes-digi/dey-examples/dey-examples-cccs.bb new file mode 100644 index 000000000..ba19d5475 --- /dev/null +++ b/meta-digi-dey/recipes-digi/dey-examples/dey-examples-cccs.bb @@ -0,0 +1,26 @@ +# Copyright (C) 2017-2023 Digi International Inc. + +require recipes-digi/dey-examples/dey-examples-src.inc + +SUMMARY = "DEY examples: ConnectCore Cloud Services example applications" +SECTION = "examples" +LICENSE = "ISC" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/ISC;md5=f3b90e78ea0cffb20bf5cca7947a896d" + +DEPENDS = "cccs" + +S = "${WORKDIR}/git" + +inherit pkgconfig + +EXTRA_OEMAKE += "-f cccs-examples.mk" + +do_compile() { + oe_runmake +} + +do_install() { + oe_runmake DESTDIR=${D} install +} + +RDEPENDS:${PN} = "cccs-daemon" diff --git a/meta-digi-dey/recipes-digi/dey-examples/dey-examples-cloudconnector.bb b/meta-digi-dey/recipes-digi/dey-examples/dey-examples-cloudconnector.bb deleted file mode 100644 index 919f33792..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/dey-examples-cloudconnector.bb +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (C) 2017, 2018 Digi International Inc. - -SUMMARY = "DEY examples: Remote Manager test applications" -SECTION = "examples" -LICENSE = "MPL-2.0" -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad" - -DEPENDS = "cloudconnector" - -SRC_URI = "file://cloudconnector_test" - -S = "${WORKDIR}/cloudconnector_test" - -inherit pkgconfig - -do_install() { - oe_runmake DESTDIR=${D} install -} - -RDEPENDS:${PN} = "cloudconnector-cert" diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/Makefile b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/Makefile deleted file mode 100644 index 989acb8a6..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (c) 2017, Digi International Inc. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, you can obtain one at http://mozilla.org/MPL/2.0/. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# - -SUBDIRS := device_request_listener upload_data_points upload_file - -all: $(SUBDIRS) - -.PHONY: $(SUBDIRS) -$(SUBDIRS): - $(MAKE) -C $@ - -.PHONY: clean install -clean install: - for a in $(SUBDIRS); do $(MAKE) -C $$a $@; done diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/Makefile b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/Makefile deleted file mode 100644 index 068457973..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -# *************************************************************************** -# Copyright (c) 2017-2023 Digi International Inc. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this file, -# You can obtain one at http://mozilla.org/MPL/2.0/. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. -# -# Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 -# -# *************************************************************************** - -PROGRAM := device_request_listener - -CFLAGS += -Wall - -CFLAGS += $(shell pkg-config --cflags cloudconnector) -LDLIBS += $(shell pkg-config --libs --static cloudconnector) - -all: $(PROGRAM) - -OBJS = device_request.o main.o - -$(PROGRAM): $(OBJS) - $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ - -.PHONY: install -install: $(PROGRAM) - install -d $(DESTDIR)/usr/bin - install -m 0755 $(PROGRAM) $(DESTDIR)/usr/bin/ - -.PHONY: clean -clean: - -rm -f *.o $(PROGRAM) diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/device_request.c b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/device_request.c deleted file mode 100644 index 992a73f30..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/device_request.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2017-2023 Digi International Inc. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 - * =========================================================================== - */ - -#include -#include -#include -#include - -#include "device_request.h" - -#if !(defined UNUSED_ARGUMENT) -#define UNUSED_ARGUMENT(a) (void)(a) -#endif - -/* - * get_time_cb() - Data callback for 'get_time' device requests - * - * @target: Target ID of the device request (get_time). - * @transport: Communication transport used by the device request. - * @req_buf_info: Buffer containing the device request. - * @resp_buf_info: Buffer to store the answer of the request. - * - * Logs information about the received request and executes the corresponding - * command. - */ -ccapi_receive_error_t get_time_cb(char const *const target, - ccapi_transport_t const transport, - ccapi_buffer_info_t const *const req_buf_info, - ccapi_buffer_info_t *const resp_buf_info) -{ - time_t t = time(NULL); - char *time_str = ctime(&t); - - UNUSED_ARGUMENT(req_buf_info); - log_debug("%s: target='%s' - transport='%d'", __func__, target, transport); - - resp_buf_info->length = snprintf(NULL, 0, "Time: %s", time_str); - resp_buf_info->buffer = calloc(resp_buf_info->length + 1, sizeof(char)); - if (resp_buf_info->buffer == NULL) { - log_error("%s: resp_buf_info calloc error", __func__); - return CCAPI_RECEIVE_ERROR_INSUFFICIENT_MEMORY; - } - - resp_buf_info->length = sprintf(resp_buf_info->buffer, "Time: %s", time_str); - - return CCAPI_RECEIVE_ERROR_NONE; -} - -/* - * get_time_status_cb() - Status callback for 'get_time' device requests - * - * @target: Target ID of the device request (get_time) - * @transport: Communication transport used by the device request. - * @resp_buf_info: Buffer containing the response data. - * @receive_error: The error status of the receive process. - * - * This callback is executed when the response process has finished. It doesn't - * matter if everything worked or there was an error during the process. - * - * Cleans and frees the response buffer. - */ -void get_time_status_cb(char const *const target, - ccapi_transport_t const transport, - ccapi_buffer_info_t *const resp_buf_info, - ccapi_receive_error_t receive_error) -{ - log_debug("%s: target='%s' - transport='%d' - error='%d'", - __func__, target, transport, receive_error); - - /* Free the response buffer */ - if (resp_buf_info != NULL) - free(resp_buf_info->buffer); -} diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/device_request.h b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/device_request.h deleted file mode 100644 index bdd9530c3..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/device_request.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2017-2023 Digi International Inc. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 - * =========================================================================== - */ - -#ifndef DEVICE_REQUEST_H_ -#define DEVICE_REQUEST_H_ - -#include - -#define TARGET_GET_TIME "get_time" - -ccapi_receive_error_t get_time_cb(char const *const target, - ccapi_transport_t const transport, - ccapi_buffer_info_t const *const req_buf_info, - ccapi_buffer_info_t *const resp_buf_info); -void get_time_status_cb(char const *const target, - ccapi_transport_t const transport, - ccapi_buffer_info_t *const resp_buf_info, - ccapi_receive_error_t receive_error); - -#endif /* DEVICE_REQUEST_H_ */ diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/main.c b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/main.c deleted file mode 100644 index 4e29aca32..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/main.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2017-2023 Digi International Inc. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 - * =========================================================================== - */ - -#include -#include -#include -#include -#include - -#include "device_request.h" - -static void sigint_handler(int signum) -{ - log_debug("%s: received signal %d to close Cloud connection.", - __func__, signum); - - exit(0); -} - -static void graceful_shutdown(void) -{ - stop_cloud_connection(); -} - -static void add_sigkill_signal(void) -{ - struct sigaction new_action; - struct sigaction old_action; - - atexit(graceful_shutdown); - - /* Setup signal hander. */ - new_action.sa_handler = sigint_handler; - sigemptyset(&new_action.sa_mask); - new_action.sa_flags = 0; - sigaction(SIGINT, NULL, &old_action); - if (old_action.sa_handler != SIG_IGN) - sigaction(SIGINT, &new_action, NULL); -} - - -/* - * Use the following SCI request to test this example (insert your Device ID): - * - * - * - * - * - * - * - * - * - * - * - * - */ - -int main(void) -{ - cc_init_error_t init_error; - cc_start_error_t start_error; - ccapi_receive_error_t receive_error; - - add_sigkill_signal(); - - init_error = init_cloud_connection(NULL); - if (init_error != CC_INIT_ERROR_NONE) { - log_error("Cannot initialize cloud connection, error %d", init_error); - return EXIT_FAILURE; - } - - start_error = start_cloud_connection(); - if (start_error != CC_START_ERROR_NONE) { - log_error("Cannot start cloud connection, error %d", start_error); - return EXIT_FAILURE; - } - - receive_error = ccapi_receive_add_target(TARGET_GET_TIME, get_time_cb, - get_time_status_cb, 0); - if (receive_error != CCAPI_RECEIVE_ERROR_NONE) { - log_error("Cannot register target '%s', error %d", TARGET_GET_TIME, - receive_error); - return EXIT_FAILURE; - } - - printf("Waiting for Remote Manager request...\n"); - printf("Press a key to exit\n"); - getchar(); - - return EXIT_SUCCESS; -} diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/Makefile b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/Makefile deleted file mode 100644 index 80b011a0e..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -# *************************************************************************** -# Copyright (c) 2017-2023 Digi International Inc. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this file, -# You can obtain one at http://mozilla.org/MPL/2.0/. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. -# -# Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 -# -# *************************************************************************** - -PROGRAM := upload_data_points - -CFLAGS += -Wall - -CFLAGS += $(shell pkg-config --cflags cloudconnector) -LDLIBS += $(shell pkg-config --libs --static cloudconnector) - -all: $(PROGRAM) - -OBJS = data_point.o main.o - -$(PROGRAM): $(OBJS) - $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ - -.PHONY: install -install: $(PROGRAM) - install -d $(DESTDIR)/usr/bin - install -m 0755 $(PROGRAM) $(DESTDIR)/usr/bin/ - -.PHONY: clean -clean: - -rm -f *.o $(PROGRAM) diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/data_point.c b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/data_point.c deleted file mode 100644 index b469fe26b..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/data_point.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2017-2023 Digi International Inc. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 - * =========================================================================== - */ - -#include -#include -#include - -#include "data_point.h" - -#define STREAM_NAME "incremental" - -/* - * get_incremental() - Retrieves an incremental value each time - */ -static int get_incremental(void) -{ - static int incremental = -1; - - if (incremental == INT_MAX) - incremental = 0; - else - incremental++; - - log_debug("Incremental = %d", incremental); - - return incremental; -} - -/* - * get_timestamp() - Get the current timestamp of the system - * - * Return: The timestamp of the system. - */ -static ccapi_timestamp_t *get_timestamp(void) -{ - ccapi_timestamp_t *timestamp = NULL; - size_t len = strlen("2016-09-27T07:07:09.546Z") + 1; - char *date = NULL; - time_t now; - - timestamp = (ccapi_timestamp_t*) malloc(sizeof(ccapi_timestamp_t)); - if (timestamp == NULL) - return NULL; - - date = (char*) malloc(sizeof(char) * len); - if (date == NULL) { - free(timestamp); - return NULL; - } - - time(&now); - if (strftime(date, len, "%FT%TZ", gmtime(&now)) > 0) { - timestamp->iso8601 = date; - } else { - free(date); - timestamp->iso8601 = NULL; - } - - return timestamp; -} - -/* - * free_timestamp() - Free given timestamp structure - * - * @timestamp: The timestamp structure to release. - */ -static void free_timestamp(ccapi_timestamp_t *timestamp) -{ - if (timestamp == NULL) - return; - - if (timestamp->iso8601 != NULL) { - free((char *) timestamp->iso8601); - timestamp->iso8601 = NULL; - } - free(timestamp); - timestamp = NULL; -} - -ccapi_dp_error_t init_data_stream(ccapi_dp_collection_handle_t *dp_collection) -{ - ccapi_dp_collection_handle_t collection; - ccapi_dp_error_t dp_error = ccapi_dp_create_collection(&collection); - - if (dp_error != CCAPI_DP_ERROR_NONE) { - log_error("%s: error %d", __func__, dp_error); - return dp_error; - } else { - *dp_collection = collection; - } - - dp_error = ccapi_dp_add_data_stream_to_collection_extra(collection, - STREAM_NAME, "int32 ts_iso", "counts", NULL); - if (dp_error != CCAPI_DP_ERROR_NONE) { - log_error("%s: error %d", __func__, dp_error); - ccapi_dp_destroy_collection(collection); - *dp_collection = NULL; - } - - return dp_error; -} - -ccapi_dp_error_t add_data_point(ccapi_dp_collection_handle_t dp_collection) -{ - ccapi_timestamp_t *timestamp = get_timestamp(); - ccapi_dp_error_t dp_error = ccapi_dp_add(dp_collection, STREAM_NAME, - get_incremental(), timestamp); - - if (dp_error != CCAPI_DP_ERROR_NONE) - log_error("%s: failed with error: %d", __func__, dp_error); - - free_timestamp(timestamp); - - return dp_error; -} - -ccapi_dp_error_t send_data_stream(ccapi_dp_collection_handle_t dp_collection) -{ - ccapi_dp_error_t dp_error; - - log_debug("%s", "Sending Data Stream with new incremental value"); - - dp_error = ccapi_dp_send_collection(CCAPI_TRANSPORT_TCP, dp_collection); - if (dp_error != CCAPI_DP_ERROR_NONE) - log_error("%s: error %d", __func__, dp_error); - - return dp_error; -} - -ccapi_dp_error_t destroy_data_stream(ccapi_dp_collection_handle_t dp_collection) -{ - log_debug("%s", "Destroying Data Stream"); - return ccapi_dp_destroy_collection(dp_collection); -} diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/data_point.h b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/data_point.h deleted file mode 100644 index 8be777c93..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/data_point.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2017-2023 Digi International Inc. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 - * =========================================================================== - */ - -#ifndef DATA_POINT_H_ -#define DATA_POINT_H_ - -#include - -ccapi_dp_error_t init_data_stream(ccapi_dp_collection_handle_t *dp_collection); -ccapi_dp_error_t add_data_point(ccapi_dp_collection_handle_t dp_collection); -ccapi_dp_error_t send_data_stream(ccapi_dp_collection_handle_t dp_collection); -ccapi_dp_error_t destroy_data_stream(ccapi_dp_collection_handle_t dp_collection); - -#endif /* DATA_POINT_H_ */ diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/main.c b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/main.c deleted file mode 100644 index 9cf6ddce0..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/main.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2017-2023 Digi International Inc. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 - * =========================================================================== - */ - -#include -#include -#include -#include - -#include "data_point.h" - -#define DP_SLEEP_TIME 5 -#define DP_NUMBER 10 - -static int running = 1; -static ccapi_dp_collection_handle_t dp_collection; - -static void sigint_handler(int signum) -{ - log_debug("%s: received signal %d to close Cloud connection.", - __func__, signum); - - exit(0); -} - -static void graceful_shutdown(void) -{ - if (running == 1) - destroy_data_stream(dp_collection); - - running = 0; - stop_cloud_connection(); -} - -static void add_sigkill_signal(void) -{ - struct sigaction new_action; - struct sigaction old_action; - - atexit(graceful_shutdown); - - /* Setup signal hander. */ - new_action.sa_handler = sigint_handler; - sigemptyset(&new_action.sa_mask); - new_action.sa_flags = 0; - sigaction(SIGINT, NULL, &old_action); - if (old_action.sa_handler != SIG_IGN) - sigaction(SIGINT, &new_action, NULL); -} - - -int main(void) -{ - cc_init_error_t init_error; - cc_start_error_t start_error; - ccapi_dp_error_t dp_error; - int i; - - add_sigkill_signal(); - - init_error = init_cloud_connection(NULL); - if (init_error != CC_INIT_ERROR_NONE) { - log_error("Cannot initialize cloud connection, error %d", init_error); - return EXIT_FAILURE; - } - - start_error = start_cloud_connection(); - if (start_error != CC_START_ERROR_NONE) { - log_error("Cannot start cloud connection, error %d", start_error); - return EXIT_FAILURE; - } - - dp_error = init_data_stream(&dp_collection); - if (dp_error != CCAPI_DP_ERROR_NONE) { - log_error("Cannot initialize data stream, error %d", start_error); - return EXIT_FAILURE; - } - - running = CCAPI_TRUE; - while (running != CCAPI_FALSE) { - - /* Collect DP_NUMBER data points sampled each DP_SLEEP_TIME seconds */ - for (i = 0; i < DP_NUMBER; i++) { - dp_error = add_data_point(dp_collection); - - if (dp_error != CCAPI_DP_ERROR_NONE) { - log_error("Cannot add data point, error %d", start_error); - i--; - } - - sleep(DP_SLEEP_TIME); - } - - /* Send the block of collected data points */ - dp_error = send_data_stream(dp_collection); - if (dp_error != CCAPI_DP_ERROR_NONE) - log_error("Cannot send data stream, error %d", start_error); - } - - return EXIT_SUCCESS; -} diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_file/Makefile b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_file/Makefile deleted file mode 100644 index ff67e421a..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_file/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -# *************************************************************************** -# Copyright (c) 2017-2023 Digi International Inc. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this file, -# You can obtain one at http://mozilla.org/MPL/2.0/. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. -# -# Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 -# -# *************************************************************************** - -PROGRAM := upload_file - -CFLAGS += -Wall - -CFLAGS += $(shell pkg-config --cflags cloudconnector) -LDLIBS += $(shell pkg-config --libs --static cloudconnector) - -all: $(PROGRAM) - -OBJS = main.o - -$(PROGRAM): $(OBJS) - $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ - -.PHONY: install -install: $(PROGRAM) - install -d $(DESTDIR)/usr/bin - install -m 0755 $(PROGRAM) $(DESTDIR)/usr/bin/ - -.PHONY: clean -clean: - -rm -f *.o $(PROGRAM) diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_file/main.c b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_file/main.c deleted file mode 100644 index 69f9ad552..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_file/main.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2017-2023 Digi International Inc. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 - * =========================================================================== - */ - -#include -#include -#include -#include - -#define UNUSED_ARGUMENT(a) (void)(a) - -#define STREAM_NAME "examples/uploaded_file" -#define UPLOAD_FILE "/etc/build" - -static void sigint_handler(int signum) -{ - log_debug("%s: received signal %d to close Cloud connection.", - __func__, signum); - - exit(0); -} - -static void graceful_shutdown(void) -{ - stop_cloud_connection(); -} - -static void add_sigkill_signal(void) -{ - struct sigaction new_action; - struct sigaction old_action; - - atexit(graceful_shutdown); - - /* Setup signal hander. */ - new_action.sa_handler = sigint_handler; - sigemptyset(&new_action.sa_mask); - new_action.sa_flags = 0; - sigaction(SIGINT, NULL, &old_action); - if (old_action.sa_handler != SIG_IGN) - sigaction(SIGINT, &new_action, NULL); -} - -int main(int argc, char *argv[]) -{ - cc_init_error_t init_error; - cc_start_error_t start_error; - ccapi_dp_b_error_t send_error; - - UNUSED_ARGUMENT(argc); - - add_sigkill_signal(); - - init_error = init_cloud_connection(NULL); - if (init_error != CC_INIT_ERROR_NONE) { - log_error("Cannot initialize cloud connection, error %d", init_error); - return EXIT_FAILURE; - } - - start_error = start_cloud_connection(); - if (start_error != CC_START_ERROR_NONE) { - log_error("Cannot start cloud connection, error %d", start_error); - return EXIT_FAILURE; - } - - send_error = ccapi_dp_binary_send_file(CCAPI_TRANSPORT_TCP, UPLOAD_FILE, STREAM_NAME); - if (send_error != CCAPI_DP_B_ERROR_NONE) { - log_error("%s failed, error %d", __func__, send_error); - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} diff --git a/meta-digi-dey/recipes-digi/packagegroups/packagegroup-dey-examples.bb b/meta-digi-dey/recipes-digi/packagegroups/packagegroup-dey-examples.bb index eda018369..507429885 100644 --- a/meta-digi-dey/recipes-digi/packagegroups/packagegroup-dey-examples.bb +++ b/meta-digi-dey/recipes-digi/packagegroups/packagegroup-dey-examples.bb @@ -17,7 +17,7 @@ RDEPENDS:${PN} = "\ ${@bb.utils.contains("MACHINE_FEATURES", "mca", "dey-examples-adc-cmp \ dey-examples-tamper", "", d)} \ dey-examples-caamblob \ - dey-examples-cloudconnector \ + dey-examples-cccs \ dey-examples-digiapix \ dey-examples-rtc \ connectcore-demo-example-multimedia \