### Start Fledge Services Source: https://github.com/fledge-iot/fledge/blob/develop/docs/building_fledge/04_installation.rst Initiates the Fledge core and other associated services. This command starts the Fledge system, making it operational and ready for use. ```console $ bin/fledge start Starting Fledge...... Fledge started. ``` -------------------------------- ### Display Fledge Command-Line Utility Usage and Help Source: https://github.com/fledge-iot/fledge/blob/develop/docs/building_fledge/04_installation.rst Shows the general usage syntax for the Fledge command-line utility (`bin/fledge`) and provides detailed help information for its various subcommands, including `start`, `stop`, `status`, `reset`, `kill`, `help`, and `version`. ```console $ bin/fledge Usage: fledge {start|start --safe-mode|stop|status|reset|kill|help|version} $ bin/fledge help Usage: fledge {start|start --safe-mode|stop|status|reset|kill|help|version} Fledge v1.3.1 admin script The script is used to start Fledge Arguments: start - Start Fledge core (core will start other services). start --safe-mode - Start in safe mode (only core and storage services will be started) stop - Stop all Fledge services and processes kill - Kill all Fledge services and processes status - Show the status for the Fledge services reset - Restore Fledge factory settings WARNING! This command will destroy all your data! version - Print Fledge version help - This text ``` -------------------------------- ### Update System and Install Fledge Debian Package Source: https://github.com/fledge-iot/fledge/blob/develop/docs/building_fledge/04_installation.rst This set of commands guides through the process of preparing the system and installing the Fledge Debian package. It includes updating and upgrading system packages, copying the downloaded Fledge .deb file to the APT cache directory, and finally installing it using `apt install`. The output illustrates the package unpacking and service setup process. ```console $ sudo apt update Hit:1 http://gb.archive.ubuntu.com/ubuntu xenial InRelease ... $ sudo apt upgrade ... $ sudo apt update ... $ sudo cp fledge-1.8.0-x86_64.deb /var/cache/apt/archives/. ... $ sudo apt install /var/cache/apt/archives/fledge-1.8.0-x86_64.deb Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'fledge' instead of '/var/cache/apt/archives/fledge-1.8.0-x86_64.deb' The following packages were automatically installed and are no longer required: ... Unpacking fledge (1.8.0) ... Setting up fledge (1.8.0) ... Resolving data directory Data directory does not exist. Using new data directory Installing service script Generating certificate files Certificate files do not exist. Generating new certificate files. Creating a self signed SSL certificate ... Certificates created successfully, and placed in data/etc/certs Generating auth certificate files CA Certificate file does not exist. Generating new CA certificate file. Creating ca SSL certificate ... ca certificate created successfully, and placed in data/etc/certs Admin Certificate file does not exist. Generating new admin certificate file. Creating user SSL certificate ... user certificate created successfully for admin, and placed in data/etc/certs User Certificate file does not exist. Generating new user certificate file. Creating user SSL certificate ... user certificate created successfully for user, and placed in data/etc/certs Setting ownership of Fledge files Calling Fledge package update script Linking update task Changing setuid of update_task.apt Removing task/update Create link file Copying sudoers file Setting setuid bit of cmdutil Enabling Fledge service fledge.service is not a native service, redirecting to systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable fledge Starting Fledge service $ ``` -------------------------------- ### Install RapidJSON Examples Directory Source: https://github.com/fledge-iot/fledge/blob/develop/C/thirdparty/rapidjson/CMakeLists.txt This snippet installs the `example/` directory to the documentation examples path. It includes patterns to exclude common build artifacts like `CMakeFiles`, `Makefile`, and `cmake_install.cmake` from the installed examples, ensuring a clean installation. ```CMake install(DIRECTORY example/ DESTINATION "${DOC_INSTALL_DIR}/examples" COMPONENT examples # Following patterns are for excluding the intermediate/object files # from an install of in-source CMake build. PATTERN "CMakeFiles" EXCLUDE PATTERN "Makefile" EXCLUDE PATTERN "cmake_install.cmake" EXCLUDE) ``` -------------------------------- ### Verify Fledge Installation Directory Contents Source: https://github.com/fledge-iot/fledge/blob/develop/docs/building_fledge/04_installation.rst Navigates to the Fledge installation root directory and lists its contents to verify the successful installation of various Fledge components such as `bin`, `data`, `plugins`, and `services`. ```console $ cd /usr/local/fledge/ $ ls -l total 32 drwxr-xr-x 2 root root 4096 Apr 24 18:07 bin drwxr-xr-x 4 fledge fledge 4096 Apr 24 18:07 data drwxr-xr-x 4 root root 4096 Apr 24 18:07 extras drwxr-xr-x 4 root root 4096 Apr 24 18:07 plugins drwxr-xr-x 3 root root 4096 Apr 24 18:07 python drwxr-xr-x 6 root root 4096 Apr 24 18:07 scripts drwxr-xr-x 2 root root 4096 Apr 24 18:07 services -rwxr-xr-x 1 root root 37 Apr 24 18:07 VERSION ``` -------------------------------- ### Start Fledge from Build Environment Source: https://github.com/fledge-iot/fledge/blob/develop/docs/building_fledge/building_fledge.rst Demonstrates how to set the `FLEDGE_ROOT` environment variable to the Fledge project directory and then start the Fledge application using the `fledge start` command. ```console $ pwd /home/ubuntu/fledge $ export FLEDGE_ROOT=/home/ubuntu/fledge $ ./scripts/fledge start Starting Fledge vX.X..... Fledge started. $ ``` -------------------------------- ### Managing Fledge as a Linux Systemd Service Source: https://github.com/fledge-iot/fledge/blob/develop/docs/building_fledge/04_installation.rst This set of console commands illustrates the process of installing and managing Fledge as a systemd service. It covers copying the `fledge.service` file to `/etc/init.d`, enabling the service to start on boot, and checking its current status. The output demonstrates the service's lifecycle, from inactive to active (running). ```console $ sudo cp /usr/local/fledge/extras/scripts/fledge.service /etc/init.d/fledge $ sudo systemctl status fledge.service ● fledge.service Loaded: not-found (Reason: No such file or directory) Active: inactive (dead) $ sudo systemctl enable fledge.service fledge.service is not a native service, redirecting to systemd-sysv-install Executing /lib/systemd/systemd-sysv-install enable fledge $ sudo systemctl status fledge.service ● fledge.service - LSB: Fledge Loaded: loaded (/etc/init.d/fledge; bad; vendor preset: enabled) Active: inactive (dead) Docs: man:systemd-sysv-generator(8) $ sudo systemctl start fledge.service $ sudo systemctl status fledge.service ● fledge.service - LSB: Fledge Loaded: loaded (/etc/init.d/fledge; generated) Active: active (running) since Thu 2020-05-28 18:42:07 IST; 9min ago Docs: man:systemd-sysv-generator(8) Process: 5047 ExecStart=/etc/init.d/fledge start (code=exited, status=0/SUCCESS) Tasks: 27 (limit: 4680) CGroup: /system.slice/fledge.service ├─5123 python3 -m fledge.services.core ├─5331 /usr/local/fledge/services/fledge.services.storage --address=0.0.0.0 --port=34827 ├─8119 /bin/sh tasks/north_c --port=34827 --address=127.0.0.1 --name=OMF to PI north └─8120 ./tasks/sending_process --port=34827 --address=127.0.0.1 --name=OMF to PI north ... ``` -------------------------------- ### Run Fledge Services and Tasks Source: https://github.com/fledge-iot/fledge/blob/develop/docs/building_fledge/building_fledge.rst Examples of command-line invocations for starting specific Fledge services like notifications and tasks such as purge and sending processes. These commands typically run Fledge components with specified ports, addresses, and names. ```console fledge.services.notification --port=42583 --address=127.0.0.1 --name=Fledge Notifications fledge.tasks.purge --port=42583 --address=127.0.0.1 --name=purge tasks/sending_process --port=42583 --address=127.0.0.1 --name=PI Server ``` -------------------------------- ### Install Fledge from Built Source Source: https://github.com/fledge-iot/fledge/blob/develop/docs/building_fledge/04_installation.rst Executes the default installation of Fledge from a previously built source. This command installs Fledge into the `/usr/local/fledge` directory and requires superuser privileges. It performs directory creation, compilation, file copying, and ownership adjustments. ```console $ sudo make install mkdir -p /usr/local/fledge Installing Fledge version 1.8.0, DB schema 2 -- Fledge DB schema check OK: Info: /usr/local/fledge is empty right now. Skipping DB schema check. cp VERSION /usr/local/fledge cd cmake_build ; cmake /home/fledge/Fledge/ -- Boost version: 1.58.0 -- Found the following Boost libraries: -- system -- thread -- chrono -- date_time -- atomic -- Found SQLite version 3.11.0: /usr/lib/x86_64-linux-gnu/libsqlite3.so -- Boost version: 1.58.0 -- Found the following Boost libraries: -- system -- thread -- chrono -- date_time -- atomic -- Configuring done -- Generating done -- Build files have been written to: /home/fledge/Fledge/cmake_build cd cmake_build ; make make[1]: Entering directory '/home/fledge/Fledge/cmake_build' ... ``` -------------------------------- ### Fledge Plugin Installation Notes File Content Source: https://github.com/fledge-iot/fledge/blob/develop/docs/plugin_developers_guide/09_packaging.rst Example content of the `install_notes.txt` file. This optional file can be included in the plugin package to provide specific instructions or recommendations that will be displayed to the user at the end of the installation process. ```console $ cat install_notes.txt It is required to reboot the RPi, please do the following steps: 1) sudo reboot ``` -------------------------------- ### Install RapidJSON System-Wide Source: https://github.com/fledge-iot/fledge/blob/develop/C/thirdparty/rapidjson/readme.md Use this command with administrative privileges to install RapidJSON headers and libraries to standard system paths, making it available globally. ```Shell make install ``` -------------------------------- ### Install RapidJSON using vcpkg Source: https://github.com/fledge-iot/fledge/blob/develop/C/thirdparty/rapidjson/readme.md Command to install RapidJSON via the vcpkg dependency manager, which simplifies compilation and integration into C++ projects. ```Shell vcpkg install rapidjson ``` -------------------------------- ### Start Fledge Core Daemon (Development) Source: https://github.com/fledge-iot/fledge/blob/develop/README.rst Initiates the Fledge core daemon using the FLEDGE_ROOT environment variable, starting the Fledge application from the development setup. ```bash $FLEDGE_ROOT/scripts/fledge start ``` -------------------------------- ### Build Examples and Install Headers for Standalone Project Source: https://github.com/fledge-iot/fledge/blob/develop/C/thirdparty/Simple-Web-Server/CMakeLists.txt This large conditional block executes only when the `Simple-Web-Server` project is being built as a top-level project, not as a sub-project. It adds compiler options (e.g., C++11, warnings), finds Boost components for examples, creates `http_examples` and `https_examples` executables, links them to the library and Boost, and finally defines the installation rules for the public header files. ```CMake if(CMAKE_SOURCE_DIR STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") if(NOT MSVC) add_compile_options(-std=c++11 -Wall -Wextra) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wthread-safety) endif() else() add_compile_options(/W1) endif() find_package(Boost 1.53.0 COMPONENTS system thread filesystem) if(Boost_FOUND) add_executable(http_examples http_examples.cpp) target_link_libraries(http_examples simple-web-server) target_link_libraries(http_examples ${Boost_LIBRARIES}) target_include_directories(http_examples PRIVATE ${Boost_INCLUDE_DIR}) if(OPENSSL_FOUND) add_executable(https_examples https_examples.cpp) target_link_libraries(https_examples simple-web-server) target_link_libraries(https_examples ${Boost_LIBRARIES}) target_include_directories(https_examples PRIVATE ${Boost_INCLUDE_DIR}) endif() endif() install(FILES asio_compatibility.hpp server_http.hpp client_http.hpp server_https.hpp client_https.hpp crypto.hpp utility.hpp status_code.hpp mutex.hpp DESTINATION include/simple-web-server) endif() ``` -------------------------------- ### Install Google Test Framework Source: https://github.com/fledge-iot/fledge/blob/develop/tests/unit/C/plugins/storage/postgres/README.rst Commands to install the Google Test framework on a Debian/Ubuntu system. This involves installing the development package, navigating to the source directory, and then building and installing the framework. ```Shell sudo apt-get install libgtest-dev cd /usr/src/gtest cmake CMakeLists.txt sudo make sudo make install ``` -------------------------------- ### Initialize Git Submodules for RapidJSON Source: https://github.com/fledge-iot/fledge/blob/develop/C/thirdparty/rapidjson/readme.md Execute this command to fetch and initialize third-party submodules, such as googletest, required for building and testing RapidJSON. ```Shell git submodule update --init ``` -------------------------------- ### Install Fledge South OpenWeather Plugin via Package Manager Source: https://github.com/fledge-iot/fledge/blob/develop/docs/plugin_developers_guide/01_Fledge_plugins.rst This snippet demonstrates the process of installing a Fledge plugin (OpenWeather South plugin) when it's available as a package. It includes checking the Fledge service status, copying the .deb package to the apt cache, installing it using `apt`, and finally verifying the successful installation by checking Fledge's status and active services. ```console $ sudo systemctl status fledge.service ● fledge.service - LSB: Fledge Loaded: loaded (/etc/init.d/fledge; bad; vendor preset: enabled) Active: active (running) since Wed 2018-05-16 01:32:25 BST; 4min 1s ago Docs: man:systemd-sysv-generator(8) CGroup: /system.slice/fledge.service ├─13741 python3 -m fledge.services.core └─13746 /usr/local/fledge/services/storage --address=0.0.0.0 --port=40138 May 16 01:36:09 ubuntu python3[13741]: Fledge[13741] INFO: scheduler: fledge.services.core.scheduler.scheduler: Process started: Schedule 'stats collection' process 'stats coll ['tasks/statistics', '--port=40138', '--address=127.0.0.1', '--name=stats collector'] ... Fledge v1.3.1 running. Fledge Uptime: 266 seconds. Fledge records: 0 read, 0 sent, 0 purged. Fledge does not require authentication. === Fledge services: fledge.services.core === Fledge tasks: $ $ sudo cp fledge-south-openweathermap-1.2-x86_64.deb /var/cache/apt/archives/. $ sudo apt install /var/cache/apt/archives/fledge-south-openweathermap-1.2-x86_64.deb Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'fledge-south-openweathermap' instead of '/var/cache/apt/archives/fledge-south-openweathermap-1.2-x86_64.deb' The following packages were automatically installed and are no longer required: linux-headers-4.4.0-109 linux-headers-4.4.0-109-generic linux-headers-4.4.0-119 linux-headers-4.4.0-119-generic linux-headers-4.4.0-121 linux-headers-4.4.0-121-generic linux-image-4.4.0-109-generic linux-image-4.4.0-119-generic linux-image-4.4.0-121-generic linux-image-extra-4.4.0-109-generic linux-image-extra-4.4.0-119-generic linux-image-extra-4.4.0-121-generic Use 'sudo apt autoremove' to remove them. The following NEW packages will be installed fledge-south-openweathermap 0 to upgrade, 1 to newly install, 0 to remove and 0 not to upgrade. Need to get 0 B/3,404 B of archives. After this operation, 0 B of additional disk space will be used. Selecting previously unselected package fledge-south-openweathermap. (Reading database ... 211747 files and directories currently installed.) Preparing to unpack .../fledge-south-openweathermap-1.2-x86_64.deb ... Unpacking fledge-south-openweathermap (1.2) ... Setting up fledge-south-openweathermap (1.2) ... openweathermap plugin installed. $ $ fledge status Fledge v1.3.1 running. Fledge Uptime: 271 seconds. Fledge records: 36 read, 0 sent, 0 purged. Fledge does not require authentication. === Fledge services: fledge.services.core fledge.services.south --port=42066 --address=127.0.0.1 --name=openweathermap === Fledge tasks: $ ``` -------------------------------- ### Build RapidJSON on Linux/macOS Source: https://github.com/fledge-iot/fledge/blob/develop/C/thirdparty/rapidjson/readme.md After CMake configuration, use this command to compile the RapidJSON library, tests, and examples on Linux or macOS systems. ```Shell make ``` -------------------------------- ### Compile and Execute SimpleWeb HTTP Server Example (Shell) Source: https://github.com/fledge-iot/fledge/blob/develop/C/thirdparty/Simple-Web-Server/docs/benchmarks.md This shell script outlines the steps to build and run the SimpleWeb HTTP server example. It uses CMake for project configuration, specifying `g++-9` as the compiler and enabling optimizations. After compilation with `make`, the script executes the generated `http_examples` binary, starting the server. ```sh mkdir build && cd build CXX=g++-9 CXXFLAGS="-O2 -DNDEBUG -flto" cmake .. make ./http_examples ``` -------------------------------- ### Install Google Test Framework Dependencies Source: https://github.com/fledge-iot/fledge/blob/develop/tests/unit/C/plugins/storage/sqlite/README.rst Commands to install the Google Unit Test framework, including fetching development libraries, navigating to the source directory, configuring with CMake, and compiling/installing the framework. ```bash sudo apt-get install libgtest-dev cd /usr/src/gtest cmake CMakeLists.txt sudo make sudo make install ``` -------------------------------- ### Start Fledge System Source: https://github.com/fledge-iot/fledge/blob/develop/docs/quick_start/starting.rst Demonstrates how to start the Fledge system using the command line utility. This command typically does not require authentication. ```console /usr/local/fledge/bin/fledge start ``` -------------------------------- ### Fledge Plugin Extra Installation Script Source: https://github.com/fledge-iot/fledge/blob/develop/docs/plugin_developers_guide/09_packaging.rst Example content of the `extras_install.sh` shell script. This optional script is executed as part of the plugin package installation, allowing for custom commands. It includes logic to identify the operating system and architecture for conditional execution. ```bash #!/usr/bin/env bash os_name=$(grep -o '^NAME=.*' /etc/os-release | cut -f2 -d\" | sed 's/"//g') os_version=$(grep -o '^VERSION_ID=.*' /etc/os-release | cut -f2 -d\" | sed 's/"//g') echo "Platform is ${os_name}, Version: ${os_version}" arch=`arch` ID=$(cat /etc/os-release | grep -w ID | cut -f2 -d"=") if [ ${ID} != "mendel" ]; then case $os_name in *"Ubuntu"*) if [ ${arch} = "aarch64" ]; then python3 -m pip install --upgrade pip fi ;; esac fi ``` -------------------------------- ### Initialize and Run Basic HTTP Server with SimpleWeb (C++) Source: https://github.com/fledge-iot/fledge/blob/develop/C/thirdparty/Simple-Web-Server/docs/benchmarks.md This C++ code snippet demonstrates setting up a simple HTTP server using the SimpleWeb library. It configures the server to listen on port 3000 and defines a default GET endpoint that responds with "Hello World!". This example showcases basic server initialization and request handling. ```c++ #include "server_http.hpp" using HttpServer = SimpleWeb::Server; int main() { HttpServer server; server.config.port = 3000; server.default_resource["GET"] = [](std::shared_ptr response, std::shared_ptr /*request*/) { response->write("Hello World!", {{"Date", SimpleWeb::Date::to_string(std::chrono::system_clock::now())}}); }; server.start(); } ``` -------------------------------- ### Run RapidJSON Tests Source: https://github.com/fledge-iot/fledge/blob/develop/C/thirdparty/rapidjson/readme.md Commands to execute the compiled unit and performance tests for RapidJSON. 'ctest -V' provides verbose output for detailed results. ```Shell make test ``` ```Shell ctest ``` ```Shell ctest -V ``` -------------------------------- ### Install Fledge Project Build Requirements Source: https://github.com/fledge-iot/fledge/blob/develop/docs/building_fledge/building_fledge.rst Shows how to execute the `requirements.sh` script with `sudo` to install necessary dependencies for building Fledge on a Linux system, including a prompt for the sudo password and initial output. ```console $ sudo ./requirements.sh [sudo] password for john: Platform is Ubuntu, Version: 20.04 apt 1.6.14 (amd64) Reading package lists... Building dependency tree... ... ``` -------------------------------- ### Configure RapidJSON Build with CMake Source: https://github.com/fledge-iot/fledge/blob/develop/C/thirdparty/rapidjson/readme.md Run this command from within the 'build' directory to configure the RapidJSON project using CMake, preparing it for compilation on various platforms. ```Shell cmake .. ``` -------------------------------- ### List PostgreSQL Databases as Current Linux User Source: https://github.com/fledge-iot/fledge/blob/develop/docs/building_fledge/building_fledge.rst Executes the `psql -l` command from the current Linux user's context. This final step confirms that the newly created PostgreSQL user (matching the Linux user) can successfully connect to the PostgreSQL server and list the available databases, indicating a successful setup. ```console psql -l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | template0 | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres (3 rows) ``` -------------------------------- ### Download Fledge TGZ Package Source: https://github.com/fledge-iot/fledge/blob/develop/docs/building_fledge/04_installation.rst This snippet demonstrates how to download the Fledge TGZ package for Intel x86_64 architecture from the official S3 bucket using the `wget` command. The output shows the download progress and successful saving of the file. ```console $ wget https://fledge-iot.s3.us-east-1.amazonaws.com/latest/ubuntu2004/x86_64/fledge.tgz --2025-06-26 13:08:24-- https://fledge-iot.s3.us-east-1.amazonaws.com/latest/ubuntu2004/x86_64/fledge.tgz Resolving fledge-iot.s3.us-east-1.amazonaws.com (fledge-iot.s3.us-east-1.amazonaws.com)... 54.231.233.50, 54.231.232.162, 16.182.38.114, ... Connecting to fledge-iot.s3.us-east-1.amazonaws.com (fledge-iot.s3.us-east-1.amazonaws.com)|54.231.233.50|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 42015699 (40M) [application/x-tar] Saving to: ‘fledge.tgz’ fledge.tgz 100%[===================================================================================================================>] 40.07M 7.03MB/s in 17s 2025-06-26 13:08:42 (2.40 MB/s) - ‘fledge.tgz’ saved [42015699/42015699] $ ``` -------------------------------- ### Viewing and Sourcing the Fledge Environment Script Source: https://github.com/fledge-iot/fledge/blob/develop/docs/building_fledge/04_installation.rst These console commands demonstrate how to inspect the contents of the `setenv.sh` script using `cat` and how to execute it in the current shell session using `source`. Sourcing the script applies the defined environment variables to the current terminal, making Fledge commands and libraries accessible. ```console $ cat /usr/local/fledge/extras/scripts/setenv.sh #!/bin/sh ##-------------------------------------------------------------------- ## Copyright (c) 2018 OSIsoft, LLC ## ## Licensed under the Apache License, Version 2.0 (the "License"); ## you may not use this file except in compliance with the License. ## You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ##-------------------------------------------------------------------- # # This script sets the user environment to facilitate the administration # of Fledge # # You can execute this script from shell, using for example this command: # # source /usr/local/fledge/extras/scripts/setenv.sh # # or you can add the same command at the bottom of your profile script # {HOME}/.profile. # export FLEDGE_ROOT="/usr/local/fledge" export FLEDGE_DATA="${FLEDGE_ROOT}/data" export PATH="${FLEDGE_ROOT}/bin:${PATH}" export LD_LIBRARY_PATH="${FLEDGE_ROOT}/lib:${LD_LIBRARY_PATH}" $ source /usr/local/fledge/extras/scripts/setenv.sh $ ``` -------------------------------- ### Example: Retrieve 'rest_api' Category Configuration via curl Source: https://github.com/fledge-iot/fledge/blob/develop/docs/rest_api_guide/03_RESTadmin.rst Illustrates how to use the `curl` command-line tool to make a GET request to the `/fledge/category/rest_api` endpoint. The example includes the full `curl` command and the detailed JSON response payload, showcasing various configuration items related to the Fledge REST API. ```console $ curl -X GET http://localhost:8081/fledge/category/rest_api { "enableHttp": { "description": "Enable HTTP (disable to use HTTPS)", "type": "boolean", "default": "true", "displayName": "Enable HTTP", "order": "1", "value": "true" }, "httpPort": { "description": "Port to accept HTTP connections on", "type": "integer", "default": "8081", "displayName": "HTTP Port", "order": "2", "value": "8081" }, "httpsPort": { "description": "Port to accept HTTPS connections on", "type": "integer", "default": "1995", "displayName": "HTTPS Port", "order": "3", "validity": "enableHttp==\"false\"", "value": "1995" }, "certificateName": { "description": "Certificate file name", "type": "string", "default": "fledge", "displayName": "Certificate Name", "order": "4", "validity": "enableHttp==\"false\"", "value": "fledge" }, "authentication": { "description": "API Call Authentication", "type": "enumeration", "options": [ "mandatory", "optional" ], "default": "optional", "displayName": "Authentication", "order": "5", "value": "optional" }, "authMethod": { "description": "Authentication method", "type": "enumeration", "options": [ "any", "password", "certificate" ], "default": "any", "displayName": "Authentication method", "order": "6", "value": "any" }, "authCertificateName": { "description": "Auth Certificate name", "type": "string", "default": "ca", "displayName": "Auth Certificate", "order": "7", "value": "ca" }, "allowPing": { "description": "Allow access to ping, regardless of the authentication required and authentication header", "type": "boolean", "default": "true", "displayName": "Allow Ping", "order": "8", "value": "true" }, "authProviders": { "description": "Authentication providers to use for the interface (JSON array object)", "type": "JSON", "default": "{\"providers\": [\"username\", \"ldap\"] }", "displayName": "Auth Providers" ``` -------------------------------- ### Fledge Project Examples CMake Build Script Source: https://github.com/fledge-iot/fledge/blob/develop/C/thirdparty/rapidjson/example/CMakeLists.txt This CMakeLists.txt file configures the build process for a collection of examples in the Fledge project. It sets the minimum required CMake version, defines a list of example names, includes necessary header directories, adds standard C format macros, and applies compiler-specific flags such as '-pthread' for GNU compilers. The script then creates executable targets for an archiver test and each defined example, finally setting up a custom target to build all examples. ```CMake cmake_minimum_required(VERSION 2.8) if(POLICY CMP0054) cmake_policy(SET CMP0054 NEW) endif() set(EXAMPLES capitalize condense filterkey filterkeydom jsonx lookaheadparser messagereader parsebyparts pretty prettyauto schemavalidator serialize simpledom simplereader simplepullreader simplewriter sortkeys tutorial) include_directories("../include/") add_definitions(-D__STDC_FORMAT_MACROS) set_property(DIRECTORY PROPERTY COMPILE_OPTIONS ${EXTRA_CXX_FLAGS}) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") endif() add_executable(archivertest archiver/archiver.cpp archiver/archivertest.cpp) foreach (example ${EXAMPLES}) add_executable(${example} ${example}/${example}.cpp) endforeach() if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") target_link_libraries(parsebyparts pthread) endif() add_custom_target(examples ALL DEPENDS ${EXAMPLES}) ``` -------------------------------- ### Install Fledge Core and GUI using APT Source: https://github.com/fledge-iot/fledge/blob/develop/docs/quick_start/installing.rst Commands to install the main Fledge package and its graphical user interface on Debian-based systems using `apt`. This sets up the fundamental Fledge components. ```console sudo DEBIAN_FRONTEND=noninteractive apt -y install ./fledge_2.3.0_x86_64.deb sudo apt -y install ./fledge-gui_2.3.0.deb ``` -------------------------------- ### Install Fledge Utilities to Destination Directory Source: https://github.com/fledge-iot/fledge/blob/develop/C/plugins/utils/CMakeLists.txt These commands specify the installation procedure for the compiled `get_plugin_info` and `cmdutil` executables. Both utilities are configured to be installed into the `fledge/extras/C` subdirectory within the overall installation prefix. ```CMake install(TARGETS ${PROJECT_NAME} DESTINATION fledge/extras/C) install(TARGETS cmdutil DESTINATION fledge/extras/C) ``` -------------------------------- ### Install Core Fledge Components and Plugins Source: https://github.com/fledge-iot/fledge/blob/develop/docs/quick_start/installing.rst This command demonstrates how to install multiple Fledge packages simultaneously, including the core Fledge system, the graphical user interface, and a south plugin (sinusoid). The `DEBIAN_FRONTEND=noninteractive` ensures a non-interactive installation process. ```console sudo DEBIAN_FRONTEND=noninteractive apt -y install fledge fledge-gui fledge-south-sinusoid ``` -------------------------------- ### Install Downloaded Fledge .deb Package Source: https://github.com/fledge-iot/fledge/blob/develop/docs/quick_start/installing.rst If Fledge packages are downloaded directly (e.g., from a download link), they can be installed using `apt` by specifying the local filename. This method is useful for offline installations or when not using the package repository. Remember to replace `` with the actual path to the `.deb` file. ```console sudo apt -y install ``` -------------------------------- ### Install RapidJSON Readme Documentation Source: https://github.com/fledge-iot/fledge/blob/develop/C/thirdparty/rapidjson/CMakeLists.txt This snippet handles the installation of the `readme.md` file. It places the file into the designated documentation installation directory, making it accessible after the project is installed. ```CMake install(FILES readme.md DESTINATION "${DOC_INSTALL_DIR}" COMPONENT doc) ``` -------------------------------- ### Define Installation Rules for Plugin Components Source: https://github.com/fledge-iot/fledge/blob/develop/C/plugins/storage/sqlitelb/CMakeLists.txt This section defines the installation targets for the built plugin. It conditionally installs the SQLite3 command-line tool, installs the compiled shared library, and copies two SQL initialization scripts (`init.sql` and `init_readings.sql`) into the Fledge plugin's storage directory structure. ```CMake if(EXISTS ${FLEDGE_SQLITE3_LIBS}) install(PROGRAMS ${FLEDGE_SQLITE3_LIBS}/sqlite3 DESTINATION "fledge/plugins/storage/${PROJECT_NAME}") endif() # Install library install(TARGETS ${PROJECT_NAME} DESTINATION fledge/plugins/storage/${PROJECT_NAME}) # Install init.sql install(FILES ${CMAKE_SOURCE_DIR}/scripts/plugins/storage/${PROJECT_NAME}/init.sql DESTINATION fledge/plugins/storage/${PROJECT_NAME}) install(FILES ${CMAKE_SOURCE_DIR}/scripts/plugins/storage/${PROJECT_NAME}/init_readings.sql DESTINATION fledge/plugins/storage/${PROJECT_NAME}) ``` -------------------------------- ### Build the Fledge Project using Make Source: https://github.com/fledge-iot/fledge/blob/develop/docs/building_fledge/building_fledge.rst Demonstrates compiling and building the Fledge project by running the `make` command, including output showing certificate creation and successful Python package installation. ```console $ make Building Fledge version X.X., DB schema X scripts/certificates "fledge" "365" Creating a self signed SSL certificate ... Certificates created successfully, and placed in data/etc/certs scripts/auth_certificates ca "ca" "365" ... Successfully installed aiohttp-3.8.1 aiohttp-cors-0.7.0 aiosignal-1.2.0 async-timeout-4.0.2 asynctest-0.13.0 attrs-22.1.0 cchardet-2.1.4 certifi-2022.6.15 charset-normalizer-2.1.1 frozenlist-1.2.0 idna-3.3 idna-ssl-1.1.0 ifaddr-0.2.0 multidict-5.2.0 pyjq-2.3.1 pyjwt-1.6.4 requests-2.27.1 requests-toolbelt-0.9.1 six-1.16.0 typing-extensions-4.1.1 urllib3-1.26.12 yarl-1.7.2 zeroconf-0.27.0 $ ``` -------------------------------- ### Fledge Lab Setup and Execution Commands Source: https://github.com/fledge-iot/fledge/blob/develop/tests/system/lab/README.rst Provides commands for setting up the Fledge Lab environment, cloning the repository, and executing the test scripts with optional arguments for version and iterations. ```bash sudo apt install git ``` ```bash cd tests/system/lab/ ``` ```bash ./run ``` ```bash ./run 1.7.0RC ``` ```bash ./run_until_fails 10 1.7.0RC ``` -------------------------------- ### Install Google Test Framework Source: https://github.com/fledge-iot/fledge/blob/develop/tests/unit/C/services/storage/postgres/plugins/common/README.rst Commands to install the Google Unit Test framework (libgtest-dev) on a Debian-based system, including building and installing from source. ```bash sudo apt-get install libgtest-dev cd /usr/src/gtest cmake CMakeLists.txt sudo make sudo make install ``` -------------------------------- ### C Plugin Information Discovery Example Source: https://github.com/fledge-iot/fledge/blob/develop/docs/plugin_developers_guide/02_writing_plugins.rst Example C code for the `plugin_info` entry point, demonstrating how to use `DeviceDiscovery` to alter default configuration. This function populates an enumeration with discovered devices before returning the plugin information. ```C /** * Return the information about this plugin */ PLUGIN_INFORMATION *plugin_info() { DeviceDiscovery discover; char *config = discover.discover(default_config, "discovered"); info.config = config; return &info; } ``` -------------------------------- ### Verify Fledge Package Installation Source: https://github.com/fledge-iot/fledge/blob/develop/docs/building_fledge/04_installation.rst This command snippet shows how to confirm that the Fledge Debian package has been successfully installed on the system. It uses `dpkg -l` to list installed packages and `grep fledge` to filter for the Fledge entry, displaying its version and description. ```console $ sudo dpkg -l | grep fledge ii fledge 1.8.0 amd64 Fledge, the open source platform for the Internet of Things $ ``` -------------------------------- ### Install Fledge South DHT Plugin to System-Wide Fledge Location Source: https://github.com/fledge-iot/fledge/blob/develop/docs/plugin_developers_guide/03_02_DHT11_C.rst Creates the plugin directory under the system-wide Fledge installation path and copies the compiled 'libdht.so' file. This applies when Fledge was installed using 'sudo make install'. ```console sudo mkdir -p /usr/local/fledge/plugins/south/dht sudo cp libdht.so /usr/local/fledge/plugins/south/dht ``` -------------------------------- ### Find RapidJSON in CMake Project Source: https://github.com/fledge-iot/fledge/blob/develop/C/thirdparty/rapidjson/readme.md Add this line to your CMakeLists.txt file to locate and link against the installed RapidJSON library in another CMake-based project. ```CMake find_package(RapidJSON) ``` -------------------------------- ### Install Adafruit Python DHT Library Source: https://github.com/fledge-iot/fledge/blob/develop/docs/plugin_developers_guide/03_01_DHT11.rst This console snippet outlines the steps to install the Adafruit Python DHT library, a prerequisite for the Fledge DHT11 plugin. It involves cloning the GitHub repository, installing build tools and Python development headers via `apt-get`, and finally installing the library using `sudo python3 setup.py install`. ```console $ git clone https://github.com/adafruit/Adafruit_Python_DHT.git Cloning into 'Adafruit_Python_DHT'... remote: Counting objects: 249, done. remote: Total 249 (delta 0), reused 0 (delta 0), pack-reused 249 Receiving objects: 100% (249/249), 77.00 KiB | 0 bytes/s, done. Resolving deltas: 100% (142/142), done. $ cd Adafruit_Python_DHT $ sudo apt-get install build-essential python-dev Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: build-essential python-dev ... $ sudo python3 setup.py install running install running bdist_egg running egg_info creating Adafruit_DHT.egg-info ... ``` -------------------------------- ### Start Fledge Application Source: https://github.com/fledge-iot/fledge/blob/develop/README.rst Starts the Fledge application using the `fledge` executable located in the FLEDGE_ROOT/bin directory. This command initiates the Fledge services. ```bash $FLEDGE_ROOT/bin/fledge start ``` -------------------------------- ### Retrieve All Configuration Categories (GET /fledge/category) Source: https://github.com/fledge-iot/fledge/blob/develop/docs/rest_api_guide/03_RESTadmin.rst An example of using curl to perform a GET request to the /fledge/category endpoint, demonstrating how to fetch all available configuration categories and their details. ```console $ curl -X GET http://localhost:8081/fledge/category { "categories": [ { "key": "Storage", "description": "Storage configuration", "displayName": "Storage" }, { "key": "Advanced", "description": "Advanced", "displayName": "Advanced" }, { "key": "LOGGING", "description": "Logging Level of Core Server", "displayName": "Logging" }, { "key": "SCHEDULER", "description": "Scheduler configuration", "displayName": "Scheduler" }, { "key": "SMNTR", "description": "Service Monitor", "displayName": "Service Monitor" }, { "key": "rest_api", "description": "Fledge Admin and User REST API", ``` -------------------------------- ### Fledge Command Line Utility API Documentation Source: https://github.com/fledge-iot/fledge/blob/develop/docs/quick_start/starting.rst Comprehensive documentation for the 'fledge' command line utility, detailing available options for system administration and various authentication mechanisms. ```APIDOC fledge CLI: Description: Command line utility for Fledge administration. Commands: start: Description: Start the Fledge system. Authentication: Not required. stop: Description: Stop the Fledge system. Authentication: Required (unless configured otherwise). status: Description: Lists currently running Fledge services and tasks. Authentication: Not required. reset: Description: Delete all data and configuration and return Fledge to factory settings. Authentication: Required. kill: Description: Kill Fledge services that have not correctly responded to Stop. Authentication: Required. help: Description: Describe Fledge options. Authentication: Not required. Authentication Methods: 1. Environment Variables: - USERNAME: Set to specify username. - PASSWORD: Set to specify password (not recommended). 2. Command Line Flags: -u : Specify username. -p : Specify password (not recommended). -c : Use certificate-based authentication. 3. Interactive Prompt: If username/password not provided via env/flags, user will be prompted. 4. Authentication Token: A time-based token is issued after successful authentication, allowing subsequent commands without re-authentication for a limited time. ``` -------------------------------- ### Configure and Install Fledge Project Files with CMake Source: https://github.com/fledge-iot/fledge/blob/develop/C/thirdparty/rapidjson/CMakeLists.txt This CMake script block handles the setup of installation directories, configuration of project-specific CMake files (like `PROJECT_NAMEConfig.cmake`), and the subsequent installation of these generated files and specified targets (e.g., RapidJSON). It ensures that the project's build and installation artifacts are correctly placed for development and deployment. ```CMake SET( CMAKECONFIG_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME} ) FILE( RELATIVE_PATH REL_INCLUDE_DIR "${CMAKECONFIG_INSTALL_DIR}" "${CMAKE_INSTALL_PREFIX}/include" ) SET( ${PROJECT_NAME}_INCLUDE_DIR "\${${PROJECT_NAME}_CMAKE_DIR}/${REL_INCLUDE_DIR}" ) SET( CONFIG_SOURCE_DIR ) SET( CONFIG_DIR ) CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake @ONLY ) INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake" DESTINATION ${CMAKECONFIG_INSTALL_DIR} ) # Install files IF(CMAKE_INSTALL_DIR) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake DESTINATION "${CMAKE_INSTALL_DIR}" COMPONENT dev) INSTALL(TARGETS RapidJSON EXPORT RapidJSON-targets) INSTALL(EXPORT RapidJSON-targets DESTINATION ${CMAKE_INSTALL_DIR}) ENDIF() ``` -------------------------------- ### Build and Run Fledge SQLite Unit Tests Source: https://github.com/fledge-iot/fledge/blob/develop/tests/unit/C/plugins/storage/sqlite/README.rst Steps to create a build directory, navigate into it, configure the project with CMake, compile the unit tests using Make, and finally execute the compiled tests. ```bash mkdir build cd build cmake .. make ./RunTests ``` -------------------------------- ### Parse, Modify, and Stringify JSON using RapidJSON DOM Source: https://github.com/fledge-iot/fledge/blob/develop/C/thirdparty/rapidjson/readme.md This C++ example demonstrates the fundamental steps of using RapidJSON's Document Object Model (DOM). It shows how to parse a JSON string into a DOM, access and modify a specific value (incrementing 'stars'), and then serialize the modified DOM back into a JSON string. This illustrates a complete cycle of JSON data manipulation. ```cpp // rapidjson/example/simpledom/simpledom.cpp` #include "rapidjson/document.h" #include "rapidjson/writer.h" #include "rapidjson/stringbuffer.h" #include using namespace rapidjson; int main() { // 1. Parse a JSON string into DOM. const char* json = "{\"project\":\"rapidjson\",\"stars\":10}"; Document d; d.Parse(json); // 2. Modify it by DOM. Value& s = d["stars"]; s.SetInt(s.GetInt() + 1); // 3. Stringify the DOM StringBuffer buffer; Writer writer(buffer); d.Accept(writer); // Output {"project":"rapidjson","stars":11} std::cout << buffer.GetString() << std::endl; return 0; } ``` -------------------------------- ### Start Fledge Core Microservice Source: https://github.com/fledge-iot/fledge/blob/develop/python/fledge/services/core/README.rst Instructions on how to initiate the Fledge core microservice, which is critical for the operation of the entire Fledge system. Two methods are provided: direct execution via Python's module runner or using the convenience `fledge` script. ```Shell python -m fledge.services.core ``` ```Shell fledge start ``` -------------------------------- ### Copy Fledge DHT11 South Plugin Files Source: https://github.com/fledge-iot/fledge/blob/develop/docs/plugin_developers_guide/03_01_DHT11.rst These console commands demonstrate how to copy the DHT11 south plugin files into the appropriate Fledge directory. Two variations are provided: one for Fledge installations from a build directory and another for installations via 'sudo make install'. ```Bash cd ~/Fledge cp -R ~/fledge-south-dht11/python/fledge/plugins/south/dht11 python/fledge/plugins/south/ ``` ```Bash sudo cp -R ~/fledge-south-dht11/python/fledge/plugins/south/dht11 /usr/local/fledge/python/fledge/plugins/south/ ``` -------------------------------- ### Install Python Test Prerequisites Source: https://github.com/fledge-iot/fledge/blob/develop/tests/system/python/pair/docs/test_python_north_service_pair.rst This console command sequence guides the user to the Fledge Python directory and installs all necessary Python packages required for running the test suite. It leverages 'pip' to install dependencies specified in the 'requirements-test.txt' file, ensuring the testing environment is properly set up. ```console $ cd fledge/python $ python3 -m pip install -r requirements-test.txt --user ``` -------------------------------- ### Check Available Git Branches for Fledge Project Source: https://github.com/fledge-iot/fledge/blob/develop/docs/building_fledge/building_fledge.rst Demonstrates how to navigate to the Fledge project directory and list all local and remote Git branches using the `git branch --all` command. ```console $ pwd /home/ubuntu $ cd fledge $ git branch --all * develop remotes/origin/1.0 ... remotes/origin/FOGL-822 remotes/origin/FOGL-823 remotes/origin/HEAD -> origin/develop ... remotes/origin/develop remotes/origin/main $ ```