Delphi xe 10官方的经典蓝牙的demo问题
Classic Bluetooth Basic app的demo,我初学delphi,发现就是改了uuid之后可以连接我的蓝牙设备,并且向蓝牙设备发送数据,但是蓝牙设备向我手机app发送数据收不到,如果在发送数据后 LData := FSocket.ReceiveData(100);这里面设定时间后可以采集到数据,如果不设定时间是一直采集的意思吗?我看到demo里面有在连接的时候创建一个进程来一直获取蓝牙接收数据,但是不知道怎么的并没有跑这段,进程这里看不大明白,这里是创建进程来捕捉蓝牙数据,问了高手说是可以用hook的方式来接收数据,但都不明白,有没有高手可以解释下:
demo路径:
radstudiodemos-code-2026-branches-RADStudio_Berlin\Object Pascal\Multi-Device Samples\Device Sensors and Services\Bluetooth\Classic Bluetooth Basic app
代码:
procedure TServerConnectionTH.Execute;
var
Msg: string;
LData: TBytes;
begin
while not Terminated do
try
FSocket := nil;
while not Terminated and (FSocket = nil) do
FSocket := FServerSocket.Accept(100);
if(FSocket <> nil) then
begin
while not Terminated do
begin
LData := FSocket.ReceiveData;
if Length(LData) > 0 then
Synchronize(procedure
begin
Form1.DisplayR.Lines.Add(TEncoding.UTF8.GetString(LData));
Form1.DisplayR.GoToTextEnd;
end);
Sleep(100);
end;
end;
except
on E : Exception do
begin
Msg := E.Message;
Synchronize(procedure
begin
Form1.DisplayR.Lines.Add('服务器端口关闭: ' + Msg);
Form1.DisplayR.GoToTextEnd;
end);
end;
end;
end;