[Q] [SOLVED] Reading sensors from Android to PC, and into Processing - Android Q&A, Help & Troubleshooting

Hi guys, I've been an avid reader of the xda forum, and it's great, so far it has been an awesome source of knowledge, however up until now I had found everything I needed...
Long story short, I want to be able to use the sensors in my smartphone (Rooted Moto G XT1032, 16 GB) in the open source software Processing. Could somebody please point me in the right direction?
Basically I want to:
Connect my phone to my PC via BT or WiFi
Read the value of the sensors within my phone and transmit them to my PC
Somehow read those values in Processing and create nice graphs and stuff
I know how to program Processing, I've looked into the Amarino Project, but it does require the Arduino Part, and I know how to interface Arduino and Processing (I've done some PID control and other stuff with those), but I want to skip the whole Arduino part (at least for now).
Could somebody please point me in the right direction?
Thanks in advance, cheers!
Update 17/09/2014: Currently looking into the SensoDuino project, which apparently will solve my problems in the Android Front.
I tested it following the video in the main page of the project in the part Pairing and Establishing a Serial Connection between Windows 7 and SensoDuino (sorry I still can't post links), I have been able to read the data using Tera Term
Just mind the COM ports, and that you are actually transmitting over bluetooth, you can check this in the services tab of the properties of the paired device within Windows (If anybody wonders why not Linux, which I use the most, in which I do my main work and in which this would be pretty much a native feature, I intend to use this with a Windows Only Software)
Special thanks to TheBeano!
P.S. Depending on what the rules of this forum regarding solved threads are, I'll either update or publish whatever the outcome of this project is, cheers!

Hectormd said:
Hi guys, I've been an avid reader of the xda forum, and it's great, so far it has been an awesome source of knowledge, however up until now I had found everything I needed...
Long story short, I want to be able to use the sensors in my smartphone (Rooted Moto G XT1032, 16 GB) in the open source software Processing. Could somebody please point me in the right direction?
Click to expand...
Click to collapse
Look at SensoDuino, they have a demo of connecting to Windows 7 via Bluetooth serial. Once you have a Bluetooth serial connection you can use Processing's serial comms to read the phone sensors. You could do the same sort of thing with Amarino, that is just read from the serial port, but it might be more work to decode the binary protocol that it uses from Processing. Sensoduino sends ASCII I think.

TheBeano said:
Look at SensoDuino, they have a demo of connecting to Windows 7 via Bluetooth serial. Once you have a Bluetooth serial connection you can use Processing's serial comms to read the phone sensors. You could do the same sort of thing with Amarino, that is just read from the serial port, but it might be more work to decode the binary protocol that it uses from Processing. Sensoduino sends ASCII I think.
Click to expand...
Click to collapse
Thanks a lot, it looks exactly like the thing that could fulfil my needs.
I'll update this post or publish whatever I come up with cheers, and thanks again!

Related

How can I forward an voice call to another android device via bluetooth?

What I want to do is to write an app that forward the phone call from my android callphone to another android device, via bluetooth. Note that the destination is another android device, which could be another phone, or, in my case, is my x86 netbook with android installed.
The question may sound goofy. After all, if bluetooth is effective then the two devices must be close to each other. If both of them are phones, as most people would think, then what is the point to simply forward the call from one phone to another?
Well, in my case, the second device is not a phone, but an android device that are not capable making a phone call, which is an x86 netbook on which I have installed android. I wonder if I can write an app, and install it on both phone and netbook, such that I can directly make/receive the phone call from the netbook.
I have checked out the bluetooth chat sample code but apparently it can only send a string (byte[] buffer) over bluetooth, but not an audio stream that I need. I glimpsed the android bluetooth api but didn't find anything helpful.
Any suggestions or hints are greatly appreciated. Or if there is any existing discussion or source code to fulfill this purpose, please let me know. I did do some google search but found nothing.
Thanks.
Lik
lik88888 said:
What I want to do is to write an app that forward the phone call from my android callphone to another android device, via bluetooth. Note that the destination is another android device, which could be another phone, or, in my case, is my x86 netbook with android installed.
The question may sound goofy. After all, if bluetooth is effective then the two devices must be close to each other. If both of them are phones, as most people would think, then what is the point to simply forward the call from one phone to another?
Well, in my case, the second device is not a phone, but an android device that are not capable making a phone call, which is an x86 netbook on which I have installed android. I wonder if I can write an app, and install it on both phone and netbook, such that I can directly make/receive the phone call from the netbook.
I have checked out the bluetooth chat sample code but apparently it can only send a string (byte[] buffer) over bluetooth, but not an audio stream that I need. I glimpsed the android bluetooth api but didn't find anything helpful.
Any suggestions or hints are greatly appreciated. Or if there is any existing discussion or source code to fulfill this purpose, please let me know. I did do some google search but found nothing.
Thanks.
Lik
Click to expand...
Click to collapse
Bump
Or something that makes me dial from Device 1 but the calls are made on Device 2

chipset access or API for low level access

Hi *,
I'm very new to forum and hardware hacking. I'm also new to android dev (I have done some WP7 development).
I want to write application about radio conditions (RSCP, EcNo) and also wanna to decode ASN.1 messages to get some 3GPP layer 3 messages (RRC). To do that, I suppose that low level access is required.
So, is there any tutorials, guides etc. on how to do that for android devices (I know about android telephony class) or WP7/WP8 devices.
I also know that that is not possible on every device due manufacture restrictions.
I'm interested in Galaxy S(2/3), Nokia Lumia, Nexus, etc (device doesn't need to have qualcom chipset, all i wanna to do that).
I also know that some of companies like ASCOM are working together with chip suppliers for that kind of applications.
So, is it possible to do on market smartphones...
Thanks in advance for answers
Cheers!
TK
It's troublesome thing.
Every modern mobile solution does split into AP (Application Processor) and BP/CP/Modem (Baseband/Call Processor), sometimes these are integrated into one SoC (QC chips) or are splitted into 2 SoCs (like Exynos AP+QC/Infineon CP), on AP there's working ARMLinux with Android platform.
Platform does communicate with RIL HAL (proprietary lib), RIL does communicate with modem through some dedicated HW interface using kernel driver, nowaday its common shared-memory topology with abit of control through UART/GPIOs before RAM-share is set up (modem bootup, assuming AP does startup first, which is case in 2xSoC topology, on QC SoCs modem does startup first and does perform bootup of AP submodules).
The problem is - BP OS is closed source. In best case (rather unlikely) low-level transmission params might being received by RIL from AP but not being passed to platform, then you probably would need to patch RIL binary to expose these values to platform. If these transmission params aren't being transmitted from CP to AP, the easiest (and the ugliest) way to do is trying to find network structures inside of modem OS and pooling them from AP (assuming you've got direct access to all of CP memory). More advanced way would be integrating additional data into BP-RIL interface (modifying both RIL and modem binaries), what then narrows down to "best case".
If you aren't familiar with ARM assembly - analysing modem binary is pretty big task, prepare for at least few weeks of intense reversing.
This is a very interesting question!
So far, AFAIK, no one here at XDA (or elsewhere) have been able to successfully extract L1 radio parameters from the modem, using any form of API or other. So anyone who would successfully be able to do this, would be an instant XDA hero! (As for L3, I don't know.)
But then again, I don't think anyone have tried hard enough either. I have tried to a limited extent in my research of the Intel XMM6260 and trying to use some of the Android internal telephony API. Others have managed by hacking the AT command line interpreter, directly in the modem image of some limited versions of the 2xSoC's (like those of Intel/Infineon) used for jailbreaking <4S iPhones. These modem images are "only" 10 MB, whereas the Qualcomm modems "images" consists of 50-60 files and have a size up to 60 MB!! Although we should be able to find the AT command Processor (ATcP) in those...
As I see it today, we only have these options how to get these parameters in the Android eco-system.
1) We believe that the modem AT command interpreter/processor have the capability to provide radio parameters to the outside world. But this direct access often seem to be crippled:
a) by denying local or external terminal (UART) serial-access.
b) by being filtered by the RIL daemons and accompanying RIL libraries
c) by being complicated due to using modified IPC (shared memory) communication, rather than regular serial devices. However, by putting the device into "download/debug" mode, sometimes these devices re-appear!
(This is what ODIN, QPST and other programs does, see (4).)
2) We know that the Android internal phone API can use the following calls to get particular modem "stuff" (including sending AT commands): RIL_OEM_HOOK_RAW and RIL_OEM_HOOK_STR
The problem is that no one seem to know how to use it, nor how it depends on the hardware...
3) We know that the Service Mode's (settings/menu) are displaying many of these parameters, so that the phone OS certainly can get have access to these. So another option is to hack and understand how this is done by the service mode menu and the underlying modem software. This is where reverse engineering would come to its right!
4) We also know that many of the OEM phone debug/repair software, like QPST and QDART (Qualcomm) and "CDMA work-shop" etc. have full access to these variables as well...
Actually, if you're on a Qualcomm based device and can put it into QXDM mode, you can have all radio data to be output to the QXDM (3.12.754) software and possibly interface API. Thus... if we can understand the handshake and protocol they use we should eventually be able to make an app that can fetch this data as well...
Thx for your answers!
It looks like I need many hours to investigate and learn! Sound like fun, hope it will be...
I hope that soon I'll post something new on this thread about question.
Thx and hear ya!
Little update: Regarding radio conditions, here is telephony API http://developer.android.com/reference/android/telephony/package-summary.html and here is Signal strength class http://developer.android.com/reference/android/telephony/SignalStrength.html!
So I have these information (at least I hope so, because I don't have device for testing and I don't have dev environment set yet).
Also, regarding WP7 Samsung devices: there is samsung app called Diagnosis, where you can access root/debug screen in Test Mode... I was looking little into that app (I have unlocked Samsung Omnia W device), and there are very interesting informations, like list of neighbour cells with CellID and signal strength and many others (Handover test, antenna/ADC, RRC state, Tx Channel, Tx Power, EcIo, RSCP, L1 (looking now it's PCH_Sleep value ??), etc)
I need that kind of information + need to find way for decode L3 messages like RRC and RLC. From L3 you can find many other information (RAB establishment, IRAT handover, all 3GPP information element for GSM/WCDMA/LTE and so on!)...
hi *,
What about Gobi platform and GOBI dev?
BR
TheKrigla said:
hi *,
What about Gobi platform and GOBI dev?
BR
Click to expand...
Click to collapse
Hi, i was just looking for GOBI, too.
But they only show 4 Devices, with the Gobi-Modem inside:
qualcomm.com/gobi/products/finder?type=Smartphones
But there are buid in a few UMTS/USB-Sticks, Mobile Hotspots, a Router and some Notebooks (SubNotebooks),
Not bad, if you can use it as an external device, like the mobile router.
So it looks like a very special solution.
Did somebody check the HTC, Motorola or Samsung SDK ?
I am also trying to get low network info, and it looks like AT commands that exist (at least on my Samsung S3) do not provide this information. So I think emulating what QXDM does is the secret sauce... but that's hard
You can probably find what you need in the "QMI" related documents from THIS post... Let us know how it goes!
E:V:A said:
You can probably find what you need in the "QMI" related documents from THIS post... Let us know how it goes!
Click to expand...
Click to collapse
I quite don't fully understand how QMI works. The SDK appears (C++) to run on Windows. Is it possible run QMI directly on android? Also one post said that really low level information like Signaling can only be through the diag port. Perhaps there is a way to emulate QXDM on the android and connect to it to grab this info
Chipset access
I am wondering how tools like qualpoc from SwissQual work. They seem to have access to every damn thing happening in the android phone. Do they have any special API access from Qualcomm ?
enigma99a said:
I quite don't fully understand how QMI works. The SDK appears (C++) to run on Windows. Is it possible run QMI directly on android? Also one post said that really low level information like Signaling can only be through the diag port. Perhaps there is a way to emulate QXDM on the android and connect to it to grab this info
Click to expand...
Click to collapse
mknair said:
I am wondering how tools like qualpoc from SwissQual work. They seem to have access to every damn thing happening in the android phone. Do they have any special API access from Qualcomm ?
Click to expand...
Click to collapse
Thanks.
http://www.swissqual.com/
Probably nothing special. What is special, is that they have full access to all their documentation. If you can download their white papers and the Android app, I'll tell you how they do it!
Is it possible to connect something like a 4G dongle to the usb port to create a roaming RF scanner and get the RSCP ECIO details from that? It's a bit mental but it doesn't look like we will be able to get this detail from the phone without paying the tens of thousands for the documentation anytime soon...
I tried to connect a Sierra Wireless device which can provide this info but I cannot seem to compile the module against the kernel.
I got QMI talking just fine on android 100%. But I need layer 1 info etc as well (DIAG)... Qualcomm docs look easy enough for the packet structure but now i just need access... And I'm totally stuck. USB is one way, but isn't there to get access locally? Like through UART or some other means? I believe all communication goes to the /dev/diag device but so far I have not been able to get access
E:V:A said:
So far, AFAIK, no one here at XDA (or elsewhere) have been able to successfully extract L1 radio parameters from the modem, using any form of API or other. So anyone who would successfully be able to do this, would be an instant XDA hero! (As for L3, I don't know.)
Click to expand...
Click to collapse
Well, I guess I am a XDA hero then I have successfully extracted L1 radio info, etc on Android itself. DIAG is pretty powerful and not very well documented so I had to figure everything out myself, but when it works you can get just about anything possible.
enigma99a said:
Well, I guess I am a XDA hero then I have successfully extracted L1 radio info, etc on Android itself. DIAG is pretty powerful and not very well documented so I had to figure everything out myself, but when it works you can get just about anything possible.
Click to expand...
Click to collapse
Any thought about sharing solution?? Not cool man...
enigma99a said:
Well, I guess I am a XDA hero then I have successfully extracted L1 radio info, etc on Android itself. DIAG is pretty powerful and not very well documented so I had to figure everything out myself, but when it works you can get just about anything possible.
Click to expand...
Click to collapse
Is that right? There were never any heroes who didn't prove their worth. So why don't you share it with us? (Or if you don't want to share, at least tell us why not?)
E:V:A said:
Is that right? There were never any heroes who didn't prove their worth. So why don't you share it with us? (Or if you don't want to share, at least tell us why not?)
Click to expand...
Click to collapse
Yeah, sorry guys for the late reply. Basically I had to rewrite the diag driver to get diag info. And this project is for profit, so I can't put myself at a competitive disadvantage after spending many weeks on it But if anyone has questions, I would be happy to answer
Hi at all!! My hero, enigma99 please tell me (or who knows)!!
I'm developing a app with SDK that use the java methods of classes like SignalStrenght and Telephony. But those methods dont work very well. (they are slow, and in much smartphone dont return the Ec/Io)
Do you think if in 3g tecnhology (UMTS, HSPA) the modem part always returns all measure (RSCP and Ec/Io)??
What's the way to follow for return this values? recompiling kernel? programming with NDK?
enigma99a said:
Yeah, sorry guys for the late reply. Basically I had to rewrite the diag driver to get diag info. And this project is for profit, so I can't put myself at a competitive disadvantage after spending many weeks on it But if anyone has questions, I would be happy to answer
Click to expand...
Click to collapse
Is this for sale yet? Curious minds would like to know.

[Q] Laptop/Desktop to Android Smartphone USB

My Question has been asked, maybe in the wrong forum, maybe I didn't ask the right question.
I'll try my best.
I have developed an application, it's almost finished but I have one more feature.
Detect events from laptop/desktop (keyboard) on Android Smartphone
I have been trying bluetooth, USB, NFC etc... I just can't quite nail the solution. I've been trying now for around 5 days to solve this problem. When the smartphone is plugged into a laptop/desktop I'd like to be able to detect keyboard events (or any type of event) from the laptop/desktop in my android app. Android 4.2.2
The idea is to log events, as the android app (installed on a dedicated device) will always be connected to a laptop/desktop for usage. The events, considering what the are will trigger certain actions on the device and within the application. If that makes sense. So far all is going well... it's just this one feature which I cannot nail.
The phone is rooted, USB Host mode enabled, recognises that it has been connected using USB. But I can't for the life of me find the device (in my development example, a macbook pro) nor can I detect any type of event triggered from the laptop.
Is this possible? If so can anyone please help me by pointing me in the right direction, adding links to resources I can read up on.
Many thanks in advance.
This is a problem which is slowly becoming demoralizing as I cannot finish the app without this feature.
Again, many many thanks for anyone willing to share some light on a possible solution. USB would be perfect but am I missing something?
Regards
Anyone?
To end these endless, sleepless nights
Much appreciated guys!
D
chronograff said:
My Question has been asked, maybe in the wrong forum, maybe I didn't ask the right question.
I'll try my best.
I have developed an application, it's almost finished but I have one more feature.
Detect events from laptop/desktop (keyboard) on Android Smartphone
I have been trying bluetooth, USB, NFC etc... I just can't quite nail the solution. I've been trying now for around 5 days to solve this problem. When the smartphone is plugged into a laptop/desktop I'd like to be able to detect keyboard events (or any type of event) from the laptop/desktop in my android app. Android 4.2.2
The idea is to log events, as the android app (installed on a dedicated device) will always be connected to a laptop/desktop for usage. The events, considering what the are will trigger certain actions on the device and within the application. If that makes sense. So far all is going well... it's just this one feature which I cannot nail.
The phone is rooted, USB Host mode enabled, recognises that it has been connected using USB. But I can't for the life of me find the device (in my development example, a macbook pro) nor can I detect any type of event triggered from the laptop.
Is this possible? If so can anyone please help me by pointing me in the right direction, adding links to resources I can read up on.
Many thanks in advance.
This is a problem which is slowly becoming demoralizing as I cannot finish the app without this feature.
Again, many many thanks for anyone willing to share some light on a possible solution. USB would be perfect but am I missing something?
Regards
Click to expand...
Click to collapse

[Q] How does a piece of hardware becomes android compatible?

Hi Devs!
I imagine this should be already discussed and explained somewhere, but I just can't find it as the word "android driver" is ambiguos and directs me to different topics.
Here we go with the question: nowadays many Android devices come with otgusb, so you can connect usb sticks, and all sorts of compatible devices. But: how to make a device compatible?
Since Android is linux, I assume loading a driver cannot be loaded just by installing an app, so do you need to call google and say "hey I got this new device, can you load the driver in your next kernel?" (sarcasm!!) or ...well...in short:
what the heck should one do if he wants to make a device compatible with android phones/tablets, even assuming he is able to write the driver by himself?
the question may be applicable to a variety of devices... a new remote one bought, a new BT wristband one wants to launch into the market, a usb sensor of some kind, etc etc etc.
thank you!
Ok, so I see there's apparently something called USB Host API, I read a little bit how it works, but I still have questions:
1. Does this mean basically that Android phone/tablet will provide RAW access via the USB Host API to any usb data stream received, and all I need is to write an app to decode that data?
2. If so, what makes a device compatible/incompatible?
3. If all of the above assumptions are wrong, please help
4. this still doesn't answer the bluetooth part, sorry for being so slow

How to send/ write Canbus messages directly from HU

Does anybody know is it possible to send/ write Canbus messages to the car directly from the Android head unit? And if it is, how to do that?
I have HU MTCE_PX30_MX and some Canbus messages are already sent to the car, so it is possible, I know. But is there any way to sent some specific messages only..?
I think for this you should have a look at MTCCanBus.apk. At some point, a serial connection is opened which seems to be responsible for receiving / sendings CAN Messages. I don't know if the connection goes directly to the CAN-Box, if it is a virtual port that simply sends data to an other software layer or if it goes anywhere else...
This is probably a good starting point.
herb77 said:
I think for this you should have a look at MTCCanBus.apk. At some point, a serial connection is opened which seems to be responsible for receiving / sendings CAN Messages. I don't know if the connection goes directly to the CAN-Box, if it is a virtual port that simply sends data to an other software layer or if it goes anywhere else...
This is probably a good starting point.
Click to expand...
Click to collapse
Thank you for the hint, I will look at it.
Actually I have already "decompiled" HCTCanBus.apk (I guess that this is right apk for MTCE units?) but I have to look it more closely. I am not so familiar with coding...
While a old thread I though I would at least now provide a Answer,
See my github for example code to talk to the CANBOX via the OS and via android calls using the existing mtccanbus.apk and such , Alas i dont know java so cannot help you there , all my work is within the CANBOS unit so far.
Canbus and services
Darkspr1te
@darkspr1te thank you. This is really useful. All I need to do is catch one MTC canbus intent into my app and get it to work, like one of the TPMS tire pressure intents for example. If I can make it work for one, I can make it work for many intents. I have a project that I'm working on and your code will definitely prove helpful !
Any news here? I really want to be able to display CANBUS info usong tasker...
marteline said:
Any news here? I really want to be able to display CANBUS info usong tasker...
Click to expand...
Click to collapse
So get involved
I downloaded @darkspr1te code and encountered some problems compiling that I haven't completely sorted out yet. Thing is that I've been quite busy with other priorities lately but I still want to pursue developing my app.
@darkspr1te did not provide any build/compile notes about the development environment used to develop the code. I'm using the latest version of Android Studio and just working through each issue one at a time. Wish @darkspr1te had used gradle as it would make setting up the build environment much easier .
The code i mentioned is not mine(as mentioned in the post too) , if you want a gradle based then see CANBUS app which is by another author. My current code is what runs on the actual canbus device (raise etc) , I have not produced any android code myself just the MCU code.
Also see this thread for further info on the headunit to canbus protocol CANBUS protocol
@darkspr1te thank you for the suggestions. I guess my referring to it as "your code" was mistaken, sorry about that. I pulled the code from your git repo and just misquoted the original source for the code.
Still regardless of the original author, I just wanted to get the code to compile and work. Maybe I can find the example(s) I needed from the other suggested resources.
Rear little connectors in HU has an 8 pins section used for CANBUS, but only if radio has CANBUS. In that little 8 pins connector section there are 2 pins called TXD and RXD that go to CANBUS box (in my case, Honda Accord 7th, to HVAC buttons frame). I haven't measured signals TXD and RXD that go to CANBUS box and, thus, I don't know if they work at 5 V or 3.3 V. I don't neither know the protocol in these lines. But CANBUS box translates signals in both senses. CANBUS is a multinode trunkline that uses 2.5 V in recessive state and +/- 1 V for dominant. But it is a serial port at radio side.
See pins 36 and 50.
It would be possible to add an Arduino 2560 with 4 serial ports as a gateway, that is, intercepting TXD and RXD with 2 serial ports of 2560 and having 2 additional serial ports to connect another devices. One of them might be an FTDI USB serial to HU and inject and intercept CAN messages from an own application. But it requires to know CAN message format at serial side.
Even better might be to program directly in HU without installing an external element, that must be also programmed. I think there is an hierarchical structure of classes that produces events that can be intercepted. But I don't know how to do it. I have begun to read about Android Automotive but there is no much information about it. The main problem is how to put a car on the table beside a PC with Android Studio.
Here the manual that describes the RS232 side messages of a certain CAN-RS232 converter: https://drive.google.com/file/d/1CKftK1HeclPr9TdSG6DdCFfwmeMjoFIm/view?usp=drivesdk
Interested in protocol, see chapter 2.7.2 and successive. But not all devices must forcely work exactly as this one.
But there is another converter that uses another different message format at RS232 side (around chapter 4): https://drive.google.com/file/d/1CMcJqeHfP0YFG83UOwGMe2EUwyD49_bY/view?usp=drivesdk
It is necessary to sniff TXD and RXD wires or having a manual describing chinese radio CAN message format.
VB6 example: https://drive.google.com/file/d/1CMlDhSCgk9QhxLxvgrERXKX1jOOKXLOo/view?usp=drivesdk
The H/U to CANBOX is 3.3v (default stm32 profile) but the pins used are 5v tolerant. There is already a fully working project plus sources with protocol encode/decode functions at
https://github.com/smartgauges/canbox
@Pacovich also your google drive links require access control so no one can download them.

Categories

Resources