• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Low Power RF & Wireless Connectivity » Bluetooth® Applications » Problem Receiving Bluetooth Data
Share
Low Power RF & Wireless Connectivity
  • Forums
  • Announcements
  • Files
  • E2E Wiki
Options
  • Subscribe via RSS

Problem Receiving Bluetooth Data

Problem Receiving Bluetooth Data

This question is answered
PhenomX
Posted by PhenomX
on Mar 23 2012 16:23 PM
Prodigy230 points

Hi,

So I have been able to connect an Android app to the MSP430BT5190+PAN1223 EMK. I am using a customized code from the "Simple" sample application found in the Ethermind SDK. I have the Idle Task which turns Bluetooth on and initializes the SPP profile. I also created a User Task (same priority as Idle Task) which loops indefinitely. The User Task blocks using semaphores when I delay for 2 seconds, and I am also forcing a context switch every time a loop completes. I have modified the Idle Task to yield only after the vApplicationHook() function has executed.

Bluetooth data is received by the callback function appl_spp_notify_cb() given a SPP_RECVD_DATA_IND event. Sometimes the program works fine, data is received and processed by SPP_RECVD_DATA_IND. Other times, even data is being sent successfully by the Android device, data is not received on the SPP_RECVD_DATA_IND end. I have noticed that when I put a breakpoint at that location, when Bluetooth connection is terminated by the Android device, SPP_RECVD_DATA_IND is executed. I have notice behaviors I have noticed:

1.) Connection is established, data is sent successfully and received by the MSP430 successfully.

2.) Connection is established, data is sent successfully and received. Ceases to work after a while. (I am using an MSP430BT5190 so there shouldn't be any connection timeout)

3.) Connection is established, data is sent successfully and but not received.

I have a couple of questions:

1.) Which task is executing the appl_spp_notify_cb callback function? Is the Idle Task which initialized the Bluetooth connection or is it the Read Task as implemented by the EtherMind SDK?

2.) I am almost certain I am not starving nor the Idle Task or the User Task, could I be starving any of the other Tasks?

The Android Bluetootph API seems to be very unstable so even tho according to their API data is being sent successfully, it could be the case that it is not. Any advice on this will be greatly appreciated.


Thanks in advance,

-Adrian

Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • srisenthilkumar chandrasekaran
    Posted by srisenthilkumar chandrasekaran
    on Mar 26 2012 23:42 PM
    Intellectual425 points

    appl_spp_notify_cb callback function is executed by Read Task, RX_ISR (msp430_uart.c) receives the event/data then those events are executed by read task.

    Read task should be higher priority, then write task, user task, idle task.

    change the user task priority in your application( it should be higher than idle task), and you can handle bluetooth on from user task or application specific init itself. configure your timerA for some ms(ex.180 ms) and release your user task semaphore every timerA isr. better dont use idle task for any specific functionalities,  those application specific function could be handled from user task itself(ex. appl_spp_data_send).

    Here the problem is somewhere tasks are held stuck, and worst case atleast you might have got UART ERROR in the receiver side. could you please check and let me know the status.

     

    Regards

     

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • PhenomX
    Posted by PhenomX
    on Mar 27 2012 08:50 AM
    Verified Answer
    Verified by PhenomX
    Prodigy230 points

    Hi,

    Thank you for you response and for the clarification of which task was running the application callback functions. Fortunately by tinkering around I found the root of my problem which came after a connection was initiated the by the Android Smartphone and the callback function was called with the SPP_CONNECT_IND event. Notice that after the connection is successfully established it sends data appl_send_spp_data(rem_bt_dev_index). I am thinking because I did not have the Android Smartphone setup to receive data, the connection was somehow being stalled. As soon as I commented that line out, the reception of data worked as expected. Refer to the piece of code below found in app_spp.c.

        case SPP_CONNECT_IND:
            sdk_initiator = FALSE;
            appl_spp_connected_indication();
            sdk_display("SPP_CONNECT_IND -> Connection Successful\n");
            sdk_display("Remote device BD_ADDR : %02X:%02X:%02X:%02X:%02X:%02X\n",
                        l_data[0], l_data[1], l_data[2], l_data[3], l_data[4],
                        l_data[5]);

            if (result == API_SUCCESS) {
                /* Save SPP Handle and Change State to SPP Connected */
                sdk_status[rem_bt_dev_index].spp_connection_handle = handle;
                SDK_SPP_CHANGE_STATE(rem_bt_dev_index, SDK_SPP_CONNECTED);
                /* Start sending the data */
                SDK_SPP_CHANGE_TX_STATE(rem_bt_dev_index, SDK_SPP_TX_ON);

                /**************************************************************
                 * No data to be sent after connection establishment
                 *************************************************************/
                //appl_send_spp_data(rem_bt_dev_index);
                /*************************************************************
                 * END
                 ************************************************************/

                /* To reflect the changes in the SPP cionnection to the user */
            }
            /* TBD: Reset state on failure */

            break;

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • srisenthilkumar chandrasekaran
    Posted by srisenthilkumar chandrasekaran
    on Mar 28 2012 01:35 AM
    Intellectual425 points

    Hi,

       Good !!!

    Search appl_send_spp_data function call in the workspace and commentout all the places. if the board initiates the connection then it will go to case SPP_CONNECT_CNF:

    Regards

    Senthil.


     

     

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • PhenomX
    Posted by PhenomX
    on Mar 28 2012 08:54 AM
    Prodigy230 points

    The android device will always initiate connection, and thus far I am only concerned with receiving data. Nonetheless I need to implement a receiving method in the Android side that would take care of the previous and also allow me to send data back and forth.

    Thank you very much for you input.

    -Adrian

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use