• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Need feedback on my ideas

 
Ranch Hand
Posts: 48
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I have encountered a problem and have two solutions to it that I need some feedback on. Or perhaps a better solution

I have two android devices that communicate with each other through a server. All the requests to the server are done by REST and all the requests by the server to the phone is done by push messages(using Firebase).

In my app, without trying to reveal to much info, one device A need to tell device B that something have happen. But before it does that, it need to check if device B is within close proximity. And if they are, ignore the message.

Idea 1:
1) Device A sends a REST request to the server, telling that something may have happen. Also include device A's GPS coords.
2) Server ask device B for its GPS coordinate by sending a push notification.
3) Device B receives the push message and sends a REST request to the server, containing its GPS coords.
4) Compare the GPS coords and determine if they are close to each other. If not, send a message to device B, telling it something have happen.

Idea 2:
1) Device A check if it can connect to device B or if it is connected to device B via Bluetooth.
2) If not, send a REST request to the server, telling that something definitely have happen.
3) Server simply forward the message to device B.

While idea 2 sounds easy and better, I am suspicious towards the use of Bluetooth. Basically, I am not use it's possible for device A to know that it actually is device B. So I am questioning the reliability of the second idea.
The first idea is on the other hand hard to implement. And I simply don't like it.  
 
P Marksson
Ranch Hand
Posts: 48
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doesn't this forum have an edit button?

Anyway, want to note that battery usage is critical. And in my experience bluetooth should be way cheaper than GPS.
 
Marshal
Posts: 4174
555
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Without knowing too much about the application, its difficult to provide specific feedback.

A variation on Idea 1 would be to have the server simply act as a relay point between the handsets, and let the receiving handset decide whether to react to the event generated by the other handset.  The devices could use a variety of location-identifying information in addition to GPS such as lists of visible cell sites and their signal strengths, the MAC-address/SSID/IP-subnet of the connected access points.  They could also send and receive broadcast announcements over the connected WiFi network, etc.

Idea 2 sounds like a good idea if you expect that normally the devices are in close proximity - such as a young child and parent at a mall, or courier and his mesesenger bag.  You might want to build your own security layer on top of Bluetooth.
 
Bartender
Posts: 7488
171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It depends on what constitutes "close proximity" - the suggestion of Bluetooth indicates that the devices would need to be pretty close indeed (no more than 30m, and probably no more than 10m).

If power consumption is a concern, then the devices probably won't have either Bluetooth or GPS turned on - in which case you might have to go with the lower-quality network location service, which can easily be off by a few hundred meters.

+1 on Ron's suggestion that the server should simply pass on the data and let the receiving handset decide whether to act on it.
 
P Marksson
Ranch Hand
Posts: 48
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the inputs.

I will consider having the server simply forward all the request and let device B do the calculations.
The purpose of the server is to do all the calculations so the mobile devices don't have to do it. Basically, device A could sends few messages per second to device B. I am afraid forwarding every request to device B would drain its battery.

AFAIK, the battery consumption of having the Bluetooth on is minimal. But I am interested in this "lower-quality network location service". Could you please elaborate?

Regarding the use of bluetooth, I found an very interesting method:
https://developer.android.com/reference/android/bluetooth/BluetoothAdapter.html#getRemoteDevice(java.lang.String)
 
Tim Moores
Bartender
Posts: 7488
171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

But I am interested in this "lower-quality network location service". Could you please elaborate?


That's the location service that on your device is labelled as "Battery saving" (as opposed to "Device only" a.k.a. GPS, or "High accuracy" which uses both).

I can't find a good comparison overview, but https://developerlife.com/2010/10/20/gps/ has a useful chart (which strangely implies that the network provider needs GPS - which it doesn't) and https://developer.android.com/guide/topics/location/strategies.html also has useful information.
 
Ranch Hand
Posts: 570
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

P Marksson wrote:Doesn't this forum have an edit button?


No,unless  you earned enough cows
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree to the suggestion of let device B make all calculations as it will be easier than receiving and sending data to server twice.
 
Slime does not pay. Always keep your tiny ad dry.
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic