際際滷

際際滷Share a Scribd company logo
MORENA: A Middleware for Programming
      NFC-enabled Android Applications as
      Distributed Object-Oriented Programs
      Andoni Lombide Carreton
      Kevin Pinte
      Wolfgang De Meuter




       ACM/IFIP/USENIX 13th International Conference on Middleware 2012
       December 5 2012
       Montreal, Canada

Monday 28 January 13
RFID in Android

       NFC (touch range).
                                  NdefMessage: {
       Callback on activities                        ,
        to detect RFID tags
        with subscribed MIME-                         , NdefRecord
        type in memory.                                 byte array
                                  }
       File access abstraction



                                      read    write




Monday 28 January 13
Drawbacks of the Android NFC API

       Manual failure handling (and NFC causes A LOT of failures because of its
        hardware characteristics).


       Blocking communication (Android documentation recommends to use a
        separate thread for many RFID operations).


       Manual data conversion


       Tight coupling with activity-based architecture




Monday 28 January 13
Lessons Learnt from Previous Ambient-Oriented
      Programming Research

       Using objects as 鍖rst class software representations for RFID-tagged things
        is a nice abstraction.


       These objects can be directly stored in the RFID tags memory to minimize
        data conversion.


       Event-driven discovery (fortunately built-in into Android).


       Asynchronous reads and writes.




Monday 28 January 13
Middleware Architecture



                       Application

                       Thing level   One middleware
                                     for Android 4.0
                        Tag level        or higher

                        Android



Monday 28 January 13
Evaluation: WiFi Sharing Application




Monday 28 January 13
Evaluation: WiFi Sharing Application




Monday 28 January 13
Things

                                                          From now on, we dont
   public class WifiConfig extends Thing {                have to worry about the
   	    public String ssid_;
                                                             activity anymore.
   	    public String key_;

   	    public WifiConfig(ThingActivity<WifiConfig> activity, String ssid, String key) {
   	    	 super(activity);
   	    	 ssid_ = ssid;
   	    	 key_ = key;
   	    }
   	
   	    public boolean connect(WifiManager wm) {
        	 // Connect to ssid_ with password key_	
   	    };
                                                    Supported serialization:
   }
                                                     - JSON-serializable 鍖elds.
                                                     - Skipping transient 鍖elds.
                                                     - Deep serialization, no cycles.
Monday 28 January 13
Initializing Things
                                     As soon as an empty
                                        tag is detected
              @Override
              public void whenDiscovered(EmptyRecord empty) {
                  empty.initialize(
                         myWifiThing,
                         new ThingSavedListener<WifiConfig>() {
              	 	 	        @Override
              	 	 	        public void signal(WifiConfig thing) {
              	 	 	 	          toast("WiFi joiner created!");
              	 	 	        }
              	 	       },
              	 	     new ThingSaveFailedListener() {
              	 	 	        @Override
              	 	 	        public void signal() {
              	 	 	 	         toast("Creating WiFi joiner failed, try again.");
              	 	 	        }
              	 	     });
              }
Monday 28 January 13
Discovering and Reading Things


                                         As soon as a Wi鍖Con鍖g
                                             tag is detected
                       @Override
                       public void whenDiscovered(WifiConfig wc) {
                          toast("Joining Wifi network " + wc.ssid_);
                       	 wc.connect();
                       }
                                                Contains cached 鍖elds for
                                                  synchronous access.
                                                 Physical reads must be
                                                     asynchronous.




Monday 28 January 13
Saving Modi鍖ed Things

          myWifiConfig.ssid_ = "MyNewWifiName";
          myWifiConfig.key_ = "MyNewWifiPassword";

          myWifiConfig.saveAsync(
                new ThingSavedListener<WifiConfig>() {
          	         @Override
          	 	 	    public void signal(WifiConfig wc) {
          	 	 	 	     toast("WiFi joiner saved!");
          	 	 	    }
          	 	 },
          	 	 new ThingSaveFailedListener() {
          	         @Override
          	 	 	    public void signal() {
          	 	           toast("Saving WiFi joiner failed, try again.");
          	 	 	    }
                });



Monday 28 January 13
Broadcasting Things to Other Phones

                                  Will trigger whenDiscovered on the
                              receiving phone with the broadcasted thing

          myWifiConfig.broadcast(
                new ThingBroadcastSuccessListener<WifiConfig>() {
          	         @Override
          	 	 	    public void signal(WifiConfig wc) {
          	 	 	 	     toast("WiFi joiner shared!");
          	 	 	    }
          	 	 },
          	 	 new ThingBroadcastFailedListener<WifiConfig>() {
          	         @Override
          	 	 	    public void signal(WifiConfig wc) {
          	 	           toast("Failed to share WiFi joiner, try again.");
          	 	 	    }
                });


Monday 28 January 13
Evaluation: WiFi Sharing Application




Monday 28 January 13
Middleware Architecture



                       Application

                       Thing level   One middleware
                                     for Android 4.0
                        Tag level        or higher

                        Android



Monday 28 January 13
Detecting RFID Tags

                       new MyTagDiscoverer(this,
                          THING_TYPE,
                          new NdefMessageToStringConverter(),
                          new StringToNdefMessageConverter());




                       private class MyTagDiscoverer extends TagDiscoverer {		
                       	 @Override
                       	 public void onTagDetected(TagReference tagReference) {
                       	 	 readTagAndUpdateUI(tagReference);
                       	 }
                       	 	
                       	 @Override
                       	 public void onTagRedetected(TagReference tagReference) {
                       	 	 readTagAndUpdateUI(tagReference);
                       	 }
                       }



Monday 28 January 13
The Tag Reference Abstraction




Monday 28 January 13
Reading RFID Tags


               tagReference.read(
                     new TagReadListener() {
                          @Override
               	         public void signal(TagReference tagReference) {
               	             // tagReference.getCachedData()
               	 	      }
               	    },
               	    new TagReadFailedListener() {
               	         @Override
               	         public void signal(TagReference tagReference) {
               	             // Deal with failure
               	         }
               	   });




Monday 28 January 13
Writing RFID Tags

               tagReference.write(
                     toWrite,
                     new TagWrittenListener() {
               	         @Override
               	         public void signal(TagReference tagReference) {
               	             // Handle write success
               	 	      }
               	    },
               	    new TagWriteFailedListener() {
               	         @Override
               	 	      public void signal(TagReference tagReference) {
               	 	          // Deal with failure
               	 	      }
               	   });




Monday 28 January 13
Fine-grained Filtering

              private class MyTagDiscoverer extends TagDiscoverer {	 	
              	 @Override
              	 public void onTagDetected(TagReference tagReference) {
              	 	 readTagAndUpdateUI(tagReference);
              	 }
              	 	
              	 @Override
              	 public void onTagRedetected(TagReference tagReference) {
              	 	 readTagAndUpdateUI(tagReference);
              	 }

                   @Override
              	    public boolean checkCondition(TagReference tagReference) {
                       // Can be used to apply a predicate
                       // on tagReference.getCachedData()
              	    }
              }



Monday 28 January 13
Conclusion

       Event-driven discovery.


       Non-blocking communication:


             Things: cached copy, asynchronous saving of cached data.


             TagReferences: 鍖rst class references to RFID tags o鍖ering asynchronous
              reads and writes.


       Automatic data conversion


       Looser coupling from activity-based architecture


       Data structures over several tags, stronger consistency guarantees?

Monday 28 January 13
MORENA: A Middleware for Programming
      NFC-enabled Android Applications as
      Distributed Object-Oriented Programs
      Andoni Lombide Carreton
      Kevin Pinte
      Wolfgang De Meuter




       ACM/IFIP/USENIX 13th International Conference on Middleware 2012
       December 5 2012
       Montreal, Canada

Monday 28 January 13
Ad

Recommended

Concurrecy techdrop
Concurrecy techdrop
Michael Barker
Creating Ext GWT Extensions and Components
Creating Ext GWT Extensions and Components
Sencha
What's New in GWT 2.2
What's New in GWT 2.2
David Chandler
Threads
Threads
Then Murugeshwari
Java 5 concurrency
Java 5 concurrency
priyank09
OSGi Puzzlers
OSGi Puzzlers
bjhargrave
Android Bluetooth Hacking Java Day2010 Eng
Android Bluetooth Hacking Java Day2010 Eng
Emanuele Di Saverio
Java concurrency begining
Java concurrency begining
maksym220889
Visual Dataflow Coordination2010
Visual Dataflow Coordination2010
alombide
Distributed Reactive Programming Tools2010
Distributed Reactive Programming Tools2010
alombide
AmbientTalk Rfid Dais2010
AmbientTalk Rfid Dais2010
alombide
Private phd defense_40-45min
Private phd defense_40-45min
alombide
An introduction to M2M / IoT technologies
An introduction to M2M / IoT technologies
Pascal Bodin
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
Luminary Labs
Pinte
Pinte
Droidcon Berlin
4th semester project report
4th semester project report
Akash Rajguru
Android Things - The IoT platform from Google
Android Things - The IoT platform from Google
Emmanuel Obot
Managing Massive data of the IoT through cooperative semantic nodes
Managing Massive data of the IoT through cooperative semantic nodes
Benoit Christophe
Android Things
Android Things
Egor Andreevich
Temporary selection of server in conventional client server
Temporary selection of server in conventional client server
Rohan Khude
02 dev room6__tapand_go_jeffprosise_9Tap and Go: Proximity Networking in WinRT
02 dev room6__tapand_go_jeffprosise_9Tap and Go: Proximity Networking in WinRT
Microsoft Developer Network (MSDN) - Belgium and Luxembourg
Zero to one with Android Things - Hieu Hua
Zero to one with Android Things - Hieu Hua
Tu Le Dinh
Wireless sensor networks using android virtual devices and near field
Wireless sensor networks using android virtual devices and near field
Nicolas Kockel
CAT III Answer Key.pdf
CAT III Answer Key.pdf
Selvaraj Seerangan
LUMIA APP LABS: DEVELOPING NFC APPS IN WINDOWS PHONE 8
LUMIA APP LABS: DEVELOPING NFC APPS IN WINDOWS PHONE 8
Microsoft Mobile Developer
Air superiority for Android Apps
Air superiority for Android Apps
Sa炭l D鱈az Gonz叩lez
Connecting your phone and home with firebase and android things - James Cogga...
Connecting your phone and home with firebase and android things - James Cogga...
DroidConTLV
How to Program SmartThings
How to Program SmartThings
Janet Huang
Android chat app1
Android chat app1
kailas_wagh
NFC on Android - Near Field Communication
NFC on Android - Near Field Communication
Sven Haiges

More Related Content

Viewers also liked (6)

Visual Dataflow Coordination2010
Visual Dataflow Coordination2010
alombide
Distributed Reactive Programming Tools2010
Distributed Reactive Programming Tools2010
alombide
AmbientTalk Rfid Dais2010
AmbientTalk Rfid Dais2010
alombide
Private phd defense_40-45min
Private phd defense_40-45min
alombide
An introduction to M2M / IoT technologies
An introduction to M2M / IoT technologies
Pascal Bodin
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
Luminary Labs
Visual Dataflow Coordination2010
Visual Dataflow Coordination2010
alombide
Distributed Reactive Programming Tools2010
Distributed Reactive Programming Tools2010
alombide
AmbientTalk Rfid Dais2010
AmbientTalk Rfid Dais2010
alombide
Private phd defense_40-45min
Private phd defense_40-45min
alombide
An introduction to M2M / IoT technologies
An introduction to M2M / IoT technologies
Pascal Bodin
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
Luminary Labs

Similar to Morena middleware2012 (20)

Pinte
Pinte
Droidcon Berlin
4th semester project report
4th semester project report
Akash Rajguru
Android Things - The IoT platform from Google
Android Things - The IoT platform from Google
Emmanuel Obot
Managing Massive data of the IoT through cooperative semantic nodes
Managing Massive data of the IoT through cooperative semantic nodes
Benoit Christophe
Android Things
Android Things
Egor Andreevich
Temporary selection of server in conventional client server
Temporary selection of server in conventional client server
Rohan Khude
02 dev room6__tapand_go_jeffprosise_9Tap and Go: Proximity Networking in WinRT
02 dev room6__tapand_go_jeffprosise_9Tap and Go: Proximity Networking in WinRT
Microsoft Developer Network (MSDN) - Belgium and Luxembourg
Zero to one with Android Things - Hieu Hua
Zero to one with Android Things - Hieu Hua
Tu Le Dinh
Wireless sensor networks using android virtual devices and near field
Wireless sensor networks using android virtual devices and near field
Nicolas Kockel
CAT III Answer Key.pdf
CAT III Answer Key.pdf
Selvaraj Seerangan
LUMIA APP LABS: DEVELOPING NFC APPS IN WINDOWS PHONE 8
LUMIA APP LABS: DEVELOPING NFC APPS IN WINDOWS PHONE 8
Microsoft Mobile Developer
Air superiority for Android Apps
Air superiority for Android Apps
Sa炭l D鱈az Gonz叩lez
Connecting your phone and home with firebase and android things - James Cogga...
Connecting your phone and home with firebase and android things - James Cogga...
DroidConTLV
How to Program SmartThings
How to Program SmartThings
Janet Huang
Android chat app1
Android chat app1
kailas_wagh
NFC on Android - Near Field Communication
NFC on Android - Near Field Communication
Sven Haiges
SOFIA - Smart M3 Information Sharing Platform - NOKIA
SOFIA - Smart M3 Information Sharing Platform - NOKIA
Sofia Eu
Minor Project Progress Presentation
Minor Project Progress Presentation
Adil Ahmad
Windows Phone 8 NFC Quickstart
Windows Phone 8 NFC Quickstart
Andreas Jakl
UXperts 2012: Connectivity Beyond the Web (Android), Friedger M端ffke
UXperts 2012: Connectivity Beyond the Web (Android), Friedger M端ffke
Friedger M端ffke
4th semester project report
4th semester project report
Akash Rajguru
Android Things - The IoT platform from Google
Android Things - The IoT platform from Google
Emmanuel Obot
Managing Massive data of the IoT through cooperative semantic nodes
Managing Massive data of the IoT through cooperative semantic nodes
Benoit Christophe
Temporary selection of server in conventional client server
Temporary selection of server in conventional client server
Rohan Khude
Zero to one with Android Things - Hieu Hua
Zero to one with Android Things - Hieu Hua
Tu Le Dinh
Wireless sensor networks using android virtual devices and near field
Wireless sensor networks using android virtual devices and near field
Nicolas Kockel
LUMIA APP LABS: DEVELOPING NFC APPS IN WINDOWS PHONE 8
LUMIA APP LABS: DEVELOPING NFC APPS IN WINDOWS PHONE 8
Microsoft Mobile Developer
Connecting your phone and home with firebase and android things - James Cogga...
Connecting your phone and home with firebase and android things - James Cogga...
DroidConTLV
How to Program SmartThings
How to Program SmartThings
Janet Huang
Android chat app1
Android chat app1
kailas_wagh
NFC on Android - Near Field Communication
NFC on Android - Near Field Communication
Sven Haiges
SOFIA - Smart M3 Information Sharing Platform - NOKIA
SOFIA - Smart M3 Information Sharing Platform - NOKIA
Sofia Eu
Minor Project Progress Presentation
Minor Project Progress Presentation
Adil Ahmad
Windows Phone 8 NFC Quickstart
Windows Phone 8 NFC Quickstart
Andreas Jakl
UXperts 2012: Connectivity Beyond the Web (Android), Friedger M端ffke
UXperts 2012: Connectivity Beyond the Web (Android), Friedger M端ffke
Friedger M端ffke
Ad

Morena middleware2012

  • 1. MORENA: A Middleware for Programming NFC-enabled Android Applications as Distributed Object-Oriented Programs Andoni Lombide Carreton Kevin Pinte Wolfgang De Meuter ACM/IFIP/USENIX 13th International Conference on Middleware 2012 December 5 2012 Montreal, Canada Monday 28 January 13
  • 2. RFID in Android NFC (touch range). NdefMessage: { Callback on activities , to detect RFID tags with subscribed MIME- , NdefRecord type in memory. byte array } File access abstraction read write Monday 28 January 13
  • 3. Drawbacks of the Android NFC API Manual failure handling (and NFC causes A LOT of failures because of its hardware characteristics). Blocking communication (Android documentation recommends to use a separate thread for many RFID operations). Manual data conversion Tight coupling with activity-based architecture Monday 28 January 13
  • 4. Lessons Learnt from Previous Ambient-Oriented Programming Research Using objects as 鍖rst class software representations for RFID-tagged things is a nice abstraction. These objects can be directly stored in the RFID tags memory to minimize data conversion. Event-driven discovery (fortunately built-in into Android). Asynchronous reads and writes. Monday 28 January 13
  • 5. Middleware Architecture Application Thing level One middleware for Android 4.0 Tag level or higher Android Monday 28 January 13
  • 6. Evaluation: WiFi Sharing Application Monday 28 January 13
  • 7. Evaluation: WiFi Sharing Application Monday 28 January 13
  • 8. Things From now on, we dont public class WifiConfig extends Thing { have to worry about the public String ssid_; activity anymore. public String key_; public WifiConfig(ThingActivity<WifiConfig> activity, String ssid, String key) { super(activity); ssid_ = ssid; key_ = key; } public boolean connect(WifiManager wm) { // Connect to ssid_ with password key_ }; Supported serialization: } - JSON-serializable 鍖elds. - Skipping transient 鍖elds. - Deep serialization, no cycles. Monday 28 January 13
  • 9. Initializing Things As soon as an empty tag is detected @Override public void whenDiscovered(EmptyRecord empty) { empty.initialize( myWifiThing, new ThingSavedListener<WifiConfig>() { @Override public void signal(WifiConfig thing) { toast("WiFi joiner created!"); } }, new ThingSaveFailedListener() { @Override public void signal() { toast("Creating WiFi joiner failed, try again."); } }); } Monday 28 January 13
  • 10. Discovering and Reading Things As soon as a Wi鍖Con鍖g tag is detected @Override public void whenDiscovered(WifiConfig wc) { toast("Joining Wifi network " + wc.ssid_); wc.connect(); } Contains cached 鍖elds for synchronous access. Physical reads must be asynchronous. Monday 28 January 13
  • 11. Saving Modi鍖ed Things myWifiConfig.ssid_ = "MyNewWifiName"; myWifiConfig.key_ = "MyNewWifiPassword"; myWifiConfig.saveAsync( new ThingSavedListener<WifiConfig>() { @Override public void signal(WifiConfig wc) { toast("WiFi joiner saved!"); } }, new ThingSaveFailedListener() { @Override public void signal() { toast("Saving WiFi joiner failed, try again."); } }); Monday 28 January 13
  • 12. Broadcasting Things to Other Phones Will trigger whenDiscovered on the receiving phone with the broadcasted thing myWifiConfig.broadcast( new ThingBroadcastSuccessListener<WifiConfig>() { @Override public void signal(WifiConfig wc) { toast("WiFi joiner shared!"); } }, new ThingBroadcastFailedListener<WifiConfig>() { @Override public void signal(WifiConfig wc) { toast("Failed to share WiFi joiner, try again."); } }); Monday 28 January 13
  • 13. Evaluation: WiFi Sharing Application Monday 28 January 13
  • 14. Middleware Architecture Application Thing level One middleware for Android 4.0 Tag level or higher Android Monday 28 January 13
  • 15. Detecting RFID Tags new MyTagDiscoverer(this, THING_TYPE, new NdefMessageToStringConverter(), new StringToNdefMessageConverter()); private class MyTagDiscoverer extends TagDiscoverer { @Override public void onTagDetected(TagReference tagReference) { readTagAndUpdateUI(tagReference); } @Override public void onTagRedetected(TagReference tagReference) { readTagAndUpdateUI(tagReference); } } Monday 28 January 13
  • 16. The Tag Reference Abstraction Monday 28 January 13
  • 17. Reading RFID Tags tagReference.read( new TagReadListener() { @Override public void signal(TagReference tagReference) { // tagReference.getCachedData() } }, new TagReadFailedListener() { @Override public void signal(TagReference tagReference) { // Deal with failure } }); Monday 28 January 13
  • 18. Writing RFID Tags tagReference.write( toWrite, new TagWrittenListener() { @Override public void signal(TagReference tagReference) { // Handle write success } }, new TagWriteFailedListener() { @Override public void signal(TagReference tagReference) { // Deal with failure } }); Monday 28 January 13
  • 19. Fine-grained Filtering private class MyTagDiscoverer extends TagDiscoverer { @Override public void onTagDetected(TagReference tagReference) { readTagAndUpdateUI(tagReference); } @Override public void onTagRedetected(TagReference tagReference) { readTagAndUpdateUI(tagReference); } @Override public boolean checkCondition(TagReference tagReference) { // Can be used to apply a predicate // on tagReference.getCachedData() } } Monday 28 January 13
  • 20. Conclusion Event-driven discovery. Non-blocking communication: Things: cached copy, asynchronous saving of cached data. TagReferences: 鍖rst class references to RFID tags o鍖ering asynchronous reads and writes. Automatic data conversion Looser coupling from activity-based architecture Data structures over several tags, stronger consistency guarantees? Monday 28 January 13
  • 21. MORENA: A Middleware for Programming NFC-enabled Android Applications as Distributed Object-Oriented Programs Andoni Lombide Carreton Kevin Pinte Wolfgang De Meuter ACM/IFIP/USENIX 13th International Conference on Middleware 2012 December 5 2012 Montreal, Canada Monday 28 January 13