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
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
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;
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:
Senthil.
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.