Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DKE-Data/agrirouter-api-cpp

 
 

Repository files navigation

agrirouter-api-cpp

  1. Abstract
  2. The current project you’re looking at
  3. How to install Protobuf C++ Compiler

Abstract

alt text

The agrirouter is a universal data exchange platform for farmers and agricultural contractors that makes it possible to connect machinery and agricultural software, regardless of vendor or manufacturer. Agrirouter does not save data; it transfers data. As a universal data exchange platform, agrirouter fills a gap on the way to Farming 4.0. Its underlying concept unites cross-vendor and discrimination-free data transfer. You retain full control over your data. Even data exchange with service providers (e.g. agricultural contractors) and other partners is uncomplicated: Data are very rapidly transferred via the online connection, and if you wish, is intelligently connected to other datasets.

The current project you're looking at

This project contains the C++ API for the communication with the agrirouter. Everything you need for the onboarding process, communication and much more.

Prerequisite

The following packages have to be installed on your device

Steps to start program

  1. cmake CMakeLists.txt
  2. make
  3. ./AgrirouterClientTest --help
    (Use one of the command line arguments)

Configuration

The configuration file AgrirouterClientTesterConfig.json looks like this

{
    "applicationSettings": {
        "applicationId": "SOME_APPLICATION_ID",
        "certificationVersionId": "SOME_CERTIFICATION_VERSION_ID",
        "externalId": "SOME_EXTERNAL_ID",
        "locationCertsAndIds": "THE_LOCATION_WHERE_THE_KEY_AND_CERT_ARE_STORED",
        "teamsetContextId": "SOME_TEAMSET_CONTEXT_ID",
        "connectionType": "HTTP"
    },
    "agrirouterSettings": {
        "url": "https://agrirouter-registration-service.cfapps.eu1.hana.ondemand.com/api/v1.0/registration/onboard"
    }
}

Other hints

The project is devided into 2 parts: the lib and an example application that is using the compiled lib.

Before creating a pull request, please execute the lint program in folder cpplint and remove all occuring errors.

How to install Protobuf C++ Compiler

The following instructions are based on the Google Protobuf installation guide and are optimized for Unix based systems. For Windows it is recommended to install Cygwin and do the same steps as if you were on a Unix based system.

Download packages

You can download protoc and protobuf packages from Google Protobuf Releases. Make sure you download the same versions of protoc and protobuf otherwise the installation won't work.

E.g. protoc-3.5.0-linux-x86_64.zip and protobuf-cpp-3.5.0.zip

Prepare Protoc

  1. Unzip package
    unzip protoc-3.* -d protoc3
  2. Move protoc to /usr/bin/
    sudo mv protoc3/bin/protoc /usr/bin/
  3. Move included packages to /usr/include/
    sudo mv protoc3/include/* /usr/include/
  4. Optional: make protoc executable for everyone
    sudo chmod +x /usr/bin/protoc
  5. Optional: make includes readable for everyone
    sudo chmod +r /usr/include/google/*

Install Protobuf

  1. Unzip package
    unzip protobuf-cpp-3.* -d protobuf3
  2. Go to folder profobuf3 and make file configure executable
    chmod +x configure
  3. Execute following commands
    ./configure
    make
    make check
    sudo make install
    sudo ldconfig
    Note: If "make check" fails, you can still install, but it is likely that some features of this library will not work correctly on your system. Proceed at your own risk.

Use Protoc

If you want to compile some proto files use protoc [OPTIONS] PROTO_FILES

The [OPTIONS] part indicates the destination of compiled file. You can use relative and absolute paths.
In the PROTO_FILES part you can define which protobuf files will be compiled.

E.g. the command protoc --cpp_out=. ./*.proto compiles every every proto file in this folder and places the compiled ones within this folder.

Cross compiling

If you want to use cross compiling you have to use --host option when executing ./configure.
E.g. ./configure --host=powerpc-linux CC=powerpc-linux-gnu-gcc CXX=powerpc-linux-gnu-g++ --with-protoc=/usr/bin/protoc

Also see Cross-compiling hints.

About

An implementation of the agrirouter interface in C++

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 5