title: Connect via Bluetooth with Delphi XE7 using portable printer
body: <p>I'm trying to communicate with a <strong>Sewoo LK-P32</strong> printer via Bluetooth. For this, I am using <strong>Delphi XE7</strong>. I made a few examples that come with Delphi and am not having success. I put the paired printer on tablet and even then I am not able to print continuously.</p>
  
  <p>When I print something have to restart the application, so I can print something again. Below my sources.</p>
  
  <p>Could someone help me? Support on this issue? My time is short to try other technologies.</p>
  
  <p>Method that initiates communication with the printer</p>
  
  <pre><code>procedure TForm2.ButtonClickStart(Sender: TObject);
  var
    Msg, Texto: string;
    I, B: Integer;
    BluetoothAdapter: TBluetoothAdapter;
    ListaDeAparelhosPareados: TBluetoothDeviceList;
    LServices: TBluetoothServiceList;
  begin
    try
      Memo1.Lines.Add('Ponto 1');
      FBluetoothManager := TBluetoothManager.Current;
      if FBluetoothManager = nil then
        Memo1.Lines.Add('FBluetoothManager esta nulo');
  
      Memo1.Lines.Add('Ponto 2');
      BluetoothAdapter := FBluetoothManager.CurrentAdapter;
      if BluetoothAdapter = nil then
      Memo1.Lines.Add('BluetoothAdapter esta nulo');
  
      ListaDeAparelhosPareados := BluetoothAdapter.PairedDevices;
      Memo1.Lines.Add('Ponto 3');
      if ListaDeAparelhosPareados = nil then
        Memo1.Lines.Add('ListaDeAparelhosPareados esta nulo');
  
      for I := 0 to ListaDeAparelhosPareados.Count - 1 do
      begin
        LDevice := ListaDeAparelhosPareados[I] as TBluetoothDevice;
        if LDevice.IsPaired then
        begin
          LServices := LDevice.GetServices;
          for B := 0 to LServices.Count - 1 do
          begin
            ServiceGUI := GUIDToString(LServices[B].UUID);
            Guid := LServices[B].UUID;
            ServiceName := LServices[B].Name;
            Memo1.Lines.Add(LServices[B].Name + ' --&gt; ' + ServiceGUI);
            Memo1.GoToTextEnd;
          end;
        end;
      end;
    except
     on E: Exception do
     begin
       Msg := E.Message;
       Memo1.Lines.Add('Erro ao Conectar na Impressora: ' + Msg);
       Memo1.GoToTextEnd;
     end;
   end;
  end;
  </code></pre>
  
  <p>The method that sends the text to the printer</p>
  
  <pre><code>procedure TForm2.ButtonClickSendText(Sender: TObject);
  var
    FSocket: TBluetoothSocket;
    ToSend: TBytes;
    Msg, Texto: String;
  begin
    try
      Memo1.Lines.Add('Aparelho pareado:' + BoolToStr(LDevice.IsPaired));
  
      Memo1.Lines.Add('Dados do Guid:' + GUIDToString(Guid));
      FSocket := LDevice.CreateClientSocket(Guid, true);
      if FSocket = nil then
      Memo1.Lines.Add('FSocket nulo');
  
      Memo1.Lines.Add('Criou Bluetooth Cliente.');
      Memo1.GoToTextEnd;
      if FSocket &lt;&gt; nil then
      begin
        // FSocket.Connect;
        FSocket.Connect;
        Memo1.Lines.Add('Criou socket cliente com o ServerSocket');
        Texto := #27 + '|cA' + 'Teste' + #13#10;
        ToSend := TEncoding.UTF8.GetBytes(Texto);
        FSocket.SendData(ToSend);
        Memo1.Lines.Add('Enviou ' + Texto + ' para a impressora.');
      end
      else
      begin
        Memo1.Lines.Add('FSocket nulo.');
      end;
  
    except
      on E: Exception do
      begin
        Msg := E.Message;
        Memo1.Lines.Add('Erro ao Conectar na Impressora: ' + Msg);
        Memo1.GoToTextEnd;
      end;
    end;
  end; 
  </code></pre>