SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Downloaden Sie, um offline zu lesen
In Touch with Things:
Programming NFC on Android with MORENA
Kevin Pinte
Andoni Lombide Carreton
Wolfgang De Meuter




Droidcon
April 10, 2013
Berlin, Germany
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
Drawbacks of the Android NFC API

• Manual failure handling
  failures are the rule rather than the exception:
  NFC causes A LOT of failures because of its hardware characteristics


• Blocking communication
  Android documentation recommends to use a separate thread
  for many NFC operations


• Manual data conversion


• Tight coupling with activity-based architecture
Lessons Learnt from Previous Ambient-Oriented
Programming Research

• Using objects as first 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, fault tolerant reads and writes.
                                                         experimental scripting
                                                       language for mobile apps
                                                          in ad hoc networks
       RFID tags as “mobile
        devices” and I/O as
      network communication
MORENA Middleware Architecture



           Application

           Thing level       One middleware
                             for Android 4.0
                             or higher (API 14)
            Tag level

            Android
Evaluation: Wi-Fi Sharing Application
Evaluation: Wi-Fi Sharing Application
Things

                                                      From now on, we don’t
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 fields.
                                                 - Skipping transient fields.
                                                 - Deep serialization, no cycles.
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.");
   	 	 	       }
   	 	     },
           5000);
   }
Discovering and Reading Things


                       As soon as a WifiConfig
                           tag is detected
     @Override
     public void whenDiscovered(WifiConfig wc) {
        toast("Joining Wifi network " + wc.ssid_);
     	 wc.connect();
     }
                              Contains cached fields for
                                synchronous access.
                               Physical reads must be
                                   asynchronous.
Saving Modified 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.");
 	 	 	 }
     },
     5000);
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.");
 	 	 	    }
       },
       5000);
Evaluation: WiFi Sharing Application
MORENA Middleware Architecture



           Application

           Thing level       One middleware
                             for Android 4.0
            Tag level        or higher (API 14)

            Android
Detecting RFID Tags

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



    new TextTagDiscoverer(
       currentActivity,
       TEXT_TYPE,
       new NdefMessageToStringConverter(),
       new StringToNdefMessageConverter());
The Tag Reference Abstraction
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
  	         }
  	   });
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
  	 	      }
  	   });
Fine-grained Filtering

  private class TextTagDiscoverer 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()
  	   }
  }
MORENA Conclusion

• Event-driven discovery.


• Non-blocking communication:


  • Things: cached copy, asynchronous saving of cached data.


  • TagReferences: first class references to RFID tags offering asynchronous
    reads and writes.


• Automatic data conversion


• Looser coupling from activity-based architecture
Current Research: Volatile Database

• Data structures over many tags?


• Querying collections of things?


• Stronger consistency guarantees?


• Transactions?


• Validations?


• ...                                Active Record (RoR)
                                           for RFID
Thing Associations
  defmodel: Shelf properties: {
  	 number: Number
  } associations: {
  	 hasMany: `books               a shelf contains many books
  };



  defmodel: Book properties: {
  	 title: Text;
  	 authors: Text;
  	 isbn: Text;
  } proto: {
  	 def isMisplaced(currentShelf) {
  	 	 shelf != currentShelf;
  	 };
  } associations: {
     belongsTo: `shelf         a book belongs to exactly
  };                             one shelf in the library
Instantiating a Model and Saving to Tag
  def newBook := Book.create: {
     title   := “Agile Web Development with Rails”;
     authors := “Dave Thomas, ...”;
     isbn    := “978-0-9776-1663-3”;
  };
  def saveReq := newBook.saveAsync(10.seconds);
  when: saveReq succeeded: {
     // the book was saved to a tag
  } catch: { |exc|
     // book could not be saved within 10 sec
  };

  newBook.shelf := shelf42;

                                    associate a book with a shelf:
  shelf42.books << newBook;
                                      foreign key in book thing
Working with Many Things: Reactive Queries

                 finding misplaced books in a library


  def shelf42 := Shelf.all.first: { |s| s.number == 42 };
  def currentShelf := Shelf.all.last;

                                          most recently scanned shelf

  def misplacedBooks := Book.all.where: { |b|
     b.isMisplaced(currentShelf)
  };                                     all books  not matching the
                                              last scanned shelf
  misplacedBooks.each: { |b|
     b.shelf := currentShelf;
     b.saveAsync(5.seconds)
  };
                                  synchronize misplaced books
                                        with current shelf
In Touch with Things:
Programming NFC on Android with MORENA

            tinyurl.com/morena-android


            tinyurl.com/kevinpinte
            kevin.pinte@vub.ac.be
            @bommasaurus



            code.google.com/p/ambienttalk
            soft.vub.ac.be/amop

            @ambienttalk


             Droidcon, April 10, 2013, Berlin, Germany

Weitere ähnliche Inhalte

Ähnlich wie Pinte

Morena middleware2012
Morena middleware2012Morena middleware2012
Morena middleware2012alombide
 
Private phd defense_40-45min
Private phd defense_40-45minPrivate phd defense_40-45min
Private phd defense_40-45minalombide
 
Flare - tech-intro-for-paris-hackathon
Flare - tech-intro-for-paris-hackathonFlare - tech-intro-for-paris-hackathon
Flare - tech-intro-for-paris-hackathonCisco DevNet
 
Microservices Application Tracing Standards and Simulators - Adrians at OSCON
Microservices Application Tracing Standards and Simulators - Adrians at OSCONMicroservices Application Tracing Standards and Simulators - Adrians at OSCON
Microservices Application Tracing Standards and Simulators - Adrians at OSCONAdrian Cockcroft
 
hibernate-presentation-1196607644547952-4.pdf
hibernate-presentation-1196607644547952-4.pdfhibernate-presentation-1196607644547952-4.pdf
hibernate-presentation-1196607644547952-4.pdfMytrux1
 
Spring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud FoundrySpring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud FoundryJoshua Long
 
Palm Developer Day PhoneGap
Palm Developer Day PhoneGap Palm Developer Day PhoneGap
Palm Developer Day PhoneGap Brian LeRoux
 
Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)ejlp12
 
Cross-Platform Data Access for Android and iPhone
Cross-Platform Data Access for Android and iPhoneCross-Platform Data Access for Android and iPhone
Cross-Platform Data Access for Android and iPhonePeter Friese
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentationguest11106b
 
Automated Discovery of Deserialization Gadget Chains
 Automated Discovery of Deserialization Gadget Chains Automated Discovery of Deserialization Gadget Chains
Automated Discovery of Deserialization Gadget ChainsPriyanka Aash
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentationLuis Goldster
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backendDavid Padbury
 
Building A Sensor Network Controller
Building A Sensor Network ControllerBuilding A Sensor Network Controller
Building A Sensor Network Controllermichaelpigg
 
From the internet of things to the web of things course
From the internet of things to the web of things courseFrom the internet of things to the web of things course
From the internet of things to the web of things courseDominique Guinard
 
4th semester project report
4th semester project report4th semester project report
4th semester project reportAkash Rajguru
 
Is OSGi modularity always worth it?
Is OSGi modularity always worth it?Is OSGi modularity always worth it?
Is OSGi modularity always worth it?glynnormington
 
Vonk fhir facade (christiaan)
Vonk fhir facade (christiaan)Vonk fhir facade (christiaan)
Vonk fhir facade (christiaan)DevDays
 

Ähnlich wie Pinte (20)

Morena middleware2012
Morena middleware2012Morena middleware2012
Morena middleware2012
 
Nfc on Android
Nfc on AndroidNfc on Android
Nfc on Android
 
Private phd defense_40-45min
Private phd defense_40-45minPrivate phd defense_40-45min
Private phd defense_40-45min
 
Flare - tech-intro-for-paris-hackathon
Flare - tech-intro-for-paris-hackathonFlare - tech-intro-for-paris-hackathon
Flare - tech-intro-for-paris-hackathon
 
Microservices Application Tracing Standards and Simulators - Adrians at OSCON
Microservices Application Tracing Standards and Simulators - Adrians at OSCONMicroservices Application Tracing Standards and Simulators - Adrians at OSCON
Microservices Application Tracing Standards and Simulators - Adrians at OSCON
 
hibernate-presentation-1196607644547952-4.pdf
hibernate-presentation-1196607644547952-4.pdfhibernate-presentation-1196607644547952-4.pdf
hibernate-presentation-1196607644547952-4.pdf
 
Spring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud FoundrySpring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud Foundry
 
Getting Native with NDK
Getting Native with NDKGetting Native with NDK
Getting Native with NDK
 
Palm Developer Day PhoneGap
Palm Developer Day PhoneGap Palm Developer Day PhoneGap
Palm Developer Day PhoneGap
 
Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)
 
Cross-Platform Data Access for Android and iPhone
Cross-Platform Data Access for Android and iPhoneCross-Platform Data Access for Android and iPhone
Cross-Platform Data Access for Android and iPhone
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
 
Automated Discovery of Deserialization Gadget Chains
 Automated Discovery of Deserialization Gadget Chains Automated Discovery of Deserialization Gadget Chains
Automated Discovery of Deserialization Gadget Chains
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentation
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
Building A Sensor Network Controller
Building A Sensor Network ControllerBuilding A Sensor Network Controller
Building A Sensor Network Controller
 
From the internet of things to the web of things course
From the internet of things to the web of things courseFrom the internet of things to the web of things course
From the internet of things to the web of things course
 
4th semester project report
4th semester project report4th semester project report
4th semester project report
 
Is OSGi modularity always worth it?
Is OSGi modularity always worth it?Is OSGi modularity always worth it?
Is OSGi modularity always worth it?
 
Vonk fhir facade (christiaan)
Vonk fhir facade (christiaan)Vonk fhir facade (christiaan)
Vonk fhir facade (christiaan)
 

Mehr von Droidcon Berlin

Droidcon de 2014 google cast
Droidcon de 2014   google castDroidcon de 2014   google cast
Droidcon de 2014 google castDroidcon Berlin
 
Android programming -_pushing_the_limits
Android programming -_pushing_the_limitsAndroid programming -_pushing_the_limits
Android programming -_pushing_the_limitsDroidcon Berlin
 
Android industrial mobility
Android industrial mobility Android industrial mobility
Android industrial mobility Droidcon Berlin
 
From sensor data_to_android_and_back
From sensor data_to_android_and_backFrom sensor data_to_android_and_back
From sensor data_to_android_and_backDroidcon Berlin
 
new_age_graphics_android_x86
new_age_graphics_android_x86new_age_graphics_android_x86
new_age_graphics_android_x86Droidcon Berlin
 
Testing and Building Android
Testing and Building AndroidTesting and Building Android
Testing and Building AndroidDroidcon Berlin
 
Matchinguu droidcon presentation
Matchinguu droidcon presentationMatchinguu droidcon presentation
Matchinguu droidcon presentationDroidcon Berlin
 
Cgm life sdk_droidcon_2014_v3
Cgm life sdk_droidcon_2014_v3Cgm life sdk_droidcon_2014_v3
Cgm life sdk_droidcon_2014_v3Droidcon Berlin
 
The artofcalabash peterkrauss
The artofcalabash peterkraussThe artofcalabash peterkrauss
The artofcalabash peterkraussDroidcon Berlin
 
Raesch, gries droidcon 2014
Raesch, gries   droidcon 2014Raesch, gries   droidcon 2014
Raesch, gries droidcon 2014Droidcon Berlin
 
Android open gl2_droidcon_2014
Android open gl2_droidcon_2014Android open gl2_droidcon_2014
Android open gl2_droidcon_2014Droidcon Berlin
 
20140508 quantified self droidcon
20140508 quantified self droidcon20140508 quantified self droidcon
20140508 quantified self droidconDroidcon Berlin
 
Tuning android for low ram devices
Tuning android for low ram devicesTuning android for low ram devices
Tuning android for low ram devicesDroidcon Berlin
 
Froyo to kit kat two years developing & maintaining deliradio
Froyo to kit kat   two years developing & maintaining deliradioFroyo to kit kat   two years developing & maintaining deliradio
Froyo to kit kat two years developing & maintaining deliradioDroidcon Berlin
 
Droidcon2013 security genes_trendmicro
Droidcon2013 security genes_trendmicroDroidcon2013 security genes_trendmicro
Droidcon2013 security genes_trendmicroDroidcon Berlin
 

Mehr von Droidcon Berlin (20)

Droidcon de 2014 google cast
Droidcon de 2014   google castDroidcon de 2014   google cast
Droidcon de 2014 google cast
 
Android programming -_pushing_the_limits
Android programming -_pushing_the_limitsAndroid programming -_pushing_the_limits
Android programming -_pushing_the_limits
 
crashing in style
crashing in stylecrashing in style
crashing in style
 
Raspberry Pi
Raspberry PiRaspberry Pi
Raspberry Pi
 
Android industrial mobility
Android industrial mobility Android industrial mobility
Android industrial mobility
 
Details matter in ux
Details matter in uxDetails matter in ux
Details matter in ux
 
From sensor data_to_android_and_back
From sensor data_to_android_and_backFrom sensor data_to_android_and_back
From sensor data_to_android_and_back
 
droidparts
droidpartsdroidparts
droidparts
 
new_age_graphics_android_x86
new_age_graphics_android_x86new_age_graphics_android_x86
new_age_graphics_android_x86
 
5 tips of monetization
5 tips of monetization5 tips of monetization
5 tips of monetization
 
Testing and Building Android
Testing and Building AndroidTesting and Building Android
Testing and Building Android
 
Matchinguu droidcon presentation
Matchinguu droidcon presentationMatchinguu droidcon presentation
Matchinguu droidcon presentation
 
Cgm life sdk_droidcon_2014_v3
Cgm life sdk_droidcon_2014_v3Cgm life sdk_droidcon_2014_v3
Cgm life sdk_droidcon_2014_v3
 
The artofcalabash peterkrauss
The artofcalabash peterkraussThe artofcalabash peterkrauss
The artofcalabash peterkrauss
 
Raesch, gries droidcon 2014
Raesch, gries   droidcon 2014Raesch, gries   droidcon 2014
Raesch, gries droidcon 2014
 
Android open gl2_droidcon_2014
Android open gl2_droidcon_2014Android open gl2_droidcon_2014
Android open gl2_droidcon_2014
 
20140508 quantified self droidcon
20140508 quantified self droidcon20140508 quantified self droidcon
20140508 quantified self droidcon
 
Tuning android for low ram devices
Tuning android for low ram devicesTuning android for low ram devices
Tuning android for low ram devices
 
Froyo to kit kat two years developing & maintaining deliradio
Froyo to kit kat   two years developing & maintaining deliradioFroyo to kit kat   two years developing & maintaining deliradio
Froyo to kit kat two years developing & maintaining deliradio
 
Droidcon2013 security genes_trendmicro
Droidcon2013 security genes_trendmicroDroidcon2013 security genes_trendmicro
Droidcon2013 security genes_trendmicro
 

Kürzlich hochgeladen

Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Delhi Call girls
 
KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...
KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...
KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...Any kyc Account
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...lizamodels9
 
How to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityHow to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityEric T. Tung
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...Paul Menig
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfAdmir Softic
 
Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Roland Driesen
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMANIlamathiKannappan
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756dollysharma2066
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...amitlee9823
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxAndy Lambert
 
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...rajveerescorts2022
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesDipal Arora
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMRavindra Nath Shukla
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLSeo
 
0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdf0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdfRenandantas16
 
Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with CultureSeta Wicaksana
 

Kürzlich hochgeladen (20)

Mifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pills
Mifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pillsMifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pills
Mifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pills
 
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
 
KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...
KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...
KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
 
How to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityHow to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League City
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
 
Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMAN
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptx
 
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSM
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
 
0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdf0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdf
 
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
 
Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with Culture
 

Pinte

  • 1. In Touch with Things: Programming NFC on Android with MORENA Kevin Pinte Andoni Lombide Carreton Wolfgang De Meuter Droidcon April 10, 2013 Berlin, Germany
  • 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
  • 3. Drawbacks of the Android NFC API • Manual failure handling failures are the rule rather than the exception: NFC causes A LOT of failures because of its hardware characteristics • Blocking communication Android documentation recommends to use a separate thread for many NFC operations • Manual data conversion • Tight coupling with activity-based architecture
  • 4. Lessons Learnt from Previous Ambient-Oriented Programming Research • Using objects as first 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, fault tolerant reads and writes. experimental scripting language for mobile apps in ad hoc networks RFID tags as “mobile devices” and I/O as network communication
  • 5. MORENA Middleware Architecture Application Thing level One middleware for Android 4.0 or higher (API 14) Tag level Android
  • 8. Things From now on, we don’t 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 fields. - Skipping transient fields. - Deep serialization, no cycles.
  • 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."); } }, 5000); }
  • 10. Discovering and Reading Things As soon as a WifiConfig tag is detected @Override public void whenDiscovered(WifiConfig wc) { toast("Joining Wifi network " + wc.ssid_); wc.connect(); } Contains cached fields for synchronous access. Physical reads must be asynchronous.
  • 11. Saving Modified 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."); } }, 5000);
  • 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."); } }, 5000);
  • 14. MORENA Middleware Architecture Application Thing level One middleware for Android 4.0 Tag level or higher (API 14) Android
  • 15. Detecting RFID Tags private class TextTagDiscoverer extends TagDiscoverer { @Override public void onTagDetected(TagReference tagReference) { readTagAndUpdateUI(tagReference); } @Override public void onTagRedetected(TagReference tagReference) { readTagAndUpdateUI(tagReference); } } new TextTagDiscoverer( currentActivity, TEXT_TYPE, new NdefMessageToStringConverter(), new StringToNdefMessageConverter());
  • 16. The Tag Reference Abstraction
  • 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 } });
  • 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 } });
  • 19. Fine-grained Filtering private class TextTagDiscoverer 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() } }
  • 20. MORENA Conclusion • Event-driven discovery. • Non-blocking communication: • Things: cached copy, asynchronous saving of cached data. • TagReferences: first class references to RFID tags offering asynchronous reads and writes. • Automatic data conversion • Looser coupling from activity-based architecture
  • 21. Current Research: Volatile Database • Data structures over many tags? • Querying collections of things? • Stronger consistency guarantees? • Transactions? • Validations? • ... Active Record (RoR) for RFID
  • 22. Thing Associations defmodel: Shelf properties: { number: Number } associations: { hasMany: `books a shelf contains many books }; defmodel: Book properties: { title: Text; authors: Text; isbn: Text; } proto: { def isMisplaced(currentShelf) { shelf != currentShelf; }; } associations: { belongsTo: `shelf a book belongs to exactly }; one shelf in the library
  • 23. Instantiating a Model and Saving to Tag def newBook := Book.create: { title := “Agile Web Development with Rails”; authors := “Dave Thomas, ...”; isbn := “978-0-9776-1663-3”; }; def saveReq := newBook.saveAsync(10.seconds); when: saveReq succeeded: { // the book was saved to a tag } catch: { |exc| // book could not be saved within 10 sec }; newBook.shelf := shelf42; associate a book with a shelf: shelf42.books << newBook; foreign key in book thing
  • 24. Working with Many Things: Reactive Queries finding misplaced books in a library def shelf42 := Shelf.all.first: { |s| s.number == 42 }; def currentShelf := Shelf.all.last; most recently scanned shelf def misplacedBooks := Book.all.where: { |b| b.isMisplaced(currentShelf) }; all books not matching the last scanned shelf misplacedBooks.each: { |b| b.shelf := currentShelf; b.saveAsync(5.seconds) }; synchronize misplaced books with current shelf
  • 25. In Touch with Things: Programming NFC on Android with MORENA tinyurl.com/morena-android tinyurl.com/kevinpinte kevin.pinte@vub.ac.be @bommasaurus code.google.com/p/ambienttalk soft.vub.ac.be/amop @ambienttalk Droidcon, April 10, 2013, Berlin, Germany