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

Android app #32

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions invehicle-apps/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*/build
3 changes: 2 additions & 1 deletion invehicle-apps/kuksa-cloud-dashboard/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ message(STATUS ${CMAKE_CURRENT_SOURCE_DIR})

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

add_executable(${PROJECT_NAME} "src/main.cpp" "src/honoMqtt.cpp" "src/emailHTTP.cpp" )

add_executable(${PROJECT_NAME} "src/main.cpp" "src/honoMqtt.cpp" "src/emailHTTP.cpp")
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/../3rd-party-libs ${CMAKE_CURRENT_SOURCE_DIR}/../3rd-party-libs/Simple-WebSocket-Server ${CMAKE_CURRENT_SOURCE_DIR}/../3rd-party-libs/jsoncons ${CMAKE_CURRENT_SOURCE_DIR}/../3rd-party-libs/paho.mqtt.c/src ${CMAKE_CURRENT_SOURCE_DIR}/../3rd-party-libs/paho.mqtt.cpp/src)

add_library(simple-websocket-server INTERFACE)
Expand Down
18 changes: 12 additions & 6 deletions invehicle-apps/kuksa-cloud-dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

This is a kuksa demo-app which connects to the w3c-visserver service via Websocket and talks to the Eclipse Hono MQTT adapter and sends telemetry data to Hono. This app reads the RPM, Speed, Fuel status and also custom DTC drom the w3c-visserver. This app also requires the following signal in the w3c-vis server tree.

`Signal.OBD.DTC1`
`Vehicle.OBD.DTC1`

`Signal.OBD.DTC2`
`Vehicle.OBD.DTC2`

`Signal.OBD.DTC3`
`Vehicle.OBD.DTC3`

`Signal.OBD.DTC4`
`Vehicle.OBD.DTC4`

`Signal.OBD.DTC5`
`Vehicle.OBD.DTC5`

To add this signal to the vss-tree, please modify the vss_rel_1.0.json file used in the w3c-vis-server.
To add this signal to the vss-tree, please modify the vss_rel_2.0.json file used in the w3c-vis-server.


### Build docker image
Expand All @@ -22,3 +22,9 @@ use the instructions available in the docker folder to build the docker image.
use the kuksa-publisher to publish the app in the kuksa-appstore.


### Publish app on kuksa-appstore

use the kuksa app-publisher to publish the app on the kuksa-appstore. The configuration for the publisher is found in kuksa-dashboard.yaml file.
Check the docs of app-publisher for more info.


4 changes: 2 additions & 2 deletions invehicle-apps/kuksa-cloud-dashboard/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM arm64v8/alpine:3.8 AS build-env

COPY kuksa-cloud-dashboard/docker/qemu-aarch64-static /usr/bin/qemu-aarch64-static

RUN apk update && apk add cmake alpine-sdk boost-dev boost-system boost-thread openssl-dev libstdc++
RUN apk update && apk add curl cmake alpine-sdk boost-dev boost-system boost-thread openssl-dev libstdc++

ADD . /app
WORKDIR /app/kuksa-cloud-dashboard
Expand All @@ -14,7 +14,7 @@ RUN cd build && make


#Transferring build artifacts to minimal docker
FROM arm64v8/alpine:3.8
FROM arm64v8/alpine:3.8
#For debugging uncomment, and replae copy with real install to see what is missing...
#RUN apk update && apk add openssl boost-system boost-thread libstdc++
COPY --from=build-env /lib/libssl.so.1.0.0 /lib/
Expand Down
2 changes: 1 addition & 1 deletion invehicle-apps/kuksa-cloud-dashboard/docker/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

VERSION="0.1.0"
VERSION="0.1.3"
NAME="cloud-dashboard"

if [ -z "$VERSION" ]; then
Expand Down
3 changes: 2 additions & 1 deletion invehicle-apps/kuksa-cloud-dashboard/docker/dockerentry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
#
# Contributors: Robert Bosch GmbH

./dashboard $HONOIP $HONOPORT $HONOPW $HONODEVICE $TOKEN $EMAIL_SERVER $EMAIL_PORT
apk update && apk add curl
./dashboard $HONOIP $HONOPORT $HONODEVICE $HONOPW $BUFFER_SIZE $BUFFER_TIME $TOKEN $EMAIL_SERVER $EMAIL_PORT

1 change: 1 addition & 0 deletions invehicle-apps/kuksa-cloud-dashboard/include/emailHTTP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ using namespace std;

int sendEmail (string emailid, string dtccode);


5 changes: 3 additions & 2 deletions invehicle-apps/kuksa-cloud-dashboard/include/honoMqtt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ class HonoMqtt : public virtual mqtt::callback, public virtual mqtt::iaction_lis

mqtt::async_client* p_Client;
void(*onMsg)(string);
mqtt::topic* top;

public:

void connect (string honoAddr , string clientID, string userName, string password);
void publish (string topic, string data);
void connect (string honoAddr , string clientID, string userName, string password, int offlineBufferSize, int connAlive);
void publish (string data);
void disconnect();
void setMessageCB(void(*)(string));

Expand Down
37 changes: 37 additions & 0 deletions invehicle-apps/kuksa-cloud-dashboard/kuksa-dashboard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Make sure you donot use tabs for indentation
# Put all app related infos here
docker :
image : "arm32v6/cloud-dashboard:0.1.0"
name : "Dashboard-W3C-Version2"
version : "0.1.0"
owner : "Company name"
description : "This is a cloud dashboard app"
config :
network_mode : "host"
volumes:
/tmp/:
bind: '/mnt/'
mode: 'rw'
environment:
HONOIP: ""
HONOPORT: "1883"
HONODEVICE: "sensor1"
HONOPW: "hono-secret"
BUFFER_SIZE: 1024000
BUFFER_TIME: 600
TOKEN: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE2MDkzNzI4MDAsInczYy12c3MiOnsiVmVoaWNsZS5PQkQuKiI6InJ3IiwiVmVoaWNsZS5DYWJpbi5JbmZvdGFpbm1lbnQuTmF2aWdhdGlvbi5DdXJyZW50TG9jYXRpb24uKiI6InJ3In19.QYs78CwwyOPnzXUZdHYbWzD7hwMWuNJWuNBTNYIBQqvkM7Df5CsIV_CvfiozSQybSPwlthnm4yJ7xgyC2yQTLh6vKKEIAlNjFcOep39b3fGEDDrRHkOyMJQuxYD5ELALKEPbakITi4QfqWozcZQNY9AdyYROKJqmTPlaYZmT0_mAQQFCIk7ji-udxtqTGtO6-WW5cDPkp0cqaDy1ZJusVUsRJGUkd942jgqbcVp98n7j4o8NvSQhZ6wGrG8Nc1tpTMUdXQmuMPA3Iv2P3cSMuBrHAY5I8511OFgIpB51gydKF4PaqTpirxCswm85iZq6so9CnMwh9I7VBO5GI6Nz_lnFfyeg1NEdRmSTEI6ucqLhjx54R2cT-fa6KIHcDKw63ZrXGT-dNyhX2px0Q5zM2zuy8phwLj6cXujCS8-uOmlysvmxwgh3oIUmtmP47x5ZLkFqaYuU2Ue-kiSr1lyleaEhQxSGykCJr6OibQ4gA6b5VIXn3mfkMWF8fse3Xm1D8jJ6UyE9zl55GhgvcAX9AlQYuqRTcaSvhZbzDmSO4pMda0wuHyHnB1DBiFcV9AtbPQsLraP2VVNGlKiWQkiJp66H0fkj1NPmQvCbbQ9v8YT-_DmAEvwnY9Mcx26FYodzC055lny4ThRXTCSmnJdxA05Av-BCjAGxPTinYxKCA1c"
EMAIL_SERVER: ""
EMAIL_PORT: "9020"

# Put all the hawkbit related infos here
hawkbit :
url: "http://hawkbit.com:8080"
target : "kuksa_Donglev2"
user : "admin"
password : "admin"

# Put all appstore infos here
appstore :
url : "https://kuksa-appstore.org:8443"
category : "kuksa-test"
auth : "Basic YWRtaW46YWRtaW4="
38 changes: 21 additions & 17 deletions invehicle-apps/kuksa-cloud-dashboard/src/honoMqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
#include "honoMqtt.hpp"

using namespace std;
using namespace std::chrono;

#define QOS 1

const string PUB_TOPIC = "telemetry";

/**
* A base action listener for pub.
Expand Down Expand Up @@ -51,42 +55,42 @@ class action_listener_sub : public virtual mqtt::iaction_listener
};


void HonoMqtt::connect (string honoAddr , string clientID, string userName, string password) {

p_Client = new mqtt::async_client (honoAddr, clientID);
void HonoMqtt::connect (string honoAddr , string clientID, string userName, string password, int offlineBufferSize , int connAlive) {

cout << "Creating async mqtt client with persist of max msg = "<< offlineBufferSize << endl;
p_Client = new mqtt::async_client (honoAddr, clientID, offlineBufferSize, nullptr);
p_Client->set_callback(*this);
mqtt::connect_options connOpts;
connOpts.set_connection_timeout(3);
connOpts.set_keep_alive_interval(20);
connOpts.set_automatic_reconnect(true);
connOpts.set_keep_alive_interval(seconds(connAlive)); // keep alive for seconds passed
connOpts.set_clean_session(true);
connOpts.set_user_name(userName);
connOpts.set_password(password);
connOpts.set_automatic_reconnect(true); // reconnects automatically.
top = new mqtt::topic(*p_Client, PUB_TOPIC, QOS, false);

try {
cout << "Connecting..." << endl;
mqtt::token_ptr conntok = p_Client->connect(connOpts, nullptr, *this);
cout << "Waiting for the connection..." << endl;
conntok->wait();
p_Client->connect(connOpts)->wait();
cout << "Connected." << endl;
} catch (const mqtt::exception& exc) {
cout << "Exception occured while connecting to hono"<< endl;
cerr << exc.what() << endl;
throw exc;
}
}

void HonoMqtt::publish (string topic, string data) {
void HonoMqtt::publish (string data) {
try {
cout << "Sending next message..." << endl;
action_listener_pub listener;
mqtt::message_ptr pubmsg = mqtt::make_message(topic, data);
mqtt::delivery_token_ptr pubtok;
try {
pubtok = p_Client->publish(pubmsg, nullptr, listener);
pubtok->wait();
cout << "Published." << endl;
top->publish(std::move(data));
cout << "Published." << endl;
} catch (const mqtt::exception& exc) {
cout << "Exception occured while publishing data"<< endl;
cerr << exc.what() << endl;
}
throw exc;
}

}

void HonoMqtt::disconnect() {
Expand Down
Loading