Bluetooth protocol and implementing a position system with four devices - android

I'm studying Bluetooth protocol and implementing a position system reading RSSI in dBm from some devices. System will be implemented with 3 fix stations with an known latitude and longitude and a mobile station. Positioning will be done on mobile station with the power received in dBm from each fix station and the typically position algorithm.
In order to increase the efficiency of the system, some parameters from Bluetooth devices needs to be changed. This parameters could be:
Scan time on fix stations to decrease time on response to Inquires.
Inquires access codes to get answered to inquires just from selected devices(our 3 fix stations)
Some others.
There are some scenarios that can be used to do that depending on used tecnologies(some of them are limited):
Fix stations with Linux OS(no problem to modify parameters), mobile station with Android (seems to have just typically functions on its Bluetooth library but bluetooth setting are difficult or impossible to be modified).
See: http://developer.android.com/reference/android/bluetooth/BluetoothAdapter.html
All stations running Linux OS, and C++ on mobile station(seems to be easy to run from shell scripts hcitool for fix stations modifying our settings, but it seems difficult to implement source code on C++ to get RSSI with our need values on dBm of links to fix stations on mobile station).
The nasty way. All stations running Linux OS and shell scripts, on mobile station running under shell scripts parsing values from RSSI from output redirection of hcidump after lunching inquires.
It seems to be very difficult to find useful info related to this scenario. Maybe some one of you can help to choose best scenario and to describe how should be implemented.
(Sorry if something it's not explained in a better way.. my English is terrible..)
Thanks.

I'm sorry, I didn't follow everything you wrote, but I think the first step is to get down to the HCI layer on the fixed stations. That is fairly straight-forward to accomplish and gives you a fair bit of control.
As you mentioned, hcitool is very useful, but it doesn't matter what tool or language you use. You can access HCI commands from any language.
For example, I did something like this with Voyage Linux on an ALIX box. Voyage is debian based so now problem to load BlueZ, PyBluez, and Python. Python made it easy to quickly prototype a solution which you can convert to C++ later if need be. (More here.)
But that's just an example - use whatever stack you are comfortable with as long as you can get at the HCI layer. (Getting past the HCI layer requires you to work with a specific chipset and load code directly into the Bluetooth chipset.)
On the mobile device you might be severely limited: if you are trying for potential real world implementation. If this is just for the lab, you should get rooted Android devices that use the standard Bluez stack and then, like on the fixed devices, you can get at the HCI interface. Android is, after all, just Linux so you can do what you want if you have root.

Related

Can you manipulate Raspberry Pi sensor data on an Android smartphone?

I am new to using the RPi and just got the A+ model which I have been using to generate different types of data from external sensors. I was wondering if it is possible to send this data it is gathering to an android device in real-time, and if so the best method? I want to be able to notify the user (through a an app made with the Ionic framework) when the data enters a particular range etc.
And also is it possible to do this whilst the user is walking around with both the devices in hand?
The short answer to the question is: Yes, you can ;-)
The longer answer is much longer, since there are many ways to do this.
The one I personally would choose as the simplest is classic Bluetooth (not LE) using the SPP profile, which basically makes the BT link a serial connection between the RPi and the phone.
On this serial link you invent you own streaming protocol suitable for the data you want to transfer.
On the RPi side you install a module such as this: https://www.sparkfun.com/products/12577
(There are many alternatives, but the RN42 module is very foolproof...)
Don't know the level of your hardware skills, you might need something more plug and play if you feel uncomfortable hooking up the 4 wires needed for 3.3V power and serial communications between the Pi and the BT Module...
On the phone side you install https://github.com/don/BluetoothSerial, which gives you an API reachable from Ionic where you can receive the BT data stream.
With that and a bit of coding on both sides you are good to go.
I've used a Raspberry Pi in combination with an Android smartphone & Lego NXT.
Communication was achieved using Bluetooth on Raspbian. I used a cheap $1 USB Bluetooth dongle. The Bluetooth stack had to be compiled for Raspi, which may not be necessary anymore. Steps can be found here: Bluetooth error: Native Library bluecove_arm not available
Bluetooth seems most logical to me.
I'm at work at the moment, hence the lightweight answer, if you'd like to discuss this further then please leave a comment and I'll be happy to provide more verbose response.
You can upload the data to any cloud services. You can use Xively/Box. Xively is specially made for real time data collection.
To connect RPi to Xively, refer this: https://xively.com/dev/tutorials/pi/
For Box, refer this: http://www.sbprojects.com/projects/raspberrypi/webdav.php
You can then use Xively API in your android app. You can see GitHub for this
Google app store already has some apps for you, if you want to use
It might look a little complex. But its really simple once you follow the above methods.

How to sniff Bluetooth traffic in Android?

I would like to know if there are any apps/api tools to track all the bluetooth connections happening in android? I tried using hcidump via BusyBox, but the trace is truncated, it does not display all the data I need.
I am trying to receive data from blood pressure monitor in android using Bluetooth HDP profile. However, the connection works at the beginning, and then stops. Therefore, I would like to use some packet sniffer to see the low level bluetooth connection for better debugging.
I found out that traces from hcidump tools are not truncated, and I think this is a perfect solution. However, I have to copy the trace from android to the pc evry time (e.g. sending by e-mail) and therefore it is a cumbersome work. Would be great if there was a tool to get access to the terminal emulator of android. Btw, BusyBox provides also some other very useful tools from Linux.
There are two options for this currently, the first is to use a software-defined radio that supports the ISM band (at least 2.4 to 2.485 GHz). This will allow you to grab any radio signals within the bluetooth range and will be especially useful if you're trying to identify interfering signals.
The downside is that you'll be receiving totally raw waveforms which you then need to demodulate using something like the gr-bluetooth stack.
The other option is a specialized device like the Ubertooth.

Simulate cellular network's behaviour on Eclipse emulator

Is there any way to simulate the behaviour of a cellular mobile network (GSM/UMTS) in the Eclipse Android emulator?
More specifically: I want to develop an app to show information about the network, such as coverage level, parameters of neighbouring cells etc, as provided by the TelephonyManager and other related classes. I would like to do as much debugging as possible with the emulator, before testing in an actual phone.
For that I would need the emulated phone to "see" a functioning cellular network, with its protocols and parameters. Is that possible?
Emulator doesn't give you the option of setting that things. I have developed a toy app for showing network parameters and the only way I found was using a real phone.
By the way, not all phones implement all methods of Android's API, so you will find that some parameters will not be shown. And also many parameters are not available from API and you will need to get them throw AT commands (you will need a rooted device)
Note: I realize this question is two years old, but since this question received a slight edit from its original author 5 minutes ago and so got bumped back up to the front of the site, I am assuming that he may still be looking for an answer.
Yes, AT&T provides such a free tool to simulate and analyze different network conditions to a certain extent. And it can be used in conjunction with Eclipse ADT, Android Studio, or something else entirely. So it's not tied to any particular IDE.
http://developer.att.com/application-resource-optimizer
That being said, I have no idea if it will give you any cell tower related meta data.

how to read external digital input in android?

Are there anyway to read digital signal input using android device? is it possible with USB cable or any other app ?
there is a sensor to get count of products in production floor. We need to get that counting signal into android device when products are going through the sensor.
we saw some ways like IOIO, arduino. But we need to just read the input with not goigng such a big development hardware or software
Thanks a lot for any idea
check out protocoder http://www.protocoder.org It has a really good support for ioio boards. Pretty easy to use and no need to install anything in your computer :)

Get Wi-Fi protocol (802.11a/b/g/n) programmatically

Through WifiManager, my Android app can get a lot of details about Wi-Fi. However I fail to get protocol type like a/b/g/n. I have a client requirement to do that.
Does anyone know how to achieve that? (I don't have the option to use adb). It is to be done programmatically. I strongly believe that device and router have already negotiated protocol before they can connect. So that information is there with device. Question is, how do we get it?
You can partially deduce the protocol from the link speed
WifiManager.getConnectionInfo().getLinkSpeed()
By Wikipedia 802.11 protocols speed table you can tell if it is 802.11b, 802.11n or 802.11ag.
802.11n and 802.11ac full link speed tables
Link speeds of protocols 802.11a and 802.11g are the same, you can distinguish between them by the used frequency (5GHz or 2.4GHz) in the scan results.
Note that protocol can change during the connection, client and access point do negotiate protocols and speeds but they agree on a list and not on one specific speed.
I don't think there is a way to distinguish between 802.11n and 802.11ac in their overlapping speeds.
I don't believe this is possible to get in a clean manner. The protocols - a, b, g, n, etc - are actually human abstractions of the MAC and physical layer in networks. These are defined as their recognizable letters if they meet certain hardware specifications, both for the device and the network device.
After doing some digging, it seems that Windows phones are able to display this information. When digging into the manner of determining the protocol on Windows, I came across the desktop explanation as well as the Visual C++ implementation via enums. It seems that even the official Windows documentation relies on vendor-provided data and enumerated values, which would lead me to believe that they need to determine hardware specifications beyond what is likely exposed in the Android API.
If you want to determine the protocol yourself, you'll need to understand the link speed as well as the frequency, modulation, and bandwidth.
TL;DR
Likely not possible unless you are working with a rooted phone and can access the hardware specs directly.

Categories

Resources