GithubHelp home page GithubHelp logo

inthehand / 32feet Goto Github PK

View Code? Open in Web Editor NEW
802.0 48.0 202.0 9.05 MB

Personal Area Networking for .NET. Open source and professionally supported

Home Page: https://inthehand.com/components/32feet/

License: MIT License

C# 92.68% HTML 2.43% Batchfile 0.38% C++ 0.65% C 0.19% Visual Basic .NET 3.67%
bluetooth dotnet windows-desktop net-standard nuget windows-phone irda compact-framework xamarin xamarin-android

32feet's Introduction

32feet.NET - Personal Area Networking for .NET

32feet.NET is an open-source project to make personal area networking technologies such as Bluetooth, Infrared (IrDA) and more, easily accessible from .NET code. Supports desktop, mobile or embedded systems. 32feet.NET is free for commercial or non-commercial use. If you use the binaries you can just use the library as-is, if you make modifications to the source you need to include the 32feet.NET License.txt document and ensure the file headers are not modified/removed. The project currently consists of the following libraries:-

  • Bluetooth Classic
  • Bluetooth LE
  • Bluetooth Permissions for Xamarin.Forms and .NET MAUI
  • IOBluetooth/IOBluetoothUI bindings for Xamarin Mac
  • IrDA
  • Object Exchange (Obex)

Bluetooth support requires .NET Framework v4.6.1 or later for desktop Windows 7, 8, 10 and 11. Android and Apple macOS and iOS are also supported using Xamarin or .NET 6.0 and above. Full platform information is listed in the Wiki.

Support 32feet

Documentation / Tutorial

The user guide is available in the Wiki section. Please start by reading it. It contains general information firstly on the various features contained in the library, and on what type of Bluetooth connection you want. It also contains information on using each feature.

Detailed API documentation is available at https://inthehand.github.io/.

Downloading

Downloads are available here on the Downloads tab. Packages are also available at NuGet:-

  • InTheHand.Net.Bluetooth - Bluetooth Classic (v4.x) NuGet version

  • InTheHand.BluetoothLE - Bluetooth Low Energy (v4.x) NuGet version

  • InTheHand.Bluetooth.Permissions - Bluetooth Permissions for .NET MAUI 7.0 and Xamarin.Forms NuGet version

  • InTheHand.IOBluetooth - IOBluetooth bindings for Xamarin Mac NuGet version

  • InTheHand.IOBluetooth - IOBluetoothUI bindings for Xamarin Mac NuGet version

  • InTheHand.Net.IrDA (v4.x) NuGet version

  • InTheHand.Net.Obex (v4.x) NuGet version

  • 32feet.NET - Legacy (v3.x) NuGet version

Blogs

Alan's 32feet.NET Development Blog

Peter's Blog

Sponsors

Thanks to our GitHub Sponsors

Many thanks to NDepend for their support. Many thanks to Aton Spa (Italy) for commissioning and funding the implementation of StoneStreet One Bluetopia support.

Contributors

Made with contrib.rocks.

32feet's People

Contributors

brofloyd avatar dependabot[bot] avatar forlayo avatar freewing-jp avatar igiona avatar jcs090218 avatar mfmeisinger avatar msalandro avatar mx0c avatar peterfoot avatar polipo avatar qmfrederik avatar stephen-systemfriend avatar suisse00 avatar sydneyowl avatar travisro avatar tylersouthard avatar yanis131 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

32feet's Issues

Reading and writing to BLE Characteristics through Unity

Hi Peter,

I'm working with some Bluetooth Low Energy ESP32 boards and trying to access them through Unity.
I saw a sample of code that you made to show printing from RfcommService from within Unity: https://gist.github.com/peterfoot/ea07a026a6c9d978fd0f27c2431bc745

Was hoping for something similar for Bluetooth Low Energy. The current sample only shows paired devices.
Have been using this Microsoft BLE Explorer UWP app for testing (https://github.com/Microsoft/BluetoothLEExplorer), but we need to be able to read and write the services and characteristics within Unity.

These are some samples of the kind of code running on the boards:
https://github.com/nkolban/ESP32_BLE_Arduino/blob/master/examples/BLE_uart/BLE_uart.ino

Any help with this would be greatly appreciated.

Thanks,
Lloyd McInnes

ObexListenerRequest getting multiple files

Hello, first time working with Obex and bluetooth applications.
Using one of the examples I'm able to create a thread with a ObexListener running and getting requests from a device sending a file.
In some occasions however I can get multiple files in the same request, and i'm not able to get this working, the COUNT Header contains the number of files to be received, but only the first file is processed and saved.

In the Wiki I read that with Brecham.Obex I will be able to receive multiple files in the same session, but I can't figure out how to make a Brecham.Obex server or listener waiting for incoming connections.

Is it possible to use InTheHand.Net.ObexListener as server for incoming connections and use Brecham.Obex to transfer the actual files?
Or is there a better way to do this?

Thank you

Fix code blocks in Wiki

Hi,

almost all the code examples in the wiki are in the wrong format. Can someone fix them?

Some example are the OBEX page and all its subpages.

Missing Xamarin.Forms examples

As a user, I was looking for fast and effective examples using the Xamarin.Forms samples provided. However, the samples in the folder Samples\BluetoothFormsApp do not reference Bluetooth at all, they are the empty Visual Studio projects.

Can we have a complete 2-way chat sample for the Xamarin.Forms projects? Thank you.

How to determine if a bluetooth adapter is bluetooth 4.0 compatible

We're working with a device that requires bluetooth 4.0... it's been given us connection problems until we realized the bluetooth radio is an old bluetooth 2.0 adapter.

Is there a way of knowing if a bluetooth adapter is 4.0?

In particular, I am interested in the LMP version.

Looking at the code, I've notice in the Win32 platform code, there's a _radioInfo structure that contains a lmpSubversion field... but where is the major version?

Could these values be exposed in the public API ?

from the LMP I can get the bluetooth version:

LMP 9.x – Bluetooth 5.0
LMP 8.x – Bluetooth 4.2
LMP 7.x – Bluetooth 4.1
LMP 6.x – Bluetooth 4.0
LMP 5.x – Bluetooth 3.0 + HS
LMP 4.x – Bluetooth 2.1 + EDR
LMP 3.x – Bluetooth 2.0 + EDR
LMP 2.x – Bluetooth 1.2
LMP 1.x – Bluetooth 1.1
LMP 0.x – Bluetooth 1.0b

thanks

MONO compatibility

Hi,
Is it compatible with MONO and, maybe, with Raspberry PI 3 Bluetooth on board device?

Thanks
Leo

Detection of BLE capable hardware

Is it possible to use this library to detect BLE capable hardware on the host machine. I looked at the documentation for the Radio class looks like it can only indicate Bluetooth but not BLE.

BC30002 Type 'BluetoothListener' is not defined. Chat2DesktopVb

Hi,

I'm working on a vb.net PC program that hopefully will connect to a few Bluetooth modules and will exchange data back and forth with them. This program Chat2DesktopVb looks like a good start for my project. I am trying to compile this program in ..\32feet-master\Samples\BluetoothChat2\Chat2Desktop, but I'm getting a bunch of these BC30002 errors. I'm sure this is an easy question for you guys. Any help is greatly appreciated.

Thank you,

Robert

Is there any way to get the COM port for a ServiceRecord?

Lets say i have the following code:

var client = new BluetoothClient();
Console.WriteLine("DiscoverDevices");
var devices = client.DiscoverDevices();
foreach(var device in devices)
{
    foreach(var serviceRecord in device.GetServiceRecords(BluetoothService.SerialPort))
    {
        //Get comport for ServiceRecord
    }
}

How would i get the Com Port? (If i look in the bluetooth dialog i can see that the device has multiple COM ports).

AcceptBluetoothClient works sporadically

Hi the Net.Sockets.BluetoothListener's AcceptBluetoothClient method works sometimes but on other occasions it just doesn't detect the connection even though my phone has established the connection.
The code can be found here:
https://stackoverflow.com/questions/45608067/32feet-acceptbluetoothclient-method-not-detecting-connection
After i posted that, it worked on one occasion, i have no idea why, but it stopped working once I restarted. Any idea what might be the problem?

Thanks in advance

System.AccessViolationException

Hi i got the following exception and i have no idea what triggerd it.
Do you have any idea?

System.AccessViolationException vid
System.Runtime.InteropServices.Marshal.ReadByte(IntPtr, Int32) vid
InTheHand.Net.Bluetooth.Msft.SocketBluetoothClient.DoDiscoverDevices(Int32, Boolean, Boolean, Boolean, Boolean, LiveDiscoveryCallback, System.Object) vid
InTheHand.Net.Bluetooth.Msft.SocketBluetoothClient.DiscoverDevices(Int32, Boolean, Boolean, Boolean, Boolean, LiveDiscoveryCallback, System.Object) vid
InTheHand.Net.Bluetooth.Msft.SocketBluetoothClient.InTheHand.Net.Bluetooth.Factory.IBluetoothClient.DiscoverDevices(Int32, Boolean, Boolean, Boolean, Boolean) vid
...

HFP receive audio

I'm trying to implement a PC app that allows a user to answer a phone calls via PC. I've implemented a Bluetooth HFP profile (can dial a number, completed codec initiation phase, etc), but stuck on creating an audio channel. If I understand this specification correctly, HFP consists of 2 connections: control channel and audio channel.
How to connect to audio channel after codec negotiation phase using this library?

newb: SocketException An invalid argument was supplied

Hi
I'm totally new to bluetooth and 32feet
I have a few devices that windows 7 recognizes and pairs correctly (though i havent progressed further then the pairing)
but in 32feet, all devices cause the following error

System.Net.Sockets.SocketException: An invalid argument was supplied 103047170F76:xxxxxxxx....

the error code is 10022

and here is the stacktrace

at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at InTheHand.Net.Bluetooth.Msft.SocketBluetoothClient.Connect(BluetoothEndPoint remoteEP) in C:\Users\CEO\Downloads\32feet-master\32feet-master\InTheHand.Net.Personal\Net.Bluetooth.Msft\SocketBluetoothClient.cs:line 698
at InTheHand.Net.Sockets.BluetoothClient.Connect(BluetoothEndPoint remoteEP) in C:\Users\CEO\Downloads\32feet-master\32feet-master\InTheHand.Net.Personal\Net.Sockets\BluetoothClient.cs:line 414
at InTheHand.Net.Sockets.BluetoothClient.Connect(BluetoothAddress address, Guid service) in C:\Users\CEO\Downloads\32feet-master\32feet-master\InTheHand.Net.Personal\Net.Sockets\BluetoothClient.cs:line 447
at Chat2DesktopVb.Form1.BluetoothConnect(BluetoothAddress addr) in C:\Users\CEO\Downloads\32feet-master\32feet-master\Samples\BluetoothChat2\Chat2DesktopVb\Form1Core.vb:line 73
at Chat2DesktopVb.Form1.menuItemConnectBySelect_Click(Object sender, EventArgs e) in C:\Users\CEO\Downloads\32feet-master\32feet-master\Samples\BluetoothChat2\Chat2DesktopVb\Form1Core.vb:line 290
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at Chat2DesktopVb.My.MyApplication.Main(String[] Args) in :line 81

I tried stopping and starting the bluetooth service in windows
also device manager shows that the drivers for both bluetooth devices (genereic bluetooth radio and microsoft bluetooth enumerator) are up to date

what may thge issue be?

thanks

InvalidOperationException in BluetoothComponent.HandleDiscoNewDevice

I have seen a couple of crashes with the following stack trace.

System.InvalidOperationException: This operation has already had OperationCompleted called on it and further calls are illegal.
   at System.ComponentModel.AsyncOperation.VerifyNotCompleted()
   at System.ComponentModel.AsyncOperation.Post(SendOrPostCallback d, Object arg)
   at InTheHand.Net.Bluetooth.BluetoothComponent.HandleDiscoNewDevice(IBluetoothDeviceInfo newDevice, Object state)
   at InTheHand.Net.Bluetooth.Msft.SocketBluetoothClient.<>c__DisplayClass2.<DiscoverDevices>b__0(Object sender, BluetoothWin32RadioInRangeEventArgs e)
   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   at InTheHand.Net.Bluetooth.BluetoothWin32Events.OnInRange(BluetoothWin32RadioInRangeEventArgs e)
   at InTheHand.Net.Bluetooth.BluetoothWin32Events.DoDevTypHandle(Message& m, String& text)
   at InTheHand.Net.Bluetooth.BluetoothWin32Events.DoBroadcastHdr(Message m)
   at InTheHand.Net.Bluetooth.BluetoothWin32Events.HandleMessage(Message& m)
   at InTheHand.Net.Bluetooth.BluetoothWin32Events.BtEventsForm.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

The exception is not easy to reproduce and looking at the code it looks like a race condition. I was not able to isolate what is causing this, but its likely related to calling BluetoothComponent.DiscoverDevicesAsync

Its on Windows 10 x64 1809, InTheHand.Net.Personal, Version=3.5.605.0 (via nuget)

Investigate pairing problems on Windows 10

PairRequest doesn't appear to be working successfully and OS will pop up a notification that connection failed. It appears that calling SetPin first is successful so that may be a workaround before a fix can be applied.

Handsfree and Headset profiles issues

I use BlueSoleil in my C# project but I notice different issues using Handsfree or Headset profiles.

If I use Headset profile (BluetoothService.Headset): the connection is reliable, I can only read message and not send it. If I use Handfree profile (BluetoothService.Handsfree): I can send message to dial a number, but after a few seconds the comunication goes down.

What is the better profile to dial number, hang-up and more?

Platform not supported exception in Unity : 32feet.NET not supporting bluetooth stack

I have been trying to connect to BioRadio device through bluetooth. My code works on visual studio and collects the required data after bluetooth connection. When I try to run it from Unity, it does not work and gives the exception error of 32feet.NET. I did add the nuget package from the references tab in visual studio but it still shows the same error. I am new to Unity and using bluetooth through visual studio.
Would anyone help to understand step by step how to resolve it ?

Underlying socket not closed on win32

When using InTheHand.Devices.Bluetooth on Windows 10 RfcommDeviceService.OpenStream does not create the NetworkStream with ownership of the Rfcomm socket. This means the socket is not closed when the stream is closed. At the moment I need to either use a wrapper class or call the socket Close method through reflection. I suspect this may apply to more than just the windows version.

PairRequest always return false when I try to pair bluetooth mouse

Hi,
I am using 32feet to discover a bluetooth mouse and try to pair and connect to it, but the PairRequest always return false. The device class is "miscellaneous". The function HandleRequests is not executed too.
The following is my code. Hope to get you answer, thank you!

EventHandler handler = new EventHandler(HandleRequests);
BluetoothWin32Authentication auth = new BluetoothWin32Authentication(handler);

protected void PairBluetoothTask(BluetoothDeviceInfo device)
{
bool isPaired = BluetoothSecurity.PairRequest(device.DeviceAddress, null);
if (isPaired)
{
Console.WriteLine(device.DeviceName + " paired!");
}
else
{
Console.WriteLine(device.DeviceName + " not paired!");
}
}

private void HandleRequests(object that, BluetoothWin32AuthenticationEventArgs e)
{
e.Confirm = true;
}

Fix all code blocks in Wiki

Imported markdown from CodePlex uses {{ around code blocks which is not displayed correctly. Correct format for GitHub is

    ```cs
    //some c# code
    ```

BluetoothRadio.PrimaryRadio return null?

Windows 7 64bit,VS2010,use InTheHand.Net.Personal.dll
bluetooth device : CSR Bluetooth Radio

BluetoothRadio myRadio = BluetoothRadio.PrimaryRadio;

the myRadio return null?

API Document:
For Windows CE based devices this is the only BluetoothRadio, for Windows XP this is the first available BluetoothRadio device.
If the device has a third-party stack this property will return null

is the CSR Bluetooth Radio is third-party stack ?

BluetoothClient client = new BluetoothClient(); also is error

DiscoverDevices API can't be run。

please help to find what error ,thanks

32feet not working in pbap mode

I'm trying to use 32feet library to get the phonebooks and I see that not exists obex negotiation to do this.

if (uri.Scheme == SchemeNames.Ftp) {
    connectPacket = new byte[] { 0x80, 0x00, 26, 0x10, 0x00, 0x20, 0x00, 0x46, 0x00, 19, 0xF9, 0xEC, 0x7B, 0xC4, 0x95, 0x3C, 0x11, 0xD2, 0x98, 0x4E, 0x52, 0x54, 0x00, 0xDC, 0x9E, 0x09 };
} else {
    connectPacket = new byte[7] { 0x80, 0x00, 0x07, 0x10, 0x00, 0x20, 0x00 };
}

And for pbap, would be (I think):
connectPacket = new byte[] { 0x80, 0x00, 26, 0x10, 0x00, 0x20, 0x00, 0x46, 0x00, 19, 0x79, 0x61, 0x35, 0xF0, 0xF0, 0xC5, 0x11, 0xD8, 0x09, 0x66, 0x08, 0x00, 0x20, 0x0C, 0x9A, 0x66 };

Can you add, please?

Can't disconnect a bluetooth connection

Hi,
I am using 32feet in Windows. I use BluetoothClient.close to disconnect from a device, but it has no effect.
My code is like following, hope to get your answer.

BluetoothClient client = new BluetoothClient();
void Connect()
{
BluetoothEndPoint ep = new BluetoothEndPoint(device.DeviceAddress, BluetoothService.Handsfree);
client.Connect(ep);
//check connection
}
void Disconnect()
{
client.Close();
client.Dispose();
}

BLE support

32feet is a very good library, and i have used this for many years, vv thanks.

but 32feet currently only supports classic bluetooth. NOW more and more BLE devices.
so, is plan to add BLE support?

¿ObexClientSession.put is not working?

Hi, i'm having problems puting file with Obex over serial port.

ObexClientSession sess = new ObexClientSession(sp.BaseStream, 600);
ObexHeaderCollection headers = new ObexHeaderCollection();
headers.Add(ObexHeaderId.Count, 1);
ObexParsedResponsePdu intResp = sess.Connect(headers);
if (intResp.ResponseCode != ObexResponseCode.Success)
using (FileStream src = File.OpenRead(file.FullName))
{
	Logger.ToLog("Copying file " + file.Name + "  " + (int)(src.Length / 1024) + " KB ");
	String name = Path.GetFileName(file.Name);
	DateTime start = DateTime.UtcNow;
	sess.PutFrom(src, name, null, src.Length);
	TimeSpan ts = DateTime.UtcNow - start;
	double bps = ((src.Length / ts.TotalMilliseconds) * 1000);
	Logger.ToLog("Copied in " + (int)ts.TotalSeconds + " s at " + (int)bps + " Bps");
}

sess.PutFrom not "block" the execution and only create the file but don't fill the file.

Bonded devices are not retained on Windows 10

I'm using classic Bluetooth to communicate between an Android app and a WPF application. The initial pairing process has been a major pain point when onboarding new users. My plan to simplify the pairing process is to provide custom dialogs inside the app (via InTheHand.Net.Bluetooth.BluetoothWin32Authentication). However, devices paired in this way are not retained by the Windows 10 system. Every connection leads to a pairing request.

  1. Connect from Android app directly to the desktop using the Bluetooth device address
  2. If the devices haven't been paired, Android initiates a pairing request.
  3. The desktop uses the InTheHand.Net.Bluetooth.BluetoothWin32Authentication and a custom dialog to present the pairing passcode and allow the user to confirm.
  4. I complete the pairing process on both devices, then the connection is establish and the applications communicate properly.
  5. Close the connection
  6. Try to re-establish the connection from the Android app.
  • From the Android OS perspective the devices are paired/bonded. But the pairing dialog still pops up.
  • In Windows 10 the device does not appear in the list of known Bluetooth devices.
  • If I ignore my custom dialog, and use the Windows 10 pairing dialog that pops up, the pins do not match but the devices pair as expected. A pairing/bonding using this method does not require to be paired after the first pairing.

Is this expected behavior for the library? Thoughts, advice?

32feetWidcomm.dll location/download

I am trying to connect to a HID, I keep reading to put 32feetWidcomm.dll in the same folder as InTheHand.Net.Personal.dll but I can't seem to find it anywhere. Is it still available or did I miss something

Unity Android/Windows

I am right now trying to create an application that is basically a Unity Android remote talking to a Unity PC application via Bluetooth.

It is a first sketch as we actually only need a few buttons on the Android side to trigger certain actions on the PC side.

At first I built all of this successfully with a WiFi connection and then tried to convert it to a Bluetooth connection.
I found your library and integrated it and am stuck now, because of the socket problem you describe on your blog. I was so glad you already addressed that problem and I downloaded the new libs.

Now I am a bit at a loss because the library and its classes seem to be a lot different.
I originally created my applications with a BluetoothListener and a BluetoothClient. Both seem not to be present anymore in the library.

Maybe you have a small sample project you could provide where one can see how it works now? I was so happy when I saw you addressed the Unity issue and I think I am so close with my app.

I would be really thankful for some help.

Connecting only one device without searcing

I need a support about connecting Bluetooth device.

My purpose is to communicate only one Bluetooth device. I don’t wanna to make search again and again.

private void send_file ()
{
InTheHand.Net.Sockets.BluetoothClient bc = new InTheHand.Net.Sockets.BluetoothClient();
InTheHand.Net.Sockets.BluetoothDeviceInfo[] dizi = bc.DiscoverDevices();

            for (int i = 0; i < dizi.Length; i++)
            {
                if (dizi[i].DeviceName == "DESKTOP-OR4D5FK")
                {
                
                System.Uri uri = new Uri("obex://" + dizi[i].DeviceAddress + "/" + "0.jpg");
                    // System.Uri uri = new Uri("obex://" + "DESKTOP-OR4D5FK" + " / " + "deneme.txt");
                    ObexWebRequest request = new ObexWebRequest(uri);
                    request.ReadFile("0.jpg");/////
                    ObexWebResponse response = (ObexWebResponse)request.GetResponse();
                    response.Close();
                break;
                }
            }
    }

Here is my example code.

I just only want to sent a file to specific device.

Kindly waiting your help

Bluetooth LE support for Windows Form APP

Hi,

I have an existing Windows Form C# application, and now this application needs to support connecting to Bluetooth LE devices.

Currently, Is there the method to support discovery and connect Bluetooth LE device for Windows Form application on 32feet?

Simultaneous file transfers(OBEX)

Humble greetings.

A few years ago I built a c# app that copies the same file to multiple Bluetooth devices simultaneously using multi-threading. I am trying to recreate the same app, but with more features using newer technology(latest 32feet.net version and Visual Studio 2017)

I'm trying to recreate the project from scratch. But I keep getting an exception when I call "ObexWebResponse response = (ObexWebResponse)request.GetResponse();" that Only 1 use of the network/protocol/address can be used at a time.

So should I downgrade the library version? (If that's even possible) Or how can I get passed this issue?
Thanks for the help in advance

.NET 2.0 Version?

Hi - I'm looking at using this for a Unity project, but Unity is (still!) limited to .NET 2.0

Should this project work; or; is there a version kicking around that should still work with the older version of .NET?

Strange interoperability with Win10 problem

I want to make UWP app to exchange data with 'classic' desktop app for older Windows. For this desktop version, I use 32feet, because it can work even on Win XP :)

But I can send data only from 32feet to Win10, not the over direction.

Working code to send from 32feet to Win10:
Sender:
oConn = oBtSrv.AcceptBluetoothClient()
Dim peer = oConn.GetStream()
Dim oWriter = New StreamWriter(peer, System.Text.Encoding.Unicode)
oWriter.Write("alamakota" & ChrW(0))
oWriter.Flush()
peer.Flush()
Reader:
(...)
Dim oRfSvcs = Await oPilotBT.GetRfcommServicesAsync(BluetoothCacheMode.Cached)
For Each oService In oRfSvcs.Services
If sBTguid.ToUpper = "{" & oService.ServiceId.Uuid.ToString.ToUpper & "}" Then
bFound = True
Exit For
End If
Next
(...)
Await oBTSocket.ConnectAsync(
oService.ConnectionHostName,
oService.ConnectionServiceName,
SocketProtectionLevel.PlainSocket)
(...)
While True
Await oReader.LoadAsync(2) ' 2 bajty, bo to 1 znak w UTF
Try
sChar = oReader.ReadString(1)
If sChar = ChrW(0) Then Exit While
sOut &= sChar
Catch ex As Exception
' Unicode BOM etc.
End Try
End While

And it works. sOut = "alamakota".

But symmetric exchage from UWP to Win32 - doesn't work:
UWP:
Dim oWriter = New DataWriter(oBTSocket.OutputStream) ' 130 ms
oWriter.UnicodeEncoding = UnicodeEncoding.Utf16LE
oWriter.WriteString("alamakota" & ChrW(0))
Await oWriter.FlushAsync
Await oBTSocket.OutputStream.FlushAsync

Win32:
Dim oReader = New StreamReader(peer, True)
Dim iChar As Integer
Dim sBuff(10) As Byte
While True
iChar = oReader.Read ' <--- here it hangs
If iChar = 0 Then Exit For
If iChar <> -1 Then sCmd = sCmd & AscW(iChar)
Next

Am I doing something wrong, or there is some error either in 32feet or in Windows?

Desktop app is compiled by VStudio 2008, and is running on Win10 15063.674. Two different Bluetooth dongles was tested, same effect (one is old BT 1.2, second is BT 4.0).
UWP app is compiled by VStudio 2017, and is running on Lumia 532, Win10 15063.608.

Detect Bluetooth LE

Hi I develop windows form app with C# and I use 32feet api for bluetooh. I can get Bluetooth devices but I cant get Bluetooth LE devices. Is there any way to get BLE devices on 32feet ?

Receiving data from SPP profile fails under Windows 10 Version 1809

We are using the 32feet library to connect to a Bluetooth Classic module (Bluegiga/Silabs WT11) via a virtual COM port connection (SPP).
Below is an excerpt of the C# code we use.

Code

...
// connect
InTheHand.Net.Sockets.BluetoothClient m_localClient;
m_localClient = new InTheHand.Net.Sockets.BluetoothClient();
m_localClient.Connect(mapping.Address, BluetoothService.SerialPort);
...

// receive data
if (m_localClient != null && m_localClient.Connected){
   Stream inStream = null;
   inStream = m_localClient.GetStream();
   int numberOfBytes = inStream.Read(m_receivedData, 0, m_receivedData.Length);
   ...
}   
...
// send data
...
if (m_localClient != null && m_localClient.Connected){
   Stream outStream = m_localClient.GetStream();
   if (outStream != null){
      outStream .WriteTimeout = 1000;
      outStream .Write(data, 0, data.Length);
   }
}
...
// disconnect
if (m_localClient != null){
    m_localClient.Close();
    m_localClient.Dispose();
    m_localClient = null;
}

Problem

Under Windows 7 this code works.
Under Windows 10 (1803 Build 17134) the code throws an exception at the receive data part.
We are still running tests with earlier versions of Windows 10 to see when the problem was introduced because there are indications that with earlier versions of Windows 10 (1507 or higher) the code worked. If we find out which versions work and which not, I will update this issue accordingly.

Connecting the virtual COM ports created by the Windows Bluetooth stack via any terminal software works under Windows 10 as well as under Windows 7, so there is no general problem with using the SPP profile.

Interestingly on the Bluetooth module side we receive the message "SYNTAX ERROR" on the serial output when trying to establish the connection using the 32feet library code above. This error does again not appear when using Windows 7.

The WT11 module uses the latest firmware (55.7.0 build 1118), although the behaviour is the same for older firmware versions.

Error

The error we get ist mostly this one:
System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)

Less often this one
System.Net.Sockets.SocketException (0x80004005): An invalid argument was supplied 00078025BEDA:0000110100001000800000805f9b34fb
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at InTheHand.Net.Bluetooth.Msft.SocketBluetoothClient.Connect(BluetoothEndPoint remoteEP)
at InTheHand.Net.Sockets.BluetoothClient.Connect(BluetoothAddress address, Guid service)

Or that one:
System.Net.Sockets.SocketException (0x80004005): An operation was attempted on something that is not a socket 00078025BEDA:0000110100001000800000805f9b34fb
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at InTheHand.Net.Bluetooth.Msft.SocketBluetoothClient.Connect(BluetoothEndPoint remoteEP)
at InTheHand.Net.Sockets.BluetoothClient.Connect(BluetoothAddress address, Guid service)

Multiple BluetoothService

hello, I'm looking for a way to put several Bluetooth Service on the same device example handsFree and phonebook

Do you have an idea ?

No BT actions

Hi!

I have the following setup:

Windows 10 64bit
Windows BT Stack
Visual Studio 2017

I have made the following small test code but it detects 0 devices while Windows itself is detecting some. When i use a BT sniffer i can see there is no BT packets been send from my desktop when i using this code:

`
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using InTheHand.Net.Bluetooth;
using InTheHand.Net.Sockets;
using InTheHand.Net.Ports;
using InTheHand.Net;
using System.IO;

namespace WindowsFormsApp3 {
public partial class Form1 : Form {

    public Form1() {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e) {
        richTextBox1.AppendText("Scanning for devices. Please wait...");
        this.Refresh();
        scan(); 
    }

    private void scan() {
        BluetoothClient client = new BluetoothClient();
        BluetoothDeviceInfo[] devices = client.DiscoverDevices();
        richTextBox1.AppendText(devices.Length.ToString() + " devices found\n");
        BluetoothClient bluetoothClient = new BluetoothClient();
        String deviceAddress;
        String deviceName;
        foreach (BluetoothDeviceInfo device in devices) {
            deviceAddress = device.DeviceAddress.ToString();
            deviceName = device.DeviceName.ToString();
            richTextBox1.AppendText(deviceAddress);
            richTextBox1.AppendText(deviceName);
        }
    }
}

}
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.