Class that implements the Bluetooth Classic specific communication and extends the AComm class.
More...
|
| | BTClassicConnection (long macAddress) |
| | Initialize new class instance based on macAddress. Bluetooth pairing with the printer is required before connecting. More...
|
| |
| | BTClassicConnection (string descriptor) |
| | Initialize new class instance based on descriptor string.
More...
|
| |
|
override void | Close () |
| | Closes a connection.
|
| |
|
override void | Open () |
| | Opens a connection.
|
| |
|
override byte[] | Read () |
| | Read all bytes available.
|
| |
|
virtual void | Read (BinaryWriter binDataIn) |
| | Reads all bytes available into the stream passed in.
|
| |
| virtual void | WaitForData (int msTimeOut) |
| | Waits until data available BytesAvailable in current thread. Current thread sleeps until data received or timeout reached. Blocking call.
More...
|
| |
| virtual void | Write (BinaryReader binReader) |
| | Write from input stream to output stream
More...
|
| |
|
override void | Write (byte[] dataOut) |
| | Writes all bytes from the array passed in.
|
| |
| virtual void | WriteAndWaitForResponse (BinaryWriter binDataIn, BinaryReader binDataOut, int responseStartTimeOut, int responseEndTimeOut, string completetionToken) |
| | Write binDataOut stream data to output stream and return data received in binDataIn stream. Data returned is any data received or up to completion token if received. Wait for response timeout before returning. More...
|
| |
| virtual byte[] | WriteAndWaitForResponse (byte[] dataOut, int responseStartTimeOut, int responseEndTimeOut, string completetionToken) |
| | Write byte data to output stream and return data received. Data returned is any data received or up to completion token if received. Wait for response timeout before returning. More...
|
| |
Class that implements the Bluetooth Classic specific communication and extends the AComm class.
Examples
using System;
using System.IO;
using System.Text;
namespace Snippets
{
class MyComm
{
public static void MainComm(string[] args)
{
SendPrintFile();
SendPrintString();
}
public static void SendPrintFile()
{
string fileName = @"C:\testFiles\Hello.pgl";
try
{
BTClassicComm.Open();
if (File.Exists(fileName))
{
using (BinaryReader binReader = new BinaryReader(File.Open(fileName, FileMode.Open)))
{
Console.WriteLine($"Sending \"{fileName}\" to printer");
BTClassicComm.Write(binReader);
}
}
else
{
Console.WriteLine($"File \"{fileName}\" not found");
}
}
catch (Exception e)
{
Console.WriteLine($"Exception Msg: {e.Message}");
}
finally
{
BTClassicComm.Close();
}
}
public static void SendPrintString()
{
string dataToPrint =
@"~CREATE;C39;72
SCALE;DOT
PAGE;30;40
ALPHA
C10;1;33;0;0;@HELLO@
C16;54;37;0;0;@*World*@
STOP
BARCODE
C128C;XRD3:3:6:6:9:9:12:12;H6;10;32
@World@
STOP
END
~EXECUTE;C39
~NORMAL
";
try
{
BTClassicComm.Open();
if (BTClassicComm.Connected)
{
byte[] outBytes = Encoding.ASCII.GetBytes(dataToPrint);
BTClassicComm.Write(outBytes);
}
else
{
Console.WriteLine($"Not connected to printer");
}
}
catch (Exception e)
{
Console.WriteLine($"Exception Msg: {e.Message}");
}
finally
{
BTClassicComm.Close();
}
}
}
}