This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Change the original behaviour of S2 button in EZ430-RF2560 kit

Dear all,

 

I have a EZ430-RF2560 kit and I want to change the original behaviour of the S2 button.

I  have changed the code in the file appl_sdk.c for the appl_acceleromenter_read_spp_send() function

to send the string "Hello world", this modification works pretty good, but I receive the string in a continuative way on my serial.

I would to receive it once every time the button S2 is pushed.

I' ve looked in the appl_menu_pl.c and in appl_sdk.c files but seems I can't fix the problem. 

 

Can you help me ?

 

Thanks a lot.

 

Regards

 

Netmastro

  • Net Mastro,

     

    The reason you see this constantly is because several of the applications for the EZ430-RF2560 are set up to respond to data received by sending data. This means a sort of ping pong behavior. If you do CTRL+SHIFT+F you can search the project for all calls to appl_send_spp_data(...).

    For example:

    case SPP_SEND_CNF:
            sdk_display("SPP_SEND_CNF -> Sent successfully\n");

            if (SDK_IS_SPP_CONNECTED(rem_bt_dev_index)
                && SDK_IS_SPP_TX_STARTED(rem_bt_dev_index)) {
                if (L2CAP_TX_QUEUE_FLOW_ON == appl_l2cap_tx_buf_state) {
                    //appl_send_spp_data(rem_bt_dev_index);
                } else {
                    SDK_SPP_CHANGE_DATA_STATE(rem_bt_dev_index, TRUE);
                }
            }
            break;

     

    As you can see here, I've commented out the line appl_send_spp_data(rem_bt_dev_index);

     

    You will need to disable the same in the cases SPP_CONNECT_CNF and SPP_CONNECT_IND.

     

    Gustavo

  • Hi Gustavo,

     

    thanks for the prompt reply. I have followed your instructions and in part I have solved my problem; now I receive

    correctly the "Hello world" once on my serial but every two push of the button, I think the reason is that the original

    code start to transmit the the accelerometer buffer at first push of the button and stop to transmit it with the second one.

     

    Infact in the file appl_sdk.c at row 141 I found :

     

            /* Dtasend stop and pause toggle button presses */

            if (SDK_IS_SPP_CONNECTED(0)) {

                if (SDK_IS_SPP_TX_STARTED(0)) {

                    /* Stop Sending Data */

                    SDK_SPP_CHANGE_TX_STATE(0, SDK_SPP_TX_OFF);


                } else {

                    /* Start Sending Data */

                    SDK_SPP_CHANGE_TX_STATE(0, SDK_SPP_TX_ON);

                    appl_acceleromenter_read_spp_send(0);

                }

     

    how can modify it to send the string every time I push the S2 button ?

    Thanks in advance

     

    Netmastro

     

    P.S. Only a clarification for the other people could need this thread; my code under case SPP_SEND_CNF in the appl_spp.c file was a bit different :

     

     case SPP_SEND_CNF:

            printf("SPP_SEND_CNF -> Sent successfully\n");


            if (SDK_IS_SPP_CONNECTED(rem_bt_dev_index)

                && SDK_IS_SPP_TX_STARTED(rem_bt_dev_index)) {

                if (L2CAP_TX_QUEUE_FLOW_ON == appl_l2cap_tx_buf_state) {

                    //appl_acceleromenter_read_spp_send(rem_bt_dev_index);

                } else {

                    SDK_SPP_CHANGE_DATA_STATE(rem_bt_dev_index, TRUE);

                }

            }

            break;

     

    and didn't found appl_acceleromenter_read_spp_send(rem_bt_dev_index); under SPP_CONNECT_CNF and SPP_CONNECT_IND cases.

  • Hi,

     

    I have fixed in this way :

     

           /* Dtasend stop and pause toggle button presses */

            if (SDK_IS_SPP_CONNECTED(0)) 

    {

    /* Start Sending Data */

                    SDK_SPP_CHANGE_TX_STATE(0, SDK_SPP_TX_ON);

                    appl_acceleromenter_read_spp_send(0);

                /*if (SDK_IS_SPP_TX_STARTED(0)) 

    {

                    // Stop Sending Data 

                    SDK_SPP_CHANGE_TX_STATE(0, SDK_SPP_TX_ON);


                } 

    else 

    {

                    // Start Sending Data 

                    SDK_SPP_CHANGE_TX_STATE(0, SDK_SPP_TX_ON);

                    appl_acceleromenter_read_spp_send(0);

                }*/

     

     

    Regards.


    Netmastro