Witam,
wykorzystuję aplikację (Delphi XE7)
C:\Users\Public\Documents\Embarcadero\Studio\15.0\Samples\Object Pascal\Mobile Samples\Device Sensors and Services\Bluetooth\Classic Bluetooth Basic app
do przesyłania tesktu między połączonymi przez bluetooth urządzenami (android, Windows)
Poniższy kod odbiera dane przesyłane z innego urządzenia.
Wiem jak długi teskt przesyłam
ShowMessage(IntTOStr(length(FData)));
ale przy próbie odczytu danych, zwracany jest pusty ciąg znaków.
Form1.DisplayR.Lines.Add(TEncoding.UTF8.GetString(FData));
Czy spotkaliście się z takim problemem?
procedure TServerConnectionTH.execute;
var
ASocket: TBluetoothSocket;
Msg: string;
begin
while not Terminated do
try
ASocket := nil;
while not Terminated and (ASocket = nil) do
ASocket := FServerSocket.Accept(100);
if(ASocket <> nil) then
begin
FSocket := ASocket;
while not Terminated do
begin
FData := ASocket.ReadData;
ShowMessage(IntTOStr(length(FData)));
if length(FData) > 0 then
Synchronize(procedure
begin
Form1.DisplayR.Lines.Add(TEncoding.UTF8.GetString(FData));
Form1.DisplayR.GoToTextEnd;
end);
sleep(100);
end;
end;
except
on E : Exception do
begin
Msg := E.Message;
Synchronize(procedure
begin
Form1.DisplayR.Lines.Add('Server Socket closed: ' + Msg);
Form1.DisplayR.GoToTextEnd;
end);
end;
end;
end;