아두이노 블루투스 모듈과 통신이 필요합니다
void __fastcall TForm1::Button2Click(TObject *Sender)
{
int a=ListBox1->ItemIndex;
if(blue->IsPaired(blue->PairedDevices()->Items[a]))
{
TBluetoothServiceList *service = blue->LastServiceList(blue->PairedDevices()->Items[a]);
soc = blue->CreateClientSocket(blue->PairedDevices()->Items[0],service->Items[0].UUID,false);
soc->Connect();
ShowMessage(u"Pairing Completed.");
}
else
{
ShowMessage(u"Pairing Failed.");
}
}
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
if(x==1)
{
try
{
TBytes bytes=soc->ReceiveData();
Memo1->Lines->Add(TEncoding::UTF8->GetString(bytes));
}
catch(...)
{
//수신이 제대로 되지 않을떄
}
}
}
에러가 read failed, socket might closed or timeout, read ret -1; 이라 나옵니다
soc->Connect();를 지우니깐 되는데 뭐가 문제인가요
|