ANDROID API, BTH CONNECTION PROBLEM

Python, Java, Android OS, etc.
cesarldm
Posts: 6
Joined: Thu May 18, 2017 6:39 pm

ANDROID API, BTH CONNECTION PROBLEM

Postby cesarldm » Mon May 22, 2017 10:25 pm

Hello,
I'm currently developing an Android APP using the ANDROID API provided.
I have two Bitalino boards to make tests, an older version and a more recent version.

The more recent board works perfectly, I'm able to establish the connection and send/receive frames without a problem,
but when I try to connect to the older device I get this error message and the connection shuts down:

93-27513/com.polito.cesarldm.tfg_bitadroidbeta E/AndroidRuntime: FATAL EXCEPTION:
ConnectedThread98:D3:31:B2:C1:32
Process: com.polito.cesarldm.tfg_bitadroidbeta, PID: 26893
java.lang.NumberFormatException: Invalid float: "3.3a_18032014"
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.initialParse(StringToReal.java:164)
at java.lang.StringToReal.parseFloat(StringToReal.java:323)
at java.lang.Float.parseFloat(Float.java:306)
at info.plux.pluxapi.bitalino.bth.BTHCommunication$ConnectedThread.run(BTHCommunication.java:811)


I'm not able to understand why this is happening, any help would be helpful.

GTelo
Posts: 4
Joined: Mon Mar 06, 2017 10:29 am

Re: ANDROID API, BTH CONNECTION PROBLEM

Postby GTelo » Tue May 23, 2017 9:34 am

Hi cesarldm,

If you update your local copy of the GitHub repository the issue should be fixed.

Your device's firmware version contains a letter along with its number. The problem was only in that letter, but that is now fixed.

Best regards,
Gonçalo Telo

cesarldm
Posts: 6
Joined: Thu May 18, 2017 6:39 pm

Re: ANDROID API, BTH CONNECTION PROBLEM

Postby cesarldm » Tue Jun 06, 2017 8:52 am

hi Gonçalo,

I updated the API and now both boards connect properly, thanks¡
But now another issue has come up:

Almost all of the times that I start recording after establishing the connection, all the frames that I receive are empty:

BITalinoFrame: 20:16:02:26:59:04: Seq: -1; Analog: [0, 0, 0, 0, 0, 0]; Digital: [0, 0, 0, 0]

(It hardly ever happened before updating the API).
If someone has some clues to explain why this is happening please let me know, it would be great help.

GTelo
Posts: 4
Joined: Mon Mar 06, 2017 10:29 am

Re: ANDROID API, BTH CONNECTION PROBLEM

Postby GTelo » Tue Jun 06, 2017 10:36 am

Hi cesarldm,

I have been trying to reproduce your problem with several BITalino devices, with different firmware versions, and different mobile devices but with no success.

This issue is caused by an error in the Cycle Redundancy Check (CRC) value, that might be caused by an unstable connection between devices. Have you tried to set the acquisition with a lower sampling frequency? It could be a limitation on your device's bluetooth adapter, that is not allowing a big data streaming.

Best regards,
Gonçalo Telo

cesarldm
Posts: 6
Joined: Thu May 18, 2017 6:39 pm

Re: ANDROID API, BTH CONNECTION PROBLEM

Postby cesarldm » Tue Jun 13, 2017 4:16 pm

Hi Gonçalo,

I found the problem.

In my previous code I started recording data as soon as the device sent to the BroadcastReciever the state as CONNECTED using this "checkConnectionState()" method:

Code: Select all

 private void checkConnectionState(String state) {
        switch(state){
            case "CONNECTED":
                isConnected=true;
                startRecording();//<---------here was the problem;

                break;
            case "ACQUISITION_OK":
                isRecording=true;
               
                break;
            case "DISCONNECTED":
                isConnected=false;
                sendStopMessage();
               
                break;
        }

It seems you need it to give de device just a tiny bit more time to establish the connection properly, I have set a button in my activity and now I connect to the device as soon as I start the service, and wait until the user presses start to start recording, and It has been working perfectly since.


Return to “Programming APIs”