1

I am trying to make a LabWindows/CVI program that talks with SPBT2632C2A Bluetooth chip. I am using a st eval spbt3atv3 dongle. I am trying to push a button and send a command to chip, but chip do not answer to me. I know my LabWindows program can receive messages from dongle, because every time I press reset button on dongle it shows me the boot up message. As I searched I need to add \n\r to end of my string, but it still didn't work. Chip does not send even error message.

CODE

int CVICALLBACK rasti (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
    switch (event)
    {
        case EVENT_COMMIT:
              sprintf(discovery,"AT+AB discovery\n\r");
              if(ComWrt (4,discovery, 18)!= 18){
                 SetCtrlVal (panelHandle, PANEL_TEXTBOX, "Nesekmingas duomenu siuntimas");
                                                        //Unsuccessful sending data
              }
              else {
                  SetCtrlVal (panelHandle, PANEL_TEXTBOX, discovery); 
              }

            break;
    }
    return 0;
}

It's event called by button. It appends my discovery string to text box. So I think it's sending data correctly to serial port. But I think my string is wrong so I don't get the answer from chip.

Any ideas how to solve this to get responses from chip?

ryyker
  • 22,849
  • 3
  • 43
  • 87
  • 1
    "It's my first question so don't eat my alive" - So we should deep fry you first? - Seriously: Read [ask]. We don't even know it's not a hardware problem. – too honest for this site Nov 29 '16 at 11:17
  • Oh forgot to mention. With hyperterminal it works fine. So no it's not hardware problem. – user6825345 Nov 29 '16 at 11:54
  • `\n\r` doesn't seem good. Try `\r` alone, or maybe `\r\n`, but not `\n\r`. – linuxfan says Reinstate Monica Jan 27 '17 at 17:32
  • If you talk using the Bluetooth protocol, it sends data in several packets, so it is not always continuous. You need to buffer all the packets received in your receiving loop until it reaches a terminating character (a part of the full message) so you can rebuild the packets to form the message again. – ecle Oct 25 '20 at 11:30
  • You may also need to check if the dongle needs some control lines like DTR/DSR or CTS/DTS to be high. – ecle Oct 25 '20 at 11:35

1 Answers1

1

Make sure to call OpenComConfig with the correct parameters before invoking ComWrt. You can look for the correct port settings in the Hyperterminal (since you mentioned it communicates correctly with the device). Refer to NI's documentation for more on this.

Also, trying different types of line termination characters might help (try using \r\n, \n or \r).

Daniel
  • 144
  • 1
  • 9