GithubHelp home page GithubHelp logo

Comments (13)

jrobble avatar jrobble commented on July 4, 2024

Cool. We've had a mesh-enabled map app on our wishlist for a while now but no time to work in it. We're glad to hear about your project.

Thanks for the code quality comment. Our focus is on developing a mesh platform and API for developers like you to write your apps.

Initially the Manet Manager app was two separate apps, the Manet Service and the Manet Manager (a simple GUI front end to the Manet Service). The division is still clear in the package hierarchy: org.span.manager and org.span.service

The Manet Manager interacts with the Manet Service by using the ManetHelper object. Take a look at line 110 here:
https://github.com/ProjectSPAN/android-manet-manager/blob/master/AndroidManetManager/src/org/span/manager/MainActivity.java

// ...
app.manet.registerObserver(this);
// ...

In this line the MainActivity registers with the ManetHelper. The registerObserver() method takes a ManetObserver as a parameter. The MainActivity implements the ManetObserver interface so it can receive callbacks, which are listed here:
https://github.com/ProjectSPAN/android-manet-manager/blob/master/AndroidManetManager/src/org/span/service/ManetObserver.java

Specifically, you're interested in the onRoutingInfoUpdated() callback, which gets invoked when ManetHelper.sendRoutingInfoQuery() is called.

To make things short:
0. Include libmanet.jar in your app.

  1. Have your activity implement ManetObserver.
  2. Create a ManetHelper object.
  3. Register your activity with the ManetHelper.
  4. Invoke ManetHelper.connectToService().
  5. Invoke ManetHelper.sendRoutingInfoQuery().
  6. Do whatever you want with the routing info passed in as a parameter to the ManetObserver.onRoutingInfoUpdated() method implemented by your activity.

Right now the routing info is passed as a String, so it needs to be parsed. You can use ManetParser.parseOLSR() to do that for you. It will return an array of strings of the form "A>B", where A is the IP address of node A and B is the IP address of node B. "A>B" represents a directed edge. The Manet Visualizer app makes use of this edge info.

You can also look into ManetHelper.sendPeersQuery() and ManetObserver.onPeersUpdated(). The latter method will return a set of Node objects to you, where each node has an IP address, list of Edges, and other useful info. The "peers" methods are meant to replace the "routingInfo" methods.

The Manet Voice Chat app makes use of the ManetHelper to periodically get a list of peers.

I hope this helps. Let us know if you run into any problems.

from android-manet-manager.

duhmojo avatar duhmojo commented on July 4, 2024

Wow, thanks for the great write up. I'll try implementing my own ManetObserver as a way of triggering changes in my app. From what I can tell onRoutingInfoUpdated should include basically the output from txtinfo-plugin (when using Olsrd), which is great.

As for my Mapping app, I used OSMdroid (http://code.google.com/p/osmdroid/). It's tries to mimic Google's Maps API, with some differences and limitations, but it does allow for offline map loadings and caching. If you just use the API as is, anything you visit in the map will be automatically cached in a tile store on the device. But I spent some time digging and was able to load my own offline map tile sets created with MOBAC (Mobile Atlas Creator). The map atlas file needs to be loaded into your app, I ended up including it as a raw file for now. The great thing about using a Mapping API is nodes can be arranged based on their real GPS location and the easiest way to do this is with a Mapping API that already deals with map tiles and GeoPoint locations. Zooming, callbacks for single and long presses are all there. Google Maps API doesn't support offline or map tile caching. It's against their terms of service and the API actually missing functionality for caching.

I can't share this project on Github as is, but I think after I finish put together a Manet Manager Mapping app to plot other connected devices. Handling the map tiles in a user friendly way is the only challenge.

Thanks again.

from android-manet-manager.

jrobble avatar jrobble commented on July 4, 2024

Yep, onRoutingInfoUpdated() is just a text dump of the txtinfo-plugin.

We're looking forward to trying out your Manet Mapping app. Once cool thing to plot is the effective range of each device so you know when you're in range, out of range, and where to position yourself to maximize hopping distance. You can use a 200 ft radius as a good heuristic.

Good luck!

from android-manet-manager.

daviddoria avatar daviddoria commented on July 4, 2024

I have only been concerned with starting the Manet Manager, not stopping it. But to facilitate that, I added a function to ManetHelper:

public void bindToService() {
    Intent i = new Intent().setComponent(new ComponentName("org.span", "org.span.service.core.ManetService"));
    serviceConn = new ManetServiceConnection();
    context.bindService(i, serviceConn, Context.BIND_AUTO_CREATE);

    mBound = true;
}

that binds to the service without (re)starting it. This seems to behave better for me and is much faster.

from android-manet-manager.

daviddoria avatar daviddoria commented on July 4, 2024

I've also been using this: https://gist.github.com/daviddoria/e34c6ee2c4b5447a8800 as a way to force the user to wait until the ad-hoc mode is enabled before returning focus to the app.

from android-manet-manager.

jrobble avatar jrobble commented on July 4, 2024

Do you use bindToService() instead of connectToService()? Note that the startService() call is idempotent:

"If this service is not already running, it will be instantiated and started (creating a process for it if needed); if it is running then it remains running."

from android-manet-manager.

jrobble avatar jrobble commented on July 4, 2024

Thanks for sharing ManetStarter. It stresses the importance of waiting to call sendStartAdhocCommand() until the after onServiceConnected() callback has been invoked.

from android-manet-manager.

daviddoria avatar daviddoria commented on July 4, 2024

I do use bindToService() instead of connectToService(). I think I was getting an error or a delay or something. I should have taken better notes... I'll try it again at some point (but can't promise how soon...).

from android-manet-manager.

jrobble avatar jrobble commented on July 4, 2024

One important piece that seems to be lacking from bindToService() that's in connectToService() is the following:

// create receive messenger
receiveMessenger = new Messenger(new IncomingHandler());

from android-manet-manager.

daviddoria avatar daviddoria commented on July 4, 2024

Did you forget to paste something :) ?

from android-manet-manager.

jrobble avatar jrobble commented on July 4, 2024

I edited the comment with the code.

from android-manet-manager.

daviddoria avatar daviddoria commented on July 4, 2024

Ah, I forgot to mention some other things I did. I believe I left out creating a new Messenger with each call to bindToService because I was getting errors when the device orientation changed (it was trying to restart to the service each time, complaining about things being re-registered, etc.). I made ManetHelper a singleton and made my UI a fragment and made the fragment persistent. Therefore once connectToService was called once, that was enough to keep everything connected. I was pretty sure you would not want that as the standard behavior, so I did not submit a patch to that effect.

from android-manet-manager.

jrobble avatar jrobble commented on July 4, 2024

I see. Thanks for the explanation.

from android-manet-manager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.