Senet network coverage survey tool

Dependencies:   GeoPosition Senet_Packet lib_gps lib_mma8451q lib_mpl3115a2 lib_sx9500 lmic_MOTE_L152RC mbed-src

Senet Network Coverage Program

Test Senet Network coverage with various data rates and transmit powers

/media/uploads/shaunkrnelson/norammote.jpg

Configure Device ID and App Key

For your device to connect to the Senet Network, set Device ID and App Key in Commissioning.h

Commissioning.h

/* CHANGE: Device ID  registered to your Developer Portal account */
 u1_t reverse_DEVEUI[8]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; 

/* CHANGE: Device App Key. To get this select the device, click on Gear button at top left then select Device Edit */  
u1_t DEVKEY[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
                                                                        
/*NOCHANGE: Senet Developer Portal Application ID */ 
 u1_t reverse_APPEUI[8]={0x00,0x25,0x0C,0x00,0x00,0x01,0x00,0x01};
 

Connecting to the Senet Network

When the device is turned on the USR LED will blink while it is joining the Senet Network. When LED state changes to solid green it has joined the network. Failure to join network will be the result of:

  1. No network coverage in that area
  2. App Key configuration is incorrect

Siting Mode

The device is in Siting test mode when positioned vertically with LEDs facing up. The Siting test consists of transmitting Senet GPS packets with acknowledgment requested at transmit power levels 14, 20, 30 in that order. For each power level the device will attempt 3 transmits at DR0, stopping if ack is received and moving on to next tx power. After first run through all powers at DR0 the test will stop if acknowledgements received at all power levels; otherwise, the test will proceed to alternate between 3 transmits at DR4 and 3 at DR0 for remaining unacknowledged tx powers until ack received.

Siting LED Profile

  1. USR
    1. Blink fast while joining
    2. Solid when joined and GPS lock
    3. Blink slow when not GPS lock
  1. RED
    1. 30 dBm status indicator
    2. Blink on transmit
    3. Solid after downlink received
  1. YELLOW
    1. 20 dBm status indicator
    2. Blink on transmit
    3. Solid after ack received
  1. GREEN
    1. 14 dBm status indicator
    2. Blink on transmit
    3. Solid after downlink received

Range Mode

The device is in this mode when not in the siting orientation.
This test consists of transmitting 8 packets at:

  1. DR3 Tx Power 14
  2. DR0 Tx Power 14
  3. DR4 Tx Power 20
  4. DR3 Tx Power 20
  5. DR0 Tx Power 20
  6. DR4 Tx Power 26
  7. DR3 Tx Power 30
  8. DR0 Tx Power 30

After transmit cycle completes the next test will start in 560 seconds unless following:

  1. After 140 seconds if no ack received
  2. After 80 seconds if 30 meters travelled from last transmit location

Range LED Profile

  • USR
    • Blink fast while joining
    • Solid when joined and GPS lock
    • Blink slow when not GPS locked
  • RED
    • Transmit indicator
    • Blink on transmit
  • YELLOW
    • Ack indicator
    • Set at beginning of transmit cycle and cleared when ack received
  • GREEN
    • V3 Mote
      • Test indicator
      • Solid while test transmit cycle in progress
    • V2 Mote
      • Not controllable by firmware

Switching Mode

Set mote orientation to desired mode. After a few seconds the new orientation will be detected and the device will indicate it is switching mode by blinking the red, yellow and green LEDs simultaneously for a couple seconds before switching to the new mode.

Revision:
16:2e5438977b6c
Parent:
10:72c5e2cfa473
Child:
19:e37b3bd60d5a
--- a/main.cpp	Fri Aug 12 13:54:34 2016 +0000
+++ b/main.cpp	Fri Sep 02 14:09:07 2016 +0000
@@ -17,7 +17,7 @@
 #define BUILD_NUMBER   0
 #define DEVELOPER_ID   0
 
-#define DR_TX_FLOATING
+
 
 // provide application router ID (8 bytes, LSBF)
 void os_getArtEui (u1_t* buf) {
@@ -65,10 +65,6 @@
 u1_t dr = 0;
 // Applicative transmit power
 u1_t pw = 0;
-// x-y-z orientation
-uint16_t orientation_mask = 0x0000;
-// is the device moving or not
-bool stationary = true;
 
 // LEDs
 #define LED_RED         PB_1
@@ -227,25 +223,6 @@
 
             break;
         }
-        case SENSOR_PACKET:
-        {
-            // Read Sensors
-            mpl3115a2.SetModeActive();
-            uint16_t pressure = mpl3115a2.ReadBarometer();
-            uint16_t temperature = mpl3115a2.ReadTemperature();
-            mpl3115a2.SetModeStandby();
-                        
-            // Sensor packet type serialized to the LMIC frame buffer
-            SensorPacket packet(LMIC.frame, MAX_LEN_FRAME);
-            packet.setPrimarySensor(orientation_mask);
-            packet.setTemperature(temperature);
-            packet.setPressure(pressure);
-            
-            // Serialize  packet to LMIC transmit buffer
-            pktLen = packet.serialize();
-
-            break;
-        }
         case GPS_PACKET:
         default:
         { 
@@ -298,9 +275,6 @@
 {
     // reset MAC state
     LMIC_reset(); 
-#ifdef DR_TX_FLOATING
-    LMIC_setAdrMode(true);
-#endif
     // start joining
     LMIC_startJoining();
 }
@@ -487,29 +461,25 @@
         }
         os_setTimedCallback( &txLedJob, os_getTime() + 1, txLedCb); 
     }
-#ifndef DR_TX_FLOATING
-    // Set next dr and tx power 
-    LMIC_setDrTxpow(dr,pw);   
-#else
-    pw = LMIC.txpow;   
-#endif
+
     // Send GPS data 
     for(int32_t i=0; i<3; i++)
     {
         if(gps_service() == true)
         {
-            if(!stationary || (0 != txCount&0x7))
-                pktSize = PrepareDataFrame(GPS_PACKET); 
-                            
+            pktSize = PrepareDataFrame(GPS_PACKET); 
             break;
         }
     }
     
-    // if unable to get GPS or stationary, send sensor packet
+    // if unable to get GPS, send self-id
     if(0 == pktSize)
-        pktSize = PrepareDataFrame(SENSOR_PACKET); 
+        pktSize = PrepareDataFrame(SELF_ID_PACKET); 
    
 
+    // Set next dr and tx power 
+    LMIC_setDrTxpow(dr,pw);      
+
     txCount++;
     txMode = operMode;
 
@@ -524,15 +494,17 @@
 
     debug("%u seconds elapsed since last test\r\n",osticks2ms(os_getTime()-lastTestDoneT)/1000);
 
-    stationary = true;
-    if(gps_service())
+    if(os_getTime() >= startT)
+    {
+        os_setCallback( &sendFrameJob, onSendFrame ); 
+    }
+    else if(gps_service())
     {
         // Do we have last tx coordinates 
         if((lastTxPos.latitude() == 0) && (lastTxPos.longitude() == 0))
         {
             // Set last tx position to current location 
             lastTxPos.set(gps.Latitude,gps.Longitude);
-            stationary = false;
         }
         else
         {
@@ -542,16 +514,11 @@
             if(distance >= RANGE_START_TEST_DISTANCE)
             {
                 debug("position change %f >= %u\r\n",distance, RANGE_START_TEST_DISTANCE);
-                stationary = false;
                 os_setCallback( &sendFrameJob, onSendFrame ); 
                 return;
             }
         }
     }
-    else if(os_getTime() >= startT)
-    {
-        os_setCallback( &sendFrameJob, onSendFrame ); 
-    }
     
     // Schedule next check 
     ostime_t nextChkT = os_getTime() + sec2osticks(RANGE_NEXT_TEST_DISTANCE_T);
@@ -767,90 +734,26 @@
     os_setTimedCallback( &statusLedJob, os_getTime() + sec2osticks(sleep), statusLedCb ); 
 }
 
-bool leds_are_down = false;
 
 static void orientationJobCb(osjob_t *job)
 {
     static MMA_orientation last;
-           MMA_orientation orientation;
+           MMA_orientation current;
            int             sleepTime = ORIENTATION_CHECK_PERIOD;
 
     mma8451q.service();
-    orientation = mma8451q.getOrientation(); 
+    current = mma8451q.getOrientation(); 
 
-    if(orientation != last)
+    if(current != last)
     {
-        last = orientation;
+        last = current;
         sleepTime  = ORIENTATION_DEBOUNCE_TIME;
     }
     else 
-    { 
-    /* Get orientation using the portrait/landscape status
-         * When viewing device from front orientation is: 
-         *  - LED UP    = landscape right
-         *  - LED LEFT  = portrait up
-         *  - LED DOWN  = landscape left
-         *  - LED RIGHT = portrait down
-         *
-         *  NOTE:
-         *    When low is true the device is flat and the orientation will always be portrait up
-         *
-         */
-         
-         bool flat  = false;
-         bool up    = false;
-         bool down  = false;
-         bool right = false;
-         bool left  = false;
+    {
+        const bool currIsVertical = !current.low && current.right;
+        const OperMode mode = currIsVertical ? SITE_TEST : RANGE_TEST; 
 
-        if(orientation.low)
-        {
-            flat = true;
-        }
-        else if(orientation.right)
-        {
-            up  = true;
-        }
-        else if(orientation.up)
-        {
-            left = true;
-        }
-        else if(orientation.left)
-        {
-            down = true;
-        }
-        else if(orientation.down)
-        {
-            right = true;
-        }
-
-        const OperMode mode = up ? SITE_TEST : RANGE_TEST; 
-        
-        uint16_t new_orientation_mask;
-        
-        /* Orientation mask values
-         *  - LED-UP    = 1000
-         *  - LED-LEFT  = 0100
-         *  - LED-DOWN  = 0010
-         *  - LED-RIGHT = 0001
-         * Flat
-         *  - front is up   = 2000
-         *  - front is down = 2100
-         */
-        if(!flat)
-        {
-            new_orientation_mask = (up << 12) | (left << 8) | (down << 4) | right;
-        }
-        else
-        {
-            new_orientation_mask = (2 << 12) | (orientation.back << 8);
-        }
-        
-        leds_are_down = down;
-
-        bool send_now = new_orientation_mask != orientation_mask;
-        orientation_mask = new_orientation_mask;
-        
         if(mode != operMode)
         {
             debug("Change to %s mode\r\n", mode==SITE_TEST?"Site":"Range");
@@ -882,8 +785,6 @@
             sitePw  = 0;
             memset(siteAck, 0, sizeof(siteAck));
         }
-        else if (send_now)
-            os_setCallback( &sendFrameJob, onSendFrame);
     }
 
     os_setTimedCallback( &orientationJob, os_getTime() + sec2osticks(sleepTime), orientationJobCb );