Basic MAC data interface for LoRa transceiver

Dependencies:   L2Frame crc

Dependents:   LoRaBaseStation LoRaTerminal

Revision:
11:3e1ff29da71a
Parent:
10:065a4b58c6ff
Child:
15:0dc9df48687a
--- a/AlohaTransceiver.cpp	Wed Jul 27 03:42:12 2016 +0000
+++ b/AlohaTransceiver.cpp	Wed Jul 27 04:37:34 2016 +0000
@@ -53,8 +53,11 @@
  * Abstract interface for accessing radio driver
  */
 
-AlohaTransceiver::AlohaTransceiver()
+AlohaTransceiver::AlohaTransceiver(uint8_t id)
 {
+    // store unique device id
+    deviceId = id;
+    
     // configure properties
 #if USE_MODEM_LORA == 1
     Settings.Power = TX_OUTPUT_POWER;
@@ -143,10 +146,17 @@
             // create new frame instance
             AlohaFrame frame(Buffer, BufferSize);
             
-            // execute callback functions
-            if (AlohaTypeCallbackTable[frame.getType()] != NULL)
+            // check destination
+            // if the destination is the device id, then processing, otherwise drop the packet and continue
+            // listening
+            if (frame.getDestinationAddress() == (deviceId & 0x0f))
             {
-                AlohaTypeCallbackTable[frame.getType()](&frame);
+                // check registered callback function
+                // execute callback functions if registered
+                if (AlohaTypeCallbackTable[frame.getType()] != NULL)
+                {
+                    AlohaTypeCallbackTable[frame.getType()](&frame);
+                }
             }
 
             Radio.Rx( 0 );
@@ -215,6 +225,16 @@
     return SnrValue;
 }
 
+uint8_t AlohaTransceiver::getDeviceId()
+{
+    return deviceId;
+}
+
+void AlohaTransceiver::setDeviceId(uint8_t id)
+{
+    deviceId = id;
+}
+
 #if USE_MODEM_LORA == 1
 AlohaTransceiver::LoRaSettings_t *AlohaTransceiver::getSettings()
 {