Ez-BLE in infinite loop error

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
RoBe_1502026
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

Hi,

   

I am having a weird thing happening with my Ez-BLE project. I know you like to see the project but the current version has some private data and i need to make a new version with out this which will take a bit to do. BUT I thought I would post the problem in case it can be resolved without the project.

   

My project consists of 1 - 5LP processor doing all the IO processes. 1 - Ez-BLE doing the communication management, it requests data from the 5LP system, then is to save the data in the GATT. this is done via a UART.

   

My 5LP systems appears to work fine. I can connect with a simple rs-232 interface and request info and it gets sent back.

   

the Ez-BLE seems to be working as doing the same test I see the data request being set via the rs-232.

   

If I connect the 2 things apprear to be ok but once I connect the CySmart v1.2 to see if the data is saves all goes south. The Ez-BLE gets sent to a infinite loop in the Cm0Start.c file CY_ISR(InDefaultHandler() the while loop is located in the else branch.

   

If anyone can give me direction on solving this that would be great. If you must see the app I will have to build a new version....

   

Thanks

   

Rob Berry

0 Likes
1 Solution
RoBe_1502026
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

Hi again!

   

EDIT:

   

I was having trouble but i think I fixed it by clearing the serial buffers after each use. Still a little buggy but BIG progress.

   

Thanks for the help!

   

Rob Berry

View solution in original post

0 Likes
21 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

This infinite loop is usually called when something really goes amiss as

   

Executing invalid instructions

   

Accessing non-existent memory

   

Both of those issues can be caused by a pointer / stack clobbering.

   

Try to set a breakpoint at the loop location and check the call stack.

   

 

   

Bob

0 Likes
RoBe_1502026
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

Bob,

   

I am not sure what I am looking at in the call stack:

   

Here is a copy of the call stack in the loop. I am going to make a clear version of my app but thought  I would put this here in case something is obvious.
0 IntDefaultHandler() 140 0x000005F6 (All)
1 <signal handler called>() ?????? 0xFFFFFFF9 (All)
2 ??() ?????? 0xA0000000 (All)
3 OS_scheduler() ?????? 0x0000717E (All)
4 ??() ?????? 0x0FFFF0E0 (All)
 

   

Thanks!

   

Rob

0 Likes
RoBe_1502026
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

Bob,

   

Also when i try to connect with CySmart i get this error :  Exchange GATT MTU Size timed out

   

Does that help ?

   

I am working on clean versions..

   

Rob

0 Likes
lock attach
Attachments are accessible only for community members.
RoBe_1502026
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

Bob,

   

Here is the Ez-BLE app. The other will talk longer as its bigger.

0 Likes
Anonymous
Not applicable

The GATT MTU Size time out is a specific event in the BLE callback handler on the PSoC chip, and thus the Ez-BLE you are connecting to is failing to send the GATT MTU Size that it supports when requested by the CySmart app.

   

Since your call stack looks like it doesn't contain any functions that you have written in it, my guess is that you have call a cyble_api function in an invalid state (e.g. connect while already connected, disconnect while already disconnected, or some other similar collision of expected state and actual state in the code).

0 Likes
RoBe_1502026
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

Thanks for the clarification. This is my first BLE app and I am having allot of trouble. Are there any books, online classes anything that give a good base for designing BLE?  I really need this done as this is the last part. I was using xbee to do my communication between parts. I was convinced the Cypress BLE option would be better and am starting to regret it and thinking of going back to xbee.... PLEASE HELP!

   

Best Regards!

   

Rob Berry

0 Likes
Anonymous
Not applicable

There are multiple layers of learning depending on how much you already know:

   

Learning the programming language; Learning the cypress IDE; Learning the Bluetooth Standard specification; Learning the cypress PSoC capabilities/limitations.

   

I would assume you are looking to learn about the PSoC BLE API related operations. The quickest way to learn that is by going through the 100 projects in 100 days example on github (https://github.com/cypresssemiconductorco/PSoC-4-BLE/tree/master/100_Projects_in_100_Days)

   

As a general rule:

   

Power saving modes (sleep, deep sleep, etc) require testing to make sure the peripherals that you want on/off are as intended, and that the chip wakes up properly/goes to sleep properly.

   

Saving data to flash (like storing bonding data or app data) requires modifying hardware settings/values and should only be done when no other hardware components are running/need to run. (There are exceptions, but generally easier not to write to flash unless you know you can afford the side effects)

   

The BLE chip has a couple main states:

   

Idle (Off, Powering up, On),

   

Advertising,

   

Scanning,

   

Connected (Unencrypted, encrypted, authentication)

   

If you are checking states before calling the Cyble API functions, then you shouldn't run into issues. A tip for determining what the last Cyble API function called before the unit crashed is to have a global status variable, and write a specific value to it whenever you call a Cyble API function.

0 Likes
RoBe_1502026
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

I already have one part done using the 5lp and it works great. I am very familiar with C and the cypress IDE. This is partly why I am 

   

so frustrated. I have done so much with psoc I don't understand why I am having trouble. I based my current app off a sample in the 100 projects in 100 days. Love them! I am going to check and make sure I am checking the state of the API before calling a function. 

   

Is there any housekeeping needed to be done to process data coming in via the UART (i.e.: disable an interrupt etc..)?

   

thanks!!

   

Rob

0 Likes
Anonymous
Not applicable

There are multiple layers of learning depending on how much you already know:

   

Learning the programming language; Learning the cypress IDE; Learning the Bluetooth Standard specification; Learning the cypress PSoC capabilities/limitations.  http://www.msrbuzz.com/download-latest-version-appvn-app-apk/

   

I would assume you are looking to learn about the PSoC BLE API related operations. The quickest way to learn that is by going through the 100 projects in 100 days example on github  http://appsforsys.com/fastpokemap/

0 Likes

Thanks for the feedback. What relevance are the links you supplied? They don't appear to have any code samples but look like an advertisement for your apps. As I appriciate your help, I don't feel embedding ads for your product in a discussion that may some day also help others in good taste. Also you basically copied a previous post and did not really add to the discussion.

   

Best Regards,

   

Rob Berry 

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

In the Rx interrupt handler you are maintaining the wrong index: RxReadIndex instead of RxWriteIndex.

   

Your statement

   

    CYBLE_STACK_MODE_DEBUG;

   


is wrong

   

Your Rx buffer is smaller (4) than your receive buffer (10).

   

 

   

Bob

0 Likes
RoBe_1502026
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

Hi again,

   

I am trying lots of stuff, made the fixes as Bob pointed out and still hitting the loop.

   

Here is what I am wondering if i am doing wrong. The GATT values I want to update are receiving their values via the UART from the 5LP.

   

EDIT:

   

I Think I am thinking this bluetooth thing incorrectly - I have 2 parts A- Central Controller  B - Machinery Interface  :  Does one save the values locally on the B device and have A retrieve the data OR is all data saved on A and then B retrieves the data and stores in local variables?

   

ALSO

   

I think the code I have is processing data as if it was via a Bluetooth connection not serial.  How do you update these values outside a bluetooth connection?

   

I am looking in the 100 days apps but thought I would just ask here....

   

Thanks,

   

Rob

0 Likes
Anonymous
Not applicable

The "server" role device will keep a local copy of data that can be updated locally, or through a remote BLE connection. The data stored locally can then be read either locally, or through a BLE connection. The remote device will not get updates unless the local code specifically calls the indication or notification BLE API functions to manually push the data to the remote BLE device. You should be able to call the cyble_gattswriteattribute() function to write data to a service/characteristic on the GATT database for the local device.

   

Not sure what you mean by "processing the data as if it was BLE versus serial."

0 Likes

Thanks,

   

I may of just been confused, being pulled many ways and stressed because i had planed to have this working 2 weeks ago and still fighting.

   

watched all the videos on the cypress site and even used the 100 app 100 days for idea.

   

I think i amy not be handling the data from the UART correctly. I have the 5lp sending data to the ez-ble via the UART but it seems to mess it up. If I stop the 5lp app i can fetch the parameters but when its running it errors.

   

Are there any samples where you retrieve data via a uart and save it in the GATT?

   

Thanks a ton for the help!

   

Rob

0 Likes
Anonymous
Not applicable

I know the feeling 😞

   

I would try breaking it up into two steps: Receiving and saving data from the UART to a local buffer (easy to see visually with the debugger by breaking on receiving UART data, and checking that you are saving it correctly)

   

Next, saving the custom UART data to the GATT DB (Should be a simple call to the cyble_gattswriteattribute() or something similar in name.

   

Here's a sample of what I'm using to update the GATT DB:

   


                    CYBLE_GATT_HANDLE_VALUE_PAIR_T hvp; //Consists of a uint8 array, and the length of the array, the handle points to the handle of the characteristic to write the value into
                    uint8 theValue[2];
                    theValue[0] = 0x55;
                    theValue[1] = 0xAA;
                    hvp.attrHandle = CYBLE_VIKING_DATA_VOLTAGE_CHAR_HANDLE;
                    hvp.value.val = theValue;
                    hvp.value.len = 2;
                    err_or_response = CyBle_GattsWriteAttributeValue(&hvp, 0, &cyBle_connHandle, CYBLE_GATT_DB_LOCALLY_INITIATED);

0 Likes
RoBe_1502026
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

I think I have a deeper problem. I have watched and read so many tutorials that I feel my app should work. SO

   

I loaded a fresh sample of the Find me app. The only change I made was the processor I am using the Cyble-224110-0.

   

I did a clean & build then ran it.  if using CYSmart on my laptop I get the GATT MTU Timeout error. If I connect with my Iphone it works.

   

So I went back to my app and ran it but this time used my iphone. I was able to connect but the GATT says 'Unknown service' and a list of 'unkown characteristic' 

   

SO Why can I connect with my iphone but not with cysmart 1.2 on my laptop? (don't know how to get to set the characteristic name)

   

Best Regards,

   

Rob Berry 

0 Likes
Anonymous
Not applicable

You can try tweaking the parameter connection settings for the CySmart application itself, and various other RF related settings to see if increasing the latency on data exchange will help the cysmart device to properly send/receive the GATT MTU exchange.

   

Another option could be to disable the automatic device reading/exchange packets that the CySmart app sends on connect (under the master settings iirc).

   

The iphone has some pretty unique/specific connection settings and behavior for BLE, so it could be skipping some steps that the CySmart app is choking on, or that your Cyble-224110-0 is having issues with.

0 Likes
RoBe_1502026
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

Hi again!

   

EDIT:

   

I was having trouble but i think I fixed it by clearing the serial buffers after each use. Still a little buggy but BIG progress.

   

Thanks for the help!

   

Rob Berry

0 Likes
Anonymous
Not applicable

I would suggest using timers of some sort to: Determine when the characters are done coming in and when the message has taken too long to send/receive.

   

Also, as Bob suggested, having a larger RX buffer might help. 

   

I would suggest using escape characters to handle sending 0x00 bytes, and using 0x00 bytes as interpreted silence on the data lines. Thus, you only receive valid characters, and throw away all 0x00 bytes that aren't deliberate. This way, you can receive a dynamic-length string for processing that starts and ends with 0x00 as the delimiters for "silence" on the data lines. You will still want to limit the maximum number of characters in the buffers, and throw away any that go over, but at least you will have more reliably separated messages.

0 Likes
Anonymous
Not applicable

Hi,

   

I am having a weird thing happening with my Ez-BLE project. I know you like to see the project but the current version has some private data and i need to make a new version with out this which will take a bit to do. BUT I thought I would post the problem in case it can be resolved without the project. appvn

0 Likes
Anonymous
Not applicable

I would suggest creating a new topic since it seems like a different topic for the issue you are having 🙂

0 Likes