cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

HeGi_2497906
Contributor II

We have a serious issue and cannot resolve it, please see if you can help.

On Android, when pairing, we get no services, once the pairing is accomplished via multiple reconnect events and it connects, it will work fine afterward.  We are prevented from going to production because of this concern.

When we pair, with a fixed pairing code, we get an error of no services, and sometimes the BLE stack gets stuck and thinks it is connected, but the app, ours or CYSMART gets a no services response.

1. We have the crystal trim code in our BLE start event

2. We have regenerated all UUIDs in 128 bit mode

Our bundle is attached, please help out as soon as you are able, this is an urgent matter.

0 Likes
1 Solution
HeGi_2497906
Contributor II

OK, we figured it out over the weekend, to pair correctly using this radio, you set the passkey, and ensure the settings are correct in the BLE profile, the most important one being AUTHORIZATION REQUIRED.

In your app you try to read any characteristic with AUTHORIZATION REQUIRED generates the pairing request in APPLE or ANDROID.  In Android you get a pairing and a disconnect, and when you reconnect it works., APPLE works first time.

That was an ordeal for us, and there appears to be nothing obvious in the BLE datasheet pointing this out, or in any of the examples.  This was all we found, after learning that the BLE stack on the phone was expecting a pair request, based on a failed access, and the CYBLE_EVT_GATTC_ERROR_RSP is what is triggering the pair request.

An Error Response event is sent by the server (CYBLE_EVT_GATTC_ERROR_RSP) in response to the Read

Multiple Request if insufficient authentication, insufficient authorization, insufficient encryption key size is used by the client, or if a read operation is not permitted on any of the Characteristic values. The Error Code parameter is set as specified in the Attribute Protocol.

View solution in original post

0 Likes
27 Replies
HeGi_2497906
Contributor II

I have been working to resolve this issue in the absence of a reply.

I have improved the situation, but have discovered a key issue.

On pairing, the device pairs, accepts the key and works as designed.

Terminating the application causes the desired effect, LED indicate a disconnect and it advertises.

Trying to reconnect after pairing results in the BLE connecting and returning no services, it also locks up the BLE stack and the host has to terminate the connection, then the 8 sec timer returns the device to normal.

The pair from the process can be repeated if the device is deleted from the host BLE list, again no second connection attempt works.  If a bad pin is used, it exits the stack cleanly and allows a reconnect.

This was on Android, repeated on Apple works flawlessly, no issues at all.  I have tried multiple Android phones, and all work the same, I have manually generated all UUIDs at 16, 32 and 128 bits and repeated the test, same results.

Our customer is quite upset, they do not understand why we cannot solve this problem, neither do we.

bundle attached....

0 Likes
KevinR_91
Employee

Herb,

1) To confirm, the issue still occurs on both your custom application and CySmart correct?

2) When you say the BLE stack "locks up" have you run the debugger to understand where this lock up occurs?

3) Have you tried adding any serial debug output to track down what is different from the initial connect, vs. the recconect?

4) Do you have any logs from the android host side?

5) Does the attach code run on a Cypress Kit?

Regards,

Kevin

0 Likes
HeGi_2497906
Contributor II

1) To confirm, the issue still occurs on both your custom application and CySmart correct?

YES

2) When you say the BLE stack "locks up" have you run the debugger to understand where this lock up occurs?  I cannot discover it with the debugger, it makes it all with way through stack and I get the auth complete event, my light turns blue, and only returns to disconnect when the phone turns off the BT service by turning off the antenna.

3) Have you tried adding any serial debug output to track down what is different from the initial connect, vs. the recconect?  No extra pins on this design, IO used to the max.

4) Do you have any logs from the android host side?

Yes, they are always the same, they show connect request, connection successful, services request that is where is stops, I can send you a screen capture, but there are no error packets or other messages.

5) Does the attach code run on a Cypress Kit?

I do not know, but since it works fine on Apple I am not sure how HW would make a difference

Thanks for the support, Herb

0 Likes
KevinR_91
Employee

Herb,

I want to know if the code runs on a Cypress kit because this would be the best way for us to be able to recreate the issue and debug it.  We do not have your HW, so we would need a way to recreate the issue in order to properly debug.

Regards,

Kevin

0 Likes
HeGi_2497906
Contributor II

It won't run on the kit I have because the processor wants to run at 48 MHZ and the kit only supports 24Mhz, also there is code in there that would need to be commented out that waits for the slave processor.

Herb

0 Likes
HeGi_2497906
Contributor II

We could do a Web so you can see what I see?

0 Likes
KevinR_91
Employee

Herb,

I would suggest porting the code to a kit so that we can recreate the issue and help debug.

Regards,

Kevin

0 Likes
HeGi_2497906
Contributor II

OK, how long will that take? Can you help, I cannot afford another week

delay to create a new project, this works on Apple, why not Android. Also,

I still have the issue that the BLE component is not the latest, one

version back, the error has never been corrected, the support guy has not

been able to figure it out.

Herb Gingold

407-832-0501

herb@rviqproducts.com

0 Likes
HeGi_2497906
Contributor II

Here is code that will run on a a pioneer kit, I did not relocated LEDs, but it loads and runs and the BLE Stack will connect and pair, once disconnected, it will not reconnect, same as with my board, identical behavior.

0 Likes
KevinR_91
Employee

Herb,

Can you also provide the phone models and android versions you have tested with?

Regards,

Kevin

0 Likes
HeGi_2497906
Contributor II

ZTE Z835

ALCATEL

SAMSUNG

PIXEL 2

LG Phoenix 2 and 3

0 Likes
GyanC_36
Employee

Herb,

  I could reproduce this issue with CySmart Android App. Need some time to analyze it in details and see if the CySmart Android App is causing the problem.

As a workaround for now , do not send the security request (CyBle_GapAuthReq(cyBle_connHandle.bdHandle,&cyBle_authInfo)) from PSoC BLE device and click on pair in CySmart Android App and proceed for pairing. Doing this will not cause any problem in second time connection.

-Gyan

0 Likes
HeGi_2497906
Contributor II

If that is the pairing request, then what good would that do, now there is no pairing?

0 Likes
HeGi_2497906
Contributor II

Attempted, there is no security or pairing, it jumps right in the GATT DB, this will not solve the issue.

Again, it works perfectly on Apple.

H

0 Likes
KevinR_91
Employee

Herb,

As Gyan stated, this is not a FIX, this is a workaround for now.  He is still working on root cause for the issue and is trying to unblock you for now so your communication can work.

Further debug will take time.

Regards,

Kevin

0 Likes
HeGi_2497906
Contributor II

This back from the app team, we use a multi platform cross compiler, so not every command is available.

We would just have to see what behavior happened when a connection attempt is made. I can't request pairing manually at all. The only call for connecting is ble.connect(),

We will test now, but without pairing we are sunk, do not consider this closed, so far the patch is not production worthy.

Herb

0 Likes
HeGi_2497906
Contributor II

Hello, any news here, we are on hold until this is resolved, we are line down on three projects.

I am fully accepting that is could be my coding, so please do not hesitate to ask me to try anything, but we must have successful Android connections to move forward

0 Likes
KevinR_91
Employee

Gyan,

Any update on the debug here.  According to Herb adding the work around, break iOS functionality.  Can you make sure that any workarounds/fixes provided are testing with BOTH iOS and Android going forward?

From Herb:

"

Guys, please see the message below, the work-around kills Apple.  We connect, but nothing works, get no services CYSMART on Apple unless the GapAuthReq instruction is given.  With GapAuthReq implemented it works on Apple but not Android.

So to make it clear, using CYSMART:

if apiResult = CyBle_GapAuthReq(cyBle_connHandle.bdHandle,&cyBle_authInfo); // request pairing is implemented, it works on APPLE but not ANDROID, the Android pairs the first time, and works, repeat connect attempts always looks connected, returns no services.

if apiResult = CyBle_GapAuthReq(cyBle_connHandle.bdHandle,&cyBle_authInfo); // request pairing is not implemented, it works on ANDROID but not APPLE since there is no way to force the pairing from the host side in Apple, it is a device function, even CYSMART does not have a pairing button in the app."

0 Likes
HeGi_2497906
Contributor II

I would appreciate an update on status, we have a call in 2 hours to discuss this with our customer, do we know anything at this point?

0 Likes
KevinR_91
Employee

Herb,

Gyan is based in India so likely will not have an update until Sunday/Monday our time.  He is actively debugging this and I have a message into him for an update.

Regards,

Kevin

0 Likes
HeGi_2497906
Contributor II

Thank you, I assumed as much, but with 2 committed designs, one very late, and one releasing in 3 weeks, plus three more on deck waiting, you can imagine how concerning this is to us, thanks again for the support.

0 Likes
GyanC_36
Employee

Herb,

  As far as my testing , I do not see any issue with the PSoC Creator Project. I tested it with other BLE App (nrfConnect) and there your project works perfectly with an Android device.

I believe here the CySmart as well as your own Custom App is not handling the pairing request properly and causing the issue. May be you can report this to your Android App development team to look into it.

All the BLE Apps might not having all the functions implemented as I see and you mentioned that CySmart iOS app does not have the pairing request option in built and the peripheral has to send the security request if it wants to pair. Android CySmart app has this option.

I would suggest you to test the project with nrfCONNECT BLE app and see if you face any issue there till we come up with a fix with CySmart Android App.

Just for your information on the BLE pairing concepts -

The pairing is always initiated by the master device. However, a slave device ( Peripheral) can send a security request to master device ( If it wants) to initiate the pairing procedure.

Screenshot_20181020-093318.png

You need to click on "Not Pair" icon to initiate pairing.

1.PNG

-Gyan

0 Likes
HeGi_2497906
Contributor II

Gyan, I concur, I have been able to duplicate success with NRF, I did see one additional instability in CYSMART that I  I need to share with you, it is another data point.

While testing the master requests pairing, CYSMART connected, paired and then disconnected, a reconnect worked and it was fine after that.  NRF did not behave this way, it connected the first time and just kept working.

Please share with us your plans for CYSMART improvement.

0 Likes
HeGi_2497906
Contributor II

This back from our app team, on APPLE pairing, we need to send a connection reject, since they did not send the password and then apple will automatically attempt to pair.  The characteristic they refer to below is encryption, I have authentication with encryption selected in the security tab.

See if you can send me a authentication failure message.

The pairing is triggered by the peripheral. Meaning the peripheral has to refuse the write or read request of your central to a characteristic. Your central gets the refusal "unauthorized authentication" and then tries to pair with the peripheral and showing the pairing alert pop up you are waiting for. This is all done by core bluetooth automatically. The only thing you need to do is change the characteristics options and permissions in your peripheral. This is the apple sample code to trigger a pairing:

https://stackoverflow.com/questions/17969570/ios-core-bluetooth-not-asking-for-pair

Please help me with an implementation that will do this please.

Herb

0 Likes
MaMc_3367101
New Contributor II

Setting the AUTHENTICATION flag for a characteristic was indeed the solution here. Once the flag is set for a characteristic then the iOS device requests a READ (WRITE will not trigger) from the service / characteristic, the pairing request pops up as expected once the error message is properly sent to the iOS device.

Thank you to everyone involved with coming up with the solution!

HeGi_2497906
Contributor II

OK, we figured it out over the weekend, to pair correctly using this radio, you set the passkey, and ensure the settings are correct in the BLE profile, the most important one being AUTHORIZATION REQUIRED.

In your app you try to read any characteristic with AUTHORIZATION REQUIRED generates the pairing request in APPLE or ANDROID.  In Android you get a pairing and a disconnect, and when you reconnect it works., APPLE works first time.

That was an ordeal for us, and there appears to be nothing obvious in the BLE datasheet pointing this out, or in any of the examples.  This was all we found, after learning that the BLE stack on the phone was expecting a pair request, based on a failed access, and the CYBLE_EVT_GATTC_ERROR_RSP is what is triggering the pair request.

An Error Response event is sent by the server (CYBLE_EVT_GATTC_ERROR_RSP) in response to the Read

Multiple Request if insufficient authentication, insufficient authorization, insufficient encryption key size is used by the client, or if a read operation is not permitted on any of the Characteristic values. The Error Code parameter is set as specified in the Attribute Protocol.

View solution in original post

0 Likes
GyanC_36
Employee

In CySmart App first Click on Pair icon ( Next to the BLE device name). Doing this will ask you for entering the passkey and pairing will be done. Now  , refresh the CySmart screen and  Click on the Device Name for the BLE connection. Once the device is paired , in future connections you just need to click on Device Name.

From the PSoC Creator Project just comment out  the API CyBle_GapAuthReq(cyBle_connHandle.bdHandle,&cyBle_authInfo).

-Gyan

0 Likes