{"id":4306,"date":"2018-09-14T18:42:43","date_gmt":"2018-09-14T16:42:43","guid":{"rendered":"https:\/\/blog.mi.hdm-stuttgart.de\/?p=4306"},"modified":"2023-06-09T12:05:37","modified_gmt":"2023-06-09T10:05:37","slug":"yet-another-connected-vehicle-cloud-platform","status":"publish","type":"post","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2018\/09\/14\/yet-another-connected-vehicle-cloud-platform\/","title":{"rendered":"Yet another Connected Vehicle Cloud Platform"},"content":{"rendered":"<h2>Getting Ideas&#8230;\u00a0write a User Story<\/h2>\n<p>When I thought about an idea for a project, part of the lecture &#8220;Software Development for Cloud Computing&#8221;, I had two related use-cases in mind. So I wrote down those high-level user-stories:<\/p>\n<blockquote><p><span style=\"font-weight: 400;\">As a user who owns a non-connected car, I want to access some information about my car on my smartphone so that I know about the position of my car and additional information like fuel level, consumption or driving statistics.<\/span><\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<blockquote><p><span style=\"font-weight: 400;\">As an employee who wants to drive a pool-car, I want to know where the vehicle is parked so that I don\u2019t have to search on different parking spots around the building.<\/span><\/p><\/blockquote>\n<p><!--more--><\/p>\n<h2>Define a Scope<\/h2>\n<p>My goal for this project was to build a functional prototype which meets the expectation of at least one requirement.<br \/>\nIt wasn&#8217;t easy to define the scope for this project because there are many ideas to expand it.<\/p>\n<ul>\n<li>Log car telemetry data from OBD-II Interface in 200ms steps.<\/li>\n<li>Transmit telemetry data every 5 seconds to AWS IoT Backend.<\/li>\n<li>Telemetry data like\u00a0geoposition, vehicle speed, engine speed, tank fuel level&#8230;<\/li>\n<li>Store incoming telemetry data on S3 storage.<\/li>\n<li>Store actual vehicle state on DynamoDB<\/li>\n<li>Build an\u00a0iOS App to show vehicle data<\/li>\n<li>(Additional)\u00a0Create an Alexa Skill<\/li>\n<\/ul>\n<h2>The Components<\/h2>\n<p>The project can be separated into three components. First part is a <strong>Datalogger<\/strong>, second the <strong>Cloud Backend Infrastructure<\/strong> and third the <strong>User-Interfaces<\/strong>.\u00a0In the following sections I want to go deeper into the single parts:<\/p>\n<h3>Data Logger<\/h3>\n<p>The datalogger should record signals like latitude, longitude, speed, engine-speed, consumption, odometer and tank level. For that, I adopted an existing solution based on a Raspberry Pi and got it to work with the OBD-II Interface of my car and an external GPS Receiver. The datalogger records the data in 200 ms steps transmits it every 5 seconds to the backend using MQTT and the AWS IoT Framework.<\/p>\n<p>The primary solution is directly connected to the CAN-bus of the car which provides a large bunch of signals including all required signals. <strong>During my modification for <\/strong>OBD-II<strong> I had to realize that OBD-II does not provide all the required signals.<\/strong> This restricts the implementation of the first user-story slightly but covers still the requirement to show the position of the car, which is also the main feature of the second user story.<\/p>\n<p><strong>Material:<\/strong> Raspberry Pi Model 3 PiCAN2 Board Serial to OBD-II Adapter Cable USB GPS Receiver * USB Power Car Adapter + Cable<\/p>\n<figure id=\"attachment_4340\" aria-describedby=\"caption-attachment-4340\" style=\"width: 300px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/datalogger-sm.jpg\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"4340\" data-permalink=\"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2018\/09\/14\/yet-another-connected-vehicle-cloud-platform\/datalogger-sm\/\" data-orig-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/datalogger-sm.jpg\" data-orig-size=\"500,400\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;1.8&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;iPhone 8&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1533657738&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;3.99&quot;,&quot;iso&quot;:&quot;40&quot;,&quot;shutter_speed&quot;:&quot;0.03030303030303&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}\" data-image-title=\"datalogger-sm\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Material Data Logger&lt;\/p&gt;\n\" data-large-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/datalogger-sm.jpg\" class=\"size-medium wp-image-4340\" src=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/datalogger-sm-300x240.jpg\" alt=\"Material Data Logger\" width=\"300\" height=\"240\" srcset=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/datalogger-sm-300x240.jpg 300w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/datalogger-sm.jpg 500w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-4340\" class=\"wp-caption-text\">Material Data Logger<\/figcaption><\/figure>\n<p><strong>How it works:<\/strong> The device uses the AWS IoT SDK to publish the data via MQTT to the AWS IoT Endpoint. It publishes to the following topic\u00a0<code class=\"\" data-line=\"\">connectedVehicle\/telemetry\/[vin]<\/code>\u00a0with a frequency of 5 seconds. The message structure is as followed:<\/p>\n<pre class=\"prettyprint lang-javascript\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">{\n    \"UDID\": \"\",\n    \"tripId\": \"\",\n    \"canSnapshotObject\": {\n        \"sensor\": {\n            \"value\": 0,\n            \"timestamp\": 0\n        }\n    }\n    \"canFrames\": {}\n}<\/pre>\n<h3>Cloud Backend Infrastructure<\/h3>\n<p>The <strong>Main Challenge<\/strong> on this was to design an lightweight but extensible architecture. At first, I searched for examples for my use-case. I wanted to know, how others do that. You can find a lot of examples, tutorials and ready-to-deploy solutions for that. The most cloud providers have example stories with car manufactures or automotive suppliers. Two main examples were helpful for me: The AWS Simple Beer Service (SBS) and the AWS Connected Vehicle Solution. The SBS is a simple example with all important components for an infrastructure like that. It was a good starting point, but as I went further, I found out, that the infrastructure, the picture shows, is a little older. For example, the API Gateway between the Kegerator and the Lambda functions is replaced with the AWS IoT Core part (see <a href=\"https:\/\/github.com\/awslabs\/simplebeerservice\/tree\/version5\">Simple Beer Service v5<\/a>). Also for the visualization part, there is a better solution for mobile devices like AWS AppSync.<\/p>\n<p>The <a href=\"https:\/\/aws.amazon.com\/de\/answers\/iot\/connected-vehicle-solution\/\"><strong>Connected Vehicle Solution<\/strong><\/a>\u00a0of AWS offers a range of features and various sample services such as location-based marketing, push notifications or driver evaluation. It&#8217;s easy to implement because Amazon provides a cloud formation template that I have installed on my AWS account. It worked without any problems.<\/p>\n<p>Unfortunately, AWS provides no documentation about how to get data to this solution. It would have been helpful to know which signals in which format and how often are expected. So a lot of investigation was necessary.<\/p>\n<p>In this way, I found a helpful tool to simulate a car. The AWS IoT Device Simulator is based on the AWS Cloud Infrastructure, can also be deployed with cloud formation template and provides an interface to simulate car rides.<\/p>\n<p>The source code of the Simulator showed me how the data is structured. The disadvantage became obviously, that for every sensor in the vehicle a message is published instead of aggregating the data and send it every x seconds. Because of this and the complex infrastructure, I decided to implement an infrastructure on my own.<\/p>\n<p><strong>Why Amazon Web Services?<\/strong><\/p>\n<p>The Main Requirement for my project was an IoT Cloud Platform. Well-known products are from Google, Microsoft, IBM, and Amazon. Every one of the four has an example and success stories for their IoT Platform with connected vehicles. I decided on Amazon AWS because it is very well documented, I have a basic knowledge of some AWS Services and my colleagues are familiar with this product, so in case I can ask them. It seems for me to be the fastest way to get a result but also a good way to learn a lot about cloud services like IoT Platforms, Serverless Programming, Storage &amp; Database, Infrastructure-, Platform- &amp; Function-as-a-Service, and in deep about AWS.<\/p>\n<p><strong>Set up IoT Infrastructure<\/strong><\/p>\n<p>In the following, I will explain how I set up the IoT Platform for my requirements:<\/p>\n<ol>\n<li>First, create a new IoT thing following the wizard. You&#8217;ll need to create a certificate, public and private key. Don&#8217;t forget to activate the certificate. The policy will be created in the next step.<\/li>\n<li>Create a new policy. Click on Advanced mode and insert following JSON document:\n<pre class=\"prettyprint lang-javascript\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Effect\": \"Allow\",\n      \"Action\": [\n        \"iot:Publish\",\n        \"iot:Subscribe\",\n        \"iot:Connect\",\n        \"iot:Receive\"\n      ],\n      \"Resource\": [\n        \"*\"\n      ]\n    }\n  ]\n}<\/pre>\n<p>Assign the policy to your newly created thing.<span style=\"font-weight: 400;\"><br \/>\n<\/span><\/li>\n<li>Copy the certificates to the IoT device<\/li>\n<li>Create a rule for the topic. The rule query statements should look like this:\u00a0<code class=\"\" data-line=\"\">SELECT * FROM &#039;connectedcar\/telemetry\/#&#039;<\/code><\/li>\n<li>Add action <em>Invoke a Lambda function passing the message data<\/em>. Leave the function name empty unless you created the function.<\/li>\n<\/ol>\n<p>After setup of the IoT Infrastructure, we can continue with storage, database, and Lambda functions.<\/p>\n<p><strong>Create S3 Bucket:<\/strong> All incoming messages will be stored on an S3 Bucket, arranged after vehicle identification number and trip. Create one with named <em>connected-vehicle-data-<\/em>eu<em>-west-1<\/em>.<\/p>\n<p><strong>Create DynamoDB\u00a0Tables:<\/strong> The dynamoDB table will show all vehicles with their current state. Create one named\u00a0connectedVehicle<em>-vehicle-snapshot<\/em>\u00a0with <em>vin as<\/em>\u00a0the primary key.<\/p>\n<p>Create Telemetry Lambda Function<\/p>\n<ol>\n<li>Create a Lambda Function\n<ul>\n<li>Name: <em>ConnectedVehicle-storeTelemetryDataFunction<\/em><\/li>\n<li>Runtime: <em>Node.js 6.10<\/em><\/li>\n<li>Role: <em>Create new role from template(s)<\/em><\/li>\n<li>Create new Role from Template: <em>connectedVehicle-dev-eu-west-1-lambdaRole<\/em><\/li>\n<li>Choose Policy Template <em>Basic Edge Lambda permissions<\/em><\/li>\n<li>Save Lambda Function<\/li>\n<\/ul>\n<\/li>\n<li>Add a trigger\n<ul>\n<li>Choose <em>AWS IoT<\/em> from the left<\/li>\n<li>Go down and configure the trigger<\/li>\n<li>Select <em>Custom IoT rule<\/em> and choose your rule (<em>ConnectedVehicleTelematics<\/em>)<\/li>\n<li>Click <em>Add<\/em><\/li>\n<\/ul>\n<\/li>\n<li>Edit IAM Role for using DynamoDB and S3\n<ul>\n<li>Go to IAM Console and edit policy<\/li>\n<li>Choose <em>Add inline policy<\/em> and add a JSON policy (<em>connectedVehicle-lambda-dynamodb-bucket-policy<\/em>):\n<pre class=\"prettyprint lang-javascript\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Sid\": \"VisualEditor0\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"dynamodb:PutItem\",\n                \"dynamodb:DescribeTable\",\n                \"dynamodb:DeleteItem\",\n                \"dynamodb:GetItem\",\n                \"dynamodb:Scan\",\n                \"dynamodb:Query\",\n                \"dynamodb:UpdateItem\"\n            ],\n            \"Resource\": \"arn:aws:dynamodb:eu-west-1:xxxxxxxxxxx:table\/*\"\n        },\n        {\n            \"Sid\": \"VisualEditor1\",\n            \"Effect\": \"Allow\",\n            \"Action\": \"dynamodb:ListTables\",\n            \"Resource\": \"*\"\n        }\n    ]\n}\n<\/pre>\n<\/li>\n<li>Add also a Policy for S3 (<em>connectedVehicle-lambda-s3-bucket-policy<\/em>):\n<pre class=\"prettyprint lang-javascript\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Sid\": \"VisualEditor0\",\n            \"Effect\": \"Allow\",\n            \"Action\": \"s3:*\",\n            \"Resource\": \"arn:aws:s3:::connected-vehicle-data-eu-west-1\"\n        }\n    ]\n}\n<\/pre>\n<\/li>\n<li>Save it.<\/li>\n<\/ul>\n<\/li>\n<li>Add following code to your Lambda function:\n<pre class=\"prettyprint lang-javascript\" data-start-line=\"1\" data-visibility=\"hidden\" data-highlight=\"\" data-caption=\"\">var DATA_TABLE = 'connectedVehicle-vehicle-snapshot';\nvar AWS = require(\"aws-sdk\");\nvar ddb = new AWS.DynamoDB();\nvar s3 = new AWS.S3({params: {Bucket: 'connected-vehicle-data-eu-west-1'}});\n\nexports.handler = function(event, context) {\n\n    if (event.UDID!==undefined) {\n\n    var rTimestamp = new Date().getTime();\n    console.log(rTimestamp);\n    var params = {\n        TableName: DATA_TABLE,\n        Item:{\n            \"vin\":{\"S\": event.UDID },\n            \"lat\":{\"S\": event.canSnapshotObject.hasOwnProperty('lat') ? event.canSnapshotObject.lat.value.toString() : '-'  },\n            \"long\":{\"S\": event.canSnapshotObject.hasOwnProperty('long') ? event.canSnapshotObject.long.value.toString() : '-' },\n            \"range_in_km\":{\"S\": event.canSnapshotObject.hasOwnProperty('range_in_km') ? event.canSnapshotObject.range_in_km.value.toString() : '-' },\n            \"tank_level_percentage\":{\"S\": event.canSnapshotObject.hasOwnProperty('tank_level_percentage') ? event.canSnapshotObject.tank_level_percentage.value.toString() : '-' },\n            \"canSnapshotObject\":{\"S\": JSON.stringify(event.canSnapshotObject)},\n            \"lastUpdated\":{\"N\": rTimestamp.toString() }\n        }\n    };\n\n    ddb.putItem(params, function(err, result) {\n        if(err)\n            console.log(\"Error in uploading file on dynamodb due to \"+ err)\n        else    \n            console.log(\"File successfully uploaded to dynamodb.\")\n    });\n\n    var params = {\n        Key: event.UDID + '\/' + event.tripId + '\/vehicle-data-' + rTimestamp,\n        Body: JSON.stringify(event),\n    };\n\n    s3.upload(params, function (err, res) {               \n        if(err)\n            console.log(\"Error in uploading file on s3 due to \"+ err)\n        else    \n            console.log(\"File successfully uploaded.\")\n    });\n\n    } else {\n    context.fail(\"JSON input [UDID] not defined.\");\n    }\n\n};\n<\/pre>\n<\/li>\n<li>Now your function should work.<\/li>\n<\/ol>\n<p><strong>Room for Improvement<\/strong><\/p>\n<ol>\n<li><strong>IoT Device Rollout.<\/strong> At this point, new IoT devices have to set up and be registered manually. After that, the new created certificates must be copied to the device. This process can be automated and is called &#8220;Just-in-Time Provisioning&#8221;. The first time the device connects to AWS IoT, a certificate will be created and downloaded to the device. All it needs is the CA certificate.<\/li>\n<li><strong>Account Linking.<\/strong> One issue is that\u00a0there is no link between a car and a user account. So every App user can access all cars. Account Linking and Rights Management would solve this. The user of a car should only access information about this car, while the fleet owner should be able to access all cars. This applies also for the Alexa Skill.<\/li>\n<li><strong>Scriptable Infrastructure.<\/strong> I had set up the AWS Services step-by-step through the web console. This is good for exploring and trying out the services but it causes a high effort to re-deploy or roll back the infrastructure. An approach for this is to use the aws cli, CloudFormation templates or use a tool like terraform.<\/li>\n<\/ol>\n<p><strong>Further Development<\/strong><\/p>\n<p>There are many ideas to extend the dashboard in the app about vehicle information. As we get on the <em>\/vehicle\/trip\/[vin]<\/em> channel a notification on trip start and end, we cloud trigger on this way some analytics on trip ends like a driver safety score or a green score. Looking at the AWS Connected Vehicle Solution there are more ideas for location-based services (geofence, marketing) or predictive maintenance. In addition to the second user story, a web dashboard for the pool-car manager could be possible to monitor all cars.<\/p>\n<h2>User Interface<\/h2>\n<h3>The App<\/h3>\n<p>There are two main user touch points to the vehicle cloud infrastructure. First, I build an iOS App for that. The App shows a Map and a card-slider with all vehicles. The card displays the vehicle identification number and owner of the car.<br \/>\nAdjusting the scope (see part data logger) affected the App mainly, so I put the focus on the vehicle position. In this way, the main feature of the app is to show the position of the vehicle.<\/p>\n<p><a href=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/carfinder_app.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"4346\" data-permalink=\"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2018\/09\/14\/yet-another-connected-vehicle-cloud-platform\/carfinder_app\/\" data-orig-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/carfinder_app.png\" data-orig-size=\"2000,2000\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"carfinder app\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/carfinder_app-1024x1024.png\" class=\"alignnone size-medium wp-image-4346\" src=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/carfinder_app-300x300.png\" alt=\"\" width=\"300\" height=\"300\" srcset=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/carfinder_app-300x300.png 300w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/carfinder_app-150x150.png 150w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/carfinder_app-768x768.png 768w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/carfinder_app-1024x1024.png 1024w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/carfinder_app.png 2000w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>A good starting point for building an app with AWS AppSync is the <a href=\"https:\/\/docs.aws.amazon.com\/appsync\/latest\/devguide\/building-a-client-app-ios.html\">documentation<\/a>. The section Code Generation for the API was a little bit unclear for me so I will explain it. AWS provides a tool to generate an API Swift code out of your schema file and queries for you. You need two files to generate the code.<\/p>\n<ul>\n<li>First, the schema file (<em>schema.json<\/em>). You can download it on the web\u00a0interface here: <a href=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/schema-download.png\"><br \/>\n<img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"4344\" data-permalink=\"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2018\/09\/14\/yet-another-connected-vehicle-cloud-platform\/schema-download\/\" data-orig-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/schema-download.png\" data-orig-size=\"700,471\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Schema download\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/schema-download.png\" class=\"alignnone size-medium wp-image-4344\" src=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/schema-download-300x202.png\" alt=\"\" width=\"300\" height=\"202\" srcset=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/schema-download-300x202.png 300w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/schema-download.png 700w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>Second, you need to create a new file called <em>query.graphql<\/em>. Put the queries here:\n<pre class=\"prettyprint lang-javascript\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">query GetCar($vin: String!) {\n    getCar(vin: $vin) {\n        vin\n        lat\n        long\n    }\n}\n\nquery ListCars {\n    listCars {\n        vin\n        lat\n        long\n    }\n}&lt;span data-mce-type=\"bookmark\" style=\"display: inline-block; width: 0px; overflow: hidden; line-height: 0;\" class=\"mce_SELRES_start\"&gt;&lt;\/span&gt;<\/pre>\n<p>&nbsp;<\/li>\n<li>Put both files in a folder called <i>GraphQLOperations<\/i><\/li>\n<li>generate the API file with<code class=\"\" data-line=\"\"> aws-appsync-codegen generate GraphQLOperations\/*.graphql --schema GraphQLOperations\/schema.json --output API.swift<\/code><\/li>\n<\/ul>\n<p><strong>App Authentication<\/strong><\/p>\n<p>With AWS AppSync you have the possibility to decide between four different authentication methods:<\/p>\n<ul>\n<li>API key<\/li>\n<li>OIDC (OpenID Connect)<\/li>\n<li>Amazon Cognito user pools<\/li>\n<li>AWS IAM (Identity and Access Management)<\/li>\n<\/ul>\n<p>For simplicity, I decided to use for this Prototype the API key. I had no intention of rolling out the prototype for people other than myself. If planned, I will switch to Cognito Authentication. I know, it is not a good way, even for prototypes. Everyone with that API key and the App can access all vehicles. But for a first demo and proof of concept, it seems to be enough for me. On further development, I will change it. Another disadvantage of the API key Method is that the key expires after one week. So have to generate a new key and rebuild the app.<\/p>\n<p>With Cognito User Pools it is also possible to define user groups to restrict access. So it would be possible that normal user only can access the assigned car but car-pool managers can access all cars.<\/p>\n<h2>&#8220;Alexa, ask carfinder where is my car&#8221;<\/h2>\n<h4>The Alexa Skill<\/h4>\n<p>In addition to the app, I created a simple Alexa Skill. The Alexa skill should answer the following question:<\/p>\n<blockquote><p>What would be the easiest way for an employee to get to know about the vehicle position of a pool car?<\/p><\/blockquote>\n<p>Actually, the employee has to look up in the driver&#8217;s log. But sometimes the position is described as inaccurate or incorrect. Alexa can answer this question much better. In addition, if an echo device with a display is used, it shows a map with the location.<\/p>\n<p>A question to a skill is constructed as followed:<\/p>\n<p><em>[Keyword &#8220;Alexa&#8221;] [Skill Invocation Name] [Intent, optional with Slots]<\/em><\/p>\n<p>A sample question could be:<\/p>\n<blockquote><p>Alexa, ask carpool where is my car?<\/p><\/blockquote>\n<p><em>&#8220;carpool&#8221;<\/em> is the skill invocation name, <em>&#8220;my car&#8221;<\/em> is a sample for the intent slot named &#8220;car&#8221; and <em>&#8220;where is {car}&#8221;<\/em> is a sample utterance.<\/p>\n<p>These three things are most important to set up. The Alexa skill is set up by an Amazon developer account (in difference to an AWS business account). After building the model an Endpoint has to be defined. This could be a lambda function or an HTTPS endpoint. I decided to use a lambda function. Using the <a href=\"https:\/\/skillinator.io\/\">Skillinator<\/a>, I generated a code example based on my JSON skill model and modified it for my needs. I implemented the link between the skill and the vehicle-snapshot DynamoDB table so that you can ask for specific cars. With the Here API, the geo-coordinates are translated into addresses. So when you ask for the position you get the street, number, and city and also the name of the next POI. This is helpful when you don&#8217;t know the exact address but the next POI like another company or a restaurant.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Getting Ideas&#8230;\u00a0write a User Story When I thought about an idea for a project, part of the lecture &#8220;Software Development for Cloud Computing&#8221;, I had two related use-cases in mind. So I wrote down those high-level user-stories: As a user who owns a non-connected car, I want to access some information about my car on [&hellip;]<\/p>\n","protected":false},"author":899,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[120,650],"tags":[],"ppma_author":[775],"class_list":["post-4306","post","type-post","status-publish","format-standard","hentry","category-cloud-technologies","category-scalable-systems"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":11460,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2020\/09\/29\/get-car-location-using-raspberrypi-and-google-cloud-iot-core\/","url_meta":{"origin":4306,"position":0},"title":"Get car location using Raspberry Pi and Google Cloud IoT Core","author":"Simon L\u00f6bert","date":"29. September 2020","format":false,"excerpt":"Project idea Have you ever been in the situation, that you parked your car somewhere in the city and some hours later, you couldn't remember where you parked it? You may wish to have an application on your smartphone, which is able to locate your car. From this consideration, the\u2026","rel":"","context":"In &quot;Allgemein&quot;","block_context":{"text":"Allgemein","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/allgemein\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2020\/09\/grafik.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":25086,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2023\/07\/28\/botnets-on-wheels-how-hackable-are-connected-autonomous-vehicles-and-what-are-we-doing-about-it\/","url_meta":{"origin":4306,"position":1},"title":"\u201cBotnets on Wheels\u201d \u2013 How Hackable Are Connected Autonomous Vehicles And What Are We Doing About It?","author":"zack walker","date":"28. July 2023","format":false,"excerpt":"Can you imagine the vehicle of the future? The vehicle of the future will not have a steering wheel, no pedals for acceleration and brakes \u2013 you will not be able to drive it at all! Most \u2013 if not all \u2013 of you will have heard a lot about\u2026","rel":"","context":"In &quot;Allgemein&quot;","block_context":{"text":"Allgemein","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/allgemein\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2023\/07\/learning-for-autonomous-driving-header-scaled.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2023\/07\/learning-for-autonomous-driving-header-scaled.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2023\/07\/learning-for-autonomous-driving-header-scaled.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2023\/07\/learning-for-autonomous-driving-header-scaled.jpg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2023\/07\/learning-for-autonomous-driving-header-scaled.jpg?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2023\/07\/learning-for-autonomous-driving-header-scaled.jpg?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":3283,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2017\/10\/25\/vulnerable-vehicles\/","url_meta":{"origin":4306,"position":2},"title":"Vulnerable Vehicles &#8211; Connected cars and their security issues","author":"Christian Trendli","date":"25. October 2017","format":false,"excerpt":"In times of the continuing Internet-of-things- and connectivity-hype, a connected variant of \u201cthe German\u2019s favourite toy\u201d cannot be absent. Modern cars, SUVs and lightweight trucks come with all kinds of connected features, from smartphone interface integration up to social media in the navigation system. But what about the security of\u2026","rel":"","context":"In &quot;Allgemein&quot;","block_context":{"text":"Allgemein","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/allgemein\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2017\/10\/titkle.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2017\/10\/titkle.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2017\/10\/titkle.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2017\/10\/titkle.jpg?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":5104,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2019\/02\/26\/end-to-end-monitoring-of-modern-cloud-applications\/","url_meta":{"origin":4306,"position":3},"title":"End-to-end Monitoring of Modern Cloud Applications","author":"je052","date":"26. February 2019","format":false,"excerpt":"During the last semester and as part of my Master's thesis, I worked at an automotive company on the development of a vehicle connectivity platform. Within my team I was assigned the task of monitoring, which turned out to be a lot more interesting but at the same time way\u2026","rel":"","context":"In &quot;Allgemein&quot;","block_context":{"text":"Allgemein","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/allgemein\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2019\/02\/diagram-1024x540.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2019\/02\/diagram-1024x540.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2019\/02\/diagram-1024x540.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":4395,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2019\/01\/17\/radcup-a-socialmedia-beerpong-app\/","url_meta":{"origin":4306,"position":4},"title":"Radcup &#8211; a socialmedia beerpong App","author":"Immanuel Haag","date":"17. January 2019","format":false,"excerpt":"Written by: Immanuel Haag, Christian M\u00fcller, Marc R\u00fcttler Radcup adds a bit of social media to the well-known game Beerpong. With Radcup the user has the possibility to register or login. Afterwards he can display\/localize already existing games and join them if possible or create new games. As soon as\u2026","rel":"","context":"In &quot;System Designs&quot;","block_context":{"text":"System Designs","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/system-designs\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-06-at-15.09.35.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-06-at-15.09.35.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-06-at-15.09.35.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":798,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2016\/07\/29\/socialcloud-lessons-learned-part-8\/","url_meta":{"origin":4306,"position":5},"title":"SocialCloud &#8211; Lessons Learned &#8211; Part 8","author":"Anna Poth","date":"29. July 2016","format":false,"excerpt":"Looking back at 4 months of intensive work on our project \u201cSocialCloud\u201d we gathered a lot of experiences and learned many things regarding teamwork, cloud infrastructure and about the difficulties of creating and designing a web application from scratch. Read this blogpost to be prepared for your next big project!\u2026","rel":"","context":"In &quot;Allgemein&quot;","block_context":{"text":"Allgemein","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/allgemein\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2016\/07\/20141202185508-8-enduring-lessons-learned-my-clients-2014.jpeg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2016\/07\/20141202185508-8-enduring-lessons-learned-my-clients-2014.jpeg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2016\/07\/20141202185508-8-enduring-lessons-learned-my-clients-2014.jpeg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2016\/07\/20141202185508-8-enduring-lessons-learned-my-clients-2014.jpeg?resize=700%2C400&ssl=1 2x"},"classes":[]}],"jetpack_sharing_enabled":true,"authors":[{"term_id":775,"user_id":899,"is_guest":0,"slug":"dl045","display_name":"dl045","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/93189d7a4255cf4d6c7b6a4a1824b509c1ef67abfff610d1a40d18b01fb885cd?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/posts\/4306","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/users\/899"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/comments?post=4306"}],"version-history":[{"count":11,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/posts\/4306\/revisions"}],"predecessor-version":[{"id":4575,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/posts\/4306\/revisions\/4575"}],"wp:attachment":[{"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/media?parent=4306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/categories?post=4306"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/tags?post=4306"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/ppma_author?post=4306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}