Working helloworld for mDot. ABP auth.

Dependencies:   libmDot-mbed5

Files at this revision

API Documentation at this revision

Comitter:
GreensladeNZ
Date:
Sun Aug 04 10:48:46 2019 +0000
Parent:
14:c05bcdee1483
Commit message:
Working.

Changed in this revision

DHT22.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/DHT22.lib	Tue Jun 12 02:38:01 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/users/Julepalme/code/DHT22/#7fd3ff04ae95
--- a/main.cpp	Tue Jun 12 02:38:01 2018 +0000
+++ b/main.cpp	Sun Aug 04 10:48:46 2019 +0000
@@ -1,8 +1,6 @@
 /*
 This program:
  - connects to a LoRaWAN by ABP/MANUAL
- - reads light data from an analogue Light Dependent Resistor
- - reads temperaure and humidity from a DHT22 sensor
  - sends the recorded data onto the LoRaWAN
  - sets the mDot to sleep
  - repeats these operations in a loop
@@ -14,31 +12,21 @@
 #include "MTSLog.h"
 #include "dot_util.h"
 #include "mbed.h"
-#include "DHT22.h"
 #include <string>
 #include <vector>
 #include <algorithm>
 #include <sstream>
 
- //analogue ldr pin (A0 on UDK 2)
- AnalogIn a0(PB_1);
-
+// Device address
+static uint8_t network_address[] = { 0x00, 0x00, 0x00, 0x00 };
+// Network session key
+static uint8_t network_session_key[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+// Application sesssion key
+static uint8_t data_session_key[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
 
-// these options must match the settings on your Conduit
-/*
-Current test settings
-dev address: 064ac45b
-net sess key: 5526fe0a28a974eb070f7b450433c35c
-app sess key: f42ea6890802d8f2c3e9d0d9f37c80a6
-*/
-//device address
-static uint8_t network_address[] = { 0x06, 0x10, 0x9f, 0xb0 };
-//network session key
-static uint8_t network_session_key[] = { 0x04, 0xb9, 0xb4, 0x7f, 0x20, 0xdb, 0x3a, 0xa3, 0x8f, 0xf5, 0xef, 0xd1, 0x39, 0x02, 0xde, 0x5e };
-//application sesssion or data session key
-static uint8_t data_session_key[] = { 0x92, 0x57, 0xa7, 0xe4, 0x2e, 0x47, 0x04, 0x54, 0x5c, 0xed, 0x0a, 0xbe, 0x5a, 0x99, 0xcd, 0xf9 };
-static uint8_t frequency_sub_band = 2; //VFI
+static uint8_t frequency_sub_band = 2; // VFI
 static bool public_network = true;
+
 //enable receipt of ackknowledge packets 0 = No, 1 = Yes
 static uint8_t ack = 0;
 //adaptive data rate enabler
@@ -88,16 +76,6 @@
             }
         }
         // in MANUAL join mode there is no join request/response transaction
-        // as long as the Dot is configured correctly and provisioned correctly on the gateway, it should be able to communicate
-        // network address - 4 bytes (00000001 - FFFFFFFE)
-        // network session key - 16 bytes
-        // data session key - 16 bytes
-        // to provision your Dot with a Conduit gateway, follow the following steps
-        //   * ssh into the Conduit
-        //   * provision the Dot using the lora-query application: http://www.multitech.net/developer/software/lora/lora-network-server/
-        //      lora-query -a 01020304 A 0102030401020304 <your Dot's device ID> 01020304010203040102030401020304 01020304010203040102030401020304
-        //   * if you change the network address, network session key, or data session key, make sure you update them on the gateway
-        // to provision your Dot with a 3rd party gateway, see the gateway or network provider documentation
         update_manual_config(network_address, network_session_key, data_session_key, frequency_sub_band, public_network, ack);
 
 
@@ -111,7 +89,7 @@
         //* DR2 - SF8BW125 -- 129 byte
         //* DR3 - SF7BW125 -- 242 bytes
         //* DR4 - SF8BW500 -- 242 bytes
-        dot->setTxDataRate(mDot::DR2);
+        dot->setTxDataRate(mDot::DR3);
         
         // save changes to configuration
         logInfo("saving configuration");
@@ -135,35 +113,10 @@
         wait(5);
         //init data variable
         std::vector<uint8_t> data;
-        logInfo("Starting reed sensor readings");
-        float reed1 = a0.read() * 10;
-        wait_ms(100);
-        float reed2 = a0.read() * 10;
-        wait_ms(100);
-        float reed3 = a0.read() * 10;
-        wait_ms(100);
-        
-        float reedFinal = (reed1 + reed2 + reed3)/3;
-        logInfo("Reed sensor readings taken");
         
-        if (reedFinal <= 0.1)
-        {
-           logInfo("/n");
-           logInfo("Gate is Closed!"); 
-           logInfo("/n");
-        }
-        else 
-        {
-           logInfo("/n");
-           logInfo("Gate is Open!"); 
-           logInfo("/n");
-        }
-    
-        //build our output string now
-        string reed_str = ToString(reedFinal);
-        string output = "Reed Switch Reading:" + reed_str;   
+        // String to send
+        string output = "Hello World!";   
         
-    
         //serial output for debugging
         logInfo("Sending %s", output.c_str());