example for iot course

Files at this revision

API Documentation at this revision

Comitter:
marcozecchini
Date:
Wed Mar 13 17:30:20 2019 +0000
Parent:
49:699a601deb79
Commit message:
example final version

Changed in this revision

DummySensor.h Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-lora-radio-drv.lib Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
diff -r 699a601deb79 -r 6e615eea1e6f DummySensor.h
--- a/DummySensor.h	Wed Mar 06 13:02:08 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/**
- * Copyright (c) 2017, Arm Limited and affiliates.
- * SPDX-License-Identifier: Apache-2.0
- *
- * 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.
- */
-
-#ifndef MBED_LORAWAN_DUMMYSENSOR_H_
-#define MBED_LORAWAN_DUMMYSENSOR_H_
-
-/*
- * A dummy sensor for Mbed LoRa Test Application
- */
-class DS1820 {
-public:
-    DS1820(uint32_t)
-    {
-        value = 1.0f;
-    };
-    bool begin()
-    {
-        return true;
-    };
-    void startConversion() {};
-    float read()
-    {
-        value += 1.1f;
-        return value;
-    }
-
-private:
-    float value;
-};
-
-
-
-#endif /* MBED_LORAWAN_DUMMYSENSOR_H_ */
diff -r 699a601deb79 -r 6e615eea1e6f main.cpp
--- a/main.cpp	Wed Mar 06 13:02:08 2019 +0000
+++ b/main.cpp	Wed Mar 13 17:30:20 2019 +0000
@@ -21,7 +21,6 @@
 #include "events/EventQueue.h"
 
 // Application helpers
-#include "DummySensor.h"
 #include "trace_helper.h"
 #include "lora_radio_helper.h"
 
@@ -50,15 +49,6 @@
  */
 #define CONFIRMED_MSG_RETRY_COUNTER     3
 
-/**
- * Dummy pin for dummy sensor
- */
-#define PC_9                            0
-
-/**
- * Dummy sensor class object
- */
-DS1820  ds1820(PC_9);
 
 /**
 * This event queue is the global event queue for both the
@@ -152,20 +142,9 @@
 {
     uint16_t packet_len;
     int16_t retcode;
-    float sensor_value;
+    printf("\n\rHello world");    
 
-    if (ds1820.begin()) {
-        ds1820.startConversion();
-        sensor_value = ds1820.read();
-        printf("\r\n Dummy Sensor Value = %3.1f \r\n", sensor_value);
-        ds1820.startConversion();
-    } else {
-        printf("\r\n No sensor found \r\n");
-        return;
-    }
-
-    packet_len = sprintf((char *) tx_buffer, "Dummy Sensor Value is %3.1f",
-                         sensor_value);
+    packet_len = sprintf((char *) tx_buffer, "Hello world");
 
     retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, tx_buffer, packet_len,
                            MSG_UNCONFIRMED_FLAG);
@@ -188,29 +167,6 @@
 }
 
 /**
- * Receive a message from the Network Server
- */
-static void receive_message()
-{
-    uint8_t port;
-    int flags;
-    int16_t retcode = lorawan.receive(rx_buffer, sizeof(rx_buffer), port, flags);
-
-    if (retcode < 0) {
-        printf("\r\n receive() - Error code %d \r\n", retcode);
-        return;
-    }
-
-    printf(" RX Data on port %u (%d bytes): ", port, retcode);
-    for (uint8_t i = 0; i < retcode; i++) {
-        printf("%02x ", rx_buffer[i]);
-    }
-    printf("\r\n");
-    
-    memset(rx_buffer, 0, sizeof(rx_buffer));
-}
-
-/**
  * Event handler
  */
 static void lora_event_handler(lorawan_event_t event)
@@ -247,7 +203,6 @@
             break;
         case RX_DONE:
             printf("\r\n Received message from Network Server \r\n");
-            receive_message();
             break;
         case RX_TIMEOUT:
         case RX_ERROR:
diff -r 699a601deb79 -r 6e615eea1e6f mbed-lora-radio-drv.lib
--- a/mbed-lora-radio-drv.lib	Wed Mar 06 13:02:08 2019 +0000
+++ b/mbed-lora-radio-drv.lib	Wed Mar 13 17:30:20 2019 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-semtech-lora-rf-drivers#16958f814d505cfbbedfa16d9bf8b9dff0e0442b
+https://github.com/ARMmbed/mbed-semtech-lora-rf-drivers/#16958f814d505cfbbedfa16d9bf8b9dff0e0442b
diff -r 699a601deb79 -r 6e615eea1e6f mbed-os.lib
--- a/mbed-os.lib	Wed Mar 06 13:02:08 2019 +0000
+++ b/mbed-os.lib	Wed Mar 13 17:30:20 2019 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#ecb3c8c837162c73537bd0f3592c6e2a42994045
+https://github.com/ARMmbed/mbed-os/#51d55508e8400b60af467005646c4e2164738d48
diff -r 699a601deb79 -r 6e615eea1e6f mbed_app.json
--- a/mbed_app.json	Wed Mar 06 13:02:08 2019 +0000
+++ b/mbed_app.json	Wed Mar 13 17:30:20 2019 +0000
@@ -27,15 +27,15 @@
     },
     "target_overrides": {
         "*": {
-            "platform.stdio-convert-newlines": true,
+            "platform.stdio-convert-newlines": false,
             "platform.stdio-baud-rate": 115200,
             "platform.default-serial-baud-rate": 115200,
-            "lora.over-the-air-activation": true,
-            "lora.duty-cycle-on": true,
+            "lora.over-the-air-activation": false,
+            "lora.duty-cycle-on": false,
             "lora.phy": "EU868",
-            "lora.device-eui": "{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }",
-            "lora.application-eui": "{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }",
-            "lora.application-key": "{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }"
+            "lora.appskey": "{ 0xCD, 0xA9, 0x0D, 0x58, 0x4A, 0x45, 0x47, 0xE7, 0x77, 0x06, 0x63, 0x7E, 0x7B, 0x0D, 0x88, 0xC1 }",
+            "lora.nwkskey": "{ 0x30, 0xFD, 0x2C, 0xD2, 0x46, 0x06, 0xE5, 0xAE, 0x21, 0x8E, 0xCF, 0x29, 0xCE, 0xFB, 0xC1, 0xA1 }",
+            "lora.device-address": "0x26011BF1" 
         },
 
         "K64F": {