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;
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;
解决方案 »
- 谁能给个内存加载dll的代码?
- 初学Delphi,该掌握多少Pascal知识?
- 关于anywhere数据库中存储Image的问题
- 怎么控制ToolButton?
- ★★Delphi操作Excel的问题,与网上的文章有不同★★
- 按回车键后如何使combobox控件自动弹出内容
- 关于Trojan Horse病毒!
- 如何彻底删除dbase/foxpro数据库里的记录(不是带删除标记的那种),要求用ado连接,问了一个星期了都没人回答,难道真的不能实现这个功能
- 大家有没有用过String数组来读取文件流?
- 如何获得窗口button句柄并模拟鼠标点击?
- delphi 7 如何写 修改切换win7 系统 的ip4 网关 dns等
- stringlist的疑难杂症啊!
FSocket.SendData(ToSend);
DisplayR.Lines.Add('Text Sent');
这几句操作成功后,为什么手机收不到消息呢有什么方式可以 向手机或者其他接收设备 发送字符 或者文件呢