= Mobility First M2M demo = [[PageOutline(2-100,Contents, inline, unnumbered)]] == 0.Requirements == * Mobility Firts M2M demo with reference implementation of dynamic GNRS resulotion, MF Click Router, MF androidstack * Rooted Android Devices running MobilityFirst stack == 1.System architecture == Figure below describes the data path from Sensors to Android Receivers. Sensor data go through the mobile gateway by Java MF API, which runs the Mobility First Android Stack. RT1 performs as a MF Multicast Router. When the data tries to reach next hop by GUID,GNRS server looks up the entry. The Android reciever(s) runs as a Java MF Server, listening the data from RT2/RT3. {{{ ____RT2____ ________________ | | | | ---> | MF Router | ---->| Android Device | / |___________| |________________| / | Reciever / | S1 _______________ ___________ / ______|______ . \ | | | | / | | . ----------> |Android Device |--->| MF Router |-> --------| GNRS Server | . / |_______________| |___________| \ |_____________| Sn SensorGateway RT1 \ | \ | \ | \ _____|_____ ________________ \ | | | | --->| MF Router | ---->| Android Device | |___________| |________________| RT3 Reciever }}} === 1.1 Implementation of Application === The figure below shows the structure of MF Sensor Gateway application. {{{ _________________________ | APP | | ________ __________ | || | | || || Sender | | Reciever || ||________| |__________|| |_________________________| }}} {{{ Sender | ______________ _________________ _____________ | __________ | | | | | | | | | | USB Reciever |--->| Android USB API |--->| Java MF API |--->| MF Stack | |______________| |_________________| |_____________| | |__________| | | | | ____v______ | | | UI Thread | |___________| | Receiver __________ | ________________ ___________ | | | | | | | | MF Stack |--->| Recieve Thread |--->| ArrayList | |__________| | |________________| |___________| | | ^ | | | _____ v |_________ _______________ ___________ | | | | | | | UI Update Thread |--->| UI Controller |--->| UI Thread | |__________________| |_______________| |___________| }}} MF SensorGateway could be devided into two module:Sender and Receiver.The sender is triggered by the USB receiver, which is a system callback method, runs in constant period. Receiver needs to run a separate thread to listen to the MF stack. An individual UI Update thread looks up the Arraylist to fetch the lastest sensor data,then deliver to the corresponding UI page. === 1.2 Extension === In the future, the GUID subscribe module will be implement.More function or application can be added based on the current framework. == 2.Installation == === 2.1 Components === Hardware * Wireless Sensor * USB Sensor Receiver * Android Phone/Tablet * Orbit Nodes * M2M Extrenal Server Software * MF Stack Launcher * MF Sensor Gateway * M2M Management Website * GNRS Server * MF Router === 2.2 Android Client === Hardware Requirement * Three rooted Android phone/tablet with USB host mode supported * Android 4.0 or above Mobility First Stack installation * You can follow the instructions [https://mobilityfirst.orbit-lab.org/browser/trunk/code/prototype/client/c_android/README here] to get all your libraries : * Place all your libary and document at the right places, then execute the following command to gain the MF launcher app source code {{{ svn checkout https://svn.orbit-lab.org/mobilityfirst/trunk/code/prototype/client/launcher }}} * Configure the interfaces.xml.Set ip and MAC as the ip and MAC of your android terminal, and the apip and apmac as the acess point that you use(it will be introduced later).Put it into ~/data/mfdemo * Configure the policy.xml properly and put it into ~/data/mfdemo * Do not forget to use chmod 744 to change all you libs' and documents' property * Create a folder named mf in ~/sdcard/ {{{ mkdir ~/sdcard/mf }}} Mobility First SensorGateway Usage * You can check out the code by executing following command : {{{ svn checkout https://svn.orbit-lab.org/mobilityfirst/trunk/code/prototype/client/demoapp/SensorGW SensorGW }}} * Include the lastest jmfapi.jar into your project.(To see how to obtain the latest version, check [https://mobilityfirst.orbit-lab.org/browser/trunk/code/prototype/client/api here]) * Set all the src guid and scheme(dst guid) propertly * Install the app onto your phone/tablet === 2.3 Orbit Node === Determine the demo location, then choose the nearest nodes. Load the image to the outdoor box To turn off the node first {{{ omf tell -a offh -t node1-8.outdoor.orbit-lab.org }}} To load the image {{{ omf load -i sugang_mfrouter.ndz -t node1-8.outdoor.orbit-lab.org }}} To turn on the node {{{ omf tell -a on -t node1-8.outdoor.orbit-lab.org ssh root@node1-8 }}} Access Point and MF_router Setup You need to set the orbit nodes as your access point, so that your android devices can connect to it. Meanwhile, nodes choosen to be AP will run as MF router. To set up the node to be an access point: * Set up correctly the DHCP server by correctly setting up the file /etc/dnsmasq.conf * Set up correctly the software AP by correctly setting up the file ~/conf/ap.conf To set up the interfaces: * Take a look at the script ~/script/init_resources.sh to see how to do it To running the MF click router, follow the instruction [https://mobilityfirst.orbit-lab.org/wiki/SystemPrototyping/Projects/ClickRouter here] Before you start the router, do not forget to configure the topology file in ~/conf. Include all nodes and devices of your demo. To start all the service in one time, execute the script start_router.sh in ~/scripts by giving the right argument To see the log of MF router, go to ~/var/log/mf-click.log Setup the GNRS server You can always a GNRS server on any node or your own machine, as long as the JRE or JDK is installed. But remember to set the gnrs_ip and gnrs_port in your MF router correctly. If your want to know more about how to build GNRS server, please visit its [https://bitbucket.org/romoore/gnrs/wiki/Home public site]. == 3.System Debug == Since there are so many components involved in this demo, it will be difficult to debug the whole system after all the things are ready. Here is the order that I bring them up(It is not neccesary the unique one, but works fo me): - gnrs server - MF router - MF android stack - MF SensorGateway app(must run after the android stack) === 3.1 Debug the Android Client === Because the use port is occupied by USB receiver, you may need to use the adb-over-wifi mode to debug your devices. Here is some instruction you might want to know: - Install the ADB over Wifi via Google Play(I assume you have a rooted device) - Enable adb over wifi in the app - Open cmd.exe, type {{{ adb connect }}} (you may need to set eviroment variable to adb.exe) - If you need to debug two Android devices at the same time, then open two cmd windows, type {{{ adb -s :5555 shell }}} - When you are in the shell, type {{{ su }}} to obtain the superuser permission - Find the log in ~/data/mfdemo/mflog Test on single node * Instead of connected to MF router, try to use WINMAIN first.Connect two devices to WINMAIN, then configure interfaces.xml(apip and apmac should be set to correspond to the other device). * Bring up the stack on both side, look into the ~/data/mfdemo/mflog to check whether they can receive associate message.If yes, it means your MF stack installation is successful. * Bring up your sender and receiver, check whether the logcat of receiver shows the recieved data. If no, look into the stack log.If everyting works fine so far, you can move on to next step(do not forget to connect your devices to corresponding MF router,and change the parameter in interfaces.xml). === 3.2 Debug the Orbit Node === All orbit nodes connect to each other by eth0, thus check by using ifconfig then set the interface parameter properly. * Bring up the GNRS server, track the log file. * Bring up the mf router, track the log. * Bring up the MF Android stack.If the log in router shows all the entries in a table, you have done all the orbit debuging works!If no, track the log file of GNRS to see if it perform insert and lookup. == 4.Performance == == 5.Known Issues == == 6.Release Notes ==