BlueDongle to BlueSMiRF auto connection?

Hi

I am a newbie and have just managed to get the BlueDongle to talk and to listen to a remote BlueSMiRF.

I am using the Hyperterminal program wiht the following startup sequence which works:

ATUCL

ATDI,1,00000000

ATDM,,1101

and then start communicating.

Now I would like to automate this process.

I have tried putting these lines into a file and transfering a file using Hyperterminal- that did not work.

In the end I would like to use a VisualC++ program to start this up.

Now I have managed to send data using my VisualC++ program once the connection is started (wiht Hyperterminal). But I cant seem to get the

VisualC++ progrma to execute the above 3 lines.

Can someone please tell me what I should do from VC++ to execute even an “AT” command?

(I think I have a problem with the

Thank you in advance.

a.

Something like the following should get you started.

HANDLE com;
DCB state;
DWORD temp;
char buff[1024];

com = CreateFile("\\\\.\\COM10", // open COM10
		 CENERIC_READ|GENERIC_WRITE, // for reading and writing
		 0, // exclusively
		 NULL, // without security
		 OPEN_EXISTING, // don't re-create if not there
		 0, // regular, sequential access
		 NULL); // no template

if(INVALID_HANDLE_VALUE != com)
{
  GetCommState(com, &state); // get current port settings
  state.BaudRate = 9600;
  state.ByteSize = 8;
  state.Parity = NOPARITY;
  state.StopBits = ONESTOPBIT;
  SetCommState(com, &state); // set port settings to specified

  // port is now setup and ready for communication
  WriteFile(com, // port handle
	    "AT\r", // string to write, "\r" is CR
	    3, // number of bytes to write
	    &temp, // number of bytes written
	    NULL);
  if(3 != temp)
  {
    // something happened and all the data wasn't written...
  }

  ReadFile(com, // port handle
	   buff, // buffer to hold read data
	   3, // number of bytes to read
	   &temp, // will be filled in with the number of bytes read
	   NULL);

  // buff should now contain "OK\r"
  // do something with read data...

  CloseHandle(com); // close port
}
else // Unable to open COM port
{
  // how do we deal with it?
}

That given, why are you using VC++? I would look into using C# for something like this since it’s easy to learn if you know C++ or Java, and is easier to write code like this in.