onDiscoverCharacteristicResults not called because of android.os.DeadObjectException - bluetooth-lowenergy

using the sample_apk_icsActivity app supplied in the motorola ICS R2 add-on, i am able to successfully connect to my BLE peripheral running the HRM profile.... i then create new BluetoothGattService object, at which time discovery of characteristics appears to begin....
using a packet sniffer, everything appears "normal".... at the end of the characteristic discovery process -- when i'd expect a callback through my IBluetoothGattProfile.Stub, i see a log message from the underlying BluetoothService reporting a DeadObjectException.... from the prior log messages, it would appear the service did find some characteristics and was preparing to give me callback....
again, i've been using the motorola sample app "as is"....
thanks....

You may have a concurrency issue. Where are you getting Gatt from ? If you send him to an another thread, he might have been destroyed in his original one.

Related

React Native BLE with OBD devices

I am currently trying to create a React Native app that lets me connect to my OBD2 device and read data about my car from it. However, I am struggling to figure out the "reading data" step. I am able to connect to the device and see characteristics and services, but cannot read data from the characteristic. I've seen articles on running a set of commands to initialize the OBD, but I have no clue what I am doing wrong. These articles have said things such as:
Set the command protocol to AUTO by running AT SP 0. By running AT DP, you should get AUTO.
Convert the commands to base64.
Use the "\r" return carriage at the end.
Write to the characteristic and read the resulting value.
Could anyone with experience on this issue explain how I can use an ordinary BLE app to send a command (via write) and receive a command following (via read). I understand how to code the read/write, but not entirely sure how to implement this specifically with OBD2 devices.
Thank you for your time.

Raspberry Pi 3 Model B (Android things OS) Error: Failed to open /dev/ttyAMA0: No such file or directory

I am a beginner in Android and testing Android code in which I am receiving and sending data through UART communication.
Hardware for communication- MAX232 device which is connected to Raspberry Pi3 Model B and the other part of MAX232 is connected to Vending Machine Port(Rx,Tx,Gnd to communicate my android app with the Vending Machine). My communication breaks SPORADICALLY and then starts communicating.
I do not know what the reason is
If anyone can help me in this, please suggest. Or any other information will be needed,I will share
private static final String UART_DEVICE_NAME = "UART0"; // define in my code.
**
I have to use ttyAMA0(PL011 UART) port because baudrate does not
change with the core frequency like with ttyS0(MIniUART)
**
For example: If I send 100 commands one by one, I get 2-5 times this
error.
**
> ERROR: Failed to open /dev/ttyAMA0: No such file or directory
**
Same thing happens to me reading data. I do not talk to the device (particle photon) connected to it, just listen. Since i'm expecting a response frequently, anything more than a couple seconds means things have gone south on one side or the other. It didn't seem likely though that my photon code was bad, as I had done many day-long tests with other things reading the data (arduino IDE, whatever).
Anyway, I created a runnable that fires every few seconds and checks when the last received response was. If it exceeds 60 seconds (things are most certainly wrecked and not going to get any better), I'll attempt to start up the connection again (Periperhal manager's openUartDevice). The main code waits another 60 seconds before trying again if it still has not received a response.
I also added code in 'onUartDeviceError' to trigger a callback the second that goes bad (not really sure if that's ever been the culprit in this), which will attempt the same restart logic but with a much smaller wait (like 5 seconds).
Lastly I made the Pi reboot itself (and thus the attached photon) so everything starts fresh, every morning at 6am. This has solved the issue for my purposes and its been in service for somewhere in the neighborhood of two years. Due to this reliability issue I don't do anything important with the pi, it simply exists to aggregate data from a few places and provide JSON. The photon is much more reliable even if the pi stops listening to it, so it controls the important/dangerous stuff (heaters, lithium batteries). Hopes this helps a little, but maybe some reconnect logic would solve the problem.

Freepbx data integration with custom CRM

NET experts,
I have a scenario where a 4-port PSTN card is installed in a server and I have installed Freebpx on that server as per suggestion by someone. When a call comes on any of the PSTN line, it is forwarded to one of the operators on his hard phone.
Each operator is also having a computer screen at his table, powered by an individual CPU. This runs our CRM software to be handled by operator. When a call arrives to an operator hard phone, say operator 2, we want that the Caller number should also be displayed in the CRM software. Based on this caller number, operator can enter some information related to the Caller and save it in database via our CRM software. Also, when operator disconnect the call, we should receive call stop time for statistics later on.
Thus, we need caller number and call start time when a call is picked by an operator on his hard phone. and then we need call end time when a call is finished.
Can someone help us how we can achieve this? Do we have to capture the SIP packets and parse them or their is some other way to do so? Our CRM database is totally separate from the Freepbx and resides on another server.
If you want to get these events realtime, you should look at AMI (Asterisk Manager Interface - port 5038 TCP by default) and it's configuration manager.conf (note: FreePBX uses the, see manager_custom.conf).
If you want the archived version, you should set up a database server, and point the CDR (Call Detail Records) module to it. PostgreSQL or MySQL/MariaDB works just fine. Asterisk will simply ignore additional fields in the CDR as long as they can be NULL or has a DEFAULT value. This can be used to store custom data.

Do I need multithread?

I am developping a project about data sampling and realtime display like oscilloscope. The data are transfered to PC with virtual com port at a high trandfer rate. I am using QT4.8.4 + Qextserialport to accomplish serial port communication on WindowsXP.
I have tested the device using AccessPort. It could receive the data from the port, but have no response to write to it. If I wanted to make the device stop uploading data, I must stop the device and write stop command to it, restarted the device, then the device stopped uploading. It is the same for the application using one thread to process reading and writing. I did not want to close the port completely. I just wanted to enter some command to change something, the sampling rate, the data format, etc.
So, I tried multithread. I downloaded a reference code from the following link.
http://www.qtcentre.org/threads/21063-QextSerialPort-with-QTimer-approch-for-reading?p=103325&highlight=#post103325
(I am sorry, I really do not know how to paste code fitly on this site)
In this code, the author derived two subclass of QThread. One is for reading port, the other is for writing port. He also reimplemented the run() in these two subclass. I tried this code, but found that when receiving code, my GUI frozen.
It seem that the author in the following thread met the same question with me.
Qt: GUI sometimes freezing when using threads and signals/slots
But I have question about this thread.
The author mentioned "When running the code in the GUI-thread, there is no problem."
Did the author mean that everything is OK when the all code in GUI-thread? So, why he used worker thread and process thread?
The author mentioned "Process thread"
Do I need a another process thread to work with GUI thread which is responsible for display?(I need to display not only the data but also the waveform, all must in realtime)
Please give me some tips on how to conquer this problem. Thanks a lot.
The short answer is yes. Doing any heavy processing on a GUI thread will result in freezing the GUI (esp if you block). Instead you should either have an independent thread that updates the data, or spin off worker threads for specific tasks. In either case, when there is new data to display you should signal the GUI thread when there is new data to display. If possible, I'd recommend using the MVC pattern and implement a QAbstractItemModel to provide data to your view (as it has a defined pattern for providing those updates).

J2ME: Multiple HttpConnection fail on device (Nokia C2-O3)

I try to create Asynchronous(non-blocking) request in my J2me application.
I write code as per this tutorial: Ajax-like Asynchronous SOA Calls with Java ME.
Code run successfully on emulator on Netbeans.
But when app deploy and device it fails on multiple connection.
When two connection open. then first connection tread kill and execute second only.
This problem only on device. It works fine on PC
According to this article http://developers.sun.com/mobility/midp/articles/mmapioverview/index.html "Note also that MIDP limits the number of HTTP connections open simultaneously to four.", but your device seems to only allow one connection.
In this case you should create a queue and execute one thread at a time.

Resources