Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to connect via bluetooth in xamarin forms ? #276

Open
maltiparmak opened this issue Jun 25, 2024 · 1 comment
Open

How to connect via bluetooth in xamarin forms ? #276

maltiparmak opened this issue Jun 25, 2024 · 1 comment

Comments

@maltiparmak
Copy link

maltiparmak commented Jun 25, 2024

Hello all,
I have sunmi v2s plus device and it has thermal printer. I'm working on it for a while but I can't print image. I tried this library but I can't connect to my thermal printer. I'm using this code below to connect and print.
`using (BluetoothAdapter bluetoothAdapter = BluetoothAdapter.DefaultAdapter)
{
BluetoothDevice device = (from bd in bluetoothAdapter?.BondedDevices
where bd?.Name == deviceName
select bd).FirstOrDefault();
try
{
// "00001101-0000-1000-8000-00805f9b34fb" is common UUID for printer & scanner.
using (BluetoothSocket socket = device?.CreateRfcommSocketToServiceRecord(UUID.FromString("00001101-0000-1000-8000-00805F9B34FB")))
{

socket?.Connect();

//Print issues

socket.Close();
}
}
catch (Exception ex)
{
throw ex;
}`

I can't figure out how to connect via this library .
// USB, Bluetooth, or Serial var printer = new SerialPrinter(portName: "COM5", baudRate: 115200);
How can I connect my thermal printer with this library ? I don't have any port or IP adress.

@igorocampos
Copy link
Collaborator

In #51 you can check the conversation about that. But currently you would have to manually open the socket (as you are already doing) and then send all bytes to it. You can still use this library to generate the bytes you need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants