1 2 Previous Next 21 Replies Latest reply on Jun 5, 2017 7:21 AM by e.pratt_1639216

    Ez-BLE in infinite loop error

    rjberry_1502026

      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

        • 1. Re: Ez-BLE in infinite loop error
          user_1377889

          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

          • 2. Re: Ez-BLE in infinite loop error
            rjberry_1502026

            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

            • 3. Re: Ez-BLE in infinite loop error
              rjberry_1502026

              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

              • 4. Re: Ez-BLE in infinite loop error
                rjberry_1502026

                Bob,

                   

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

                • 5. Re: Ez-BLE in infinite loop error
                  e.pratt_1639216

                  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).

                  • 6. Re: Ez-BLE in infinite loop error
                    rjberry_1502026

                    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

                    • 7. Re: Ez-BLE in infinite loop error
                      e.pratt_1639216

                      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.

                      • 8. Re: Ez-BLE in infinite loop error
                        rjberry_1502026

                        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

                        • 9. Re: Ez-BLE in infinite loop error
                          apps.kpt

                          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/

                          • 10. Re: Ez-BLE in infinite loop error
                            user_1377889

                            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

                            • 11. Re: Ez-BLE in infinite loop error
                              rjberry_1502026

                              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 

                              • 12. Re: Ez-BLE in infinite loop error
                                rjberry_1502026

                                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

                                • 13. Re: Ez-BLE in infinite loop error
                                  rjberry_1502026

                                  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 

                                  • 14. Re: Ez-BLE in infinite loop error
                                    e.pratt_1639216

                                    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."

                                    1 2 Previous Next