Skip to content
Peter Foot edited this page Jun 13, 2022 · 28 revisions
Clone this wiki locally

32feet.NET - User's Guide / Tutorial / Examples

Version 4.0, December 2021

Bluetooth Classic (BR/EDR)

Discovery

Discovery of classic Bluetooth devices can be done either programmatically where you present the results to the user in your own way, or via a picker component which presents a platform standard component to the user.

Client

RFComm connections are exposed programmatically as Sockets and will be familiar to any developer who has worked with other network communications. You can create your own profile and define your own data structures or use one of the RFComm based Bluetooth classic profiles.

Server

In order to expose a service to which other devices may connect you need to create a valid SDP record and open a listening socket.

Virtual Serial Ports

Separate from the Serial Port Profile for Bluetooth, which defines a serial style connection between devices, some platforms such as Windows support creating a virtual COM port. This appears natively on the system as a hardware port but represents a Bluetooth connection to a device supporting Serial Port Profile. Because of the additional overhead and legacy code you shouldn't use Virtual Serial Ports unless you really need to. For example, if you have an old client app which you can't change and it requires a COM port to operate.

Bluetooth Low Energy (Gatt)

Bluetooth Low Energy consists of one or more services which then have one or more Characteristics which expose a particular value or logic set of values for the remote device. Each Characteristic may support Read/Write/Notify functionality. Rather than maintaining an open connection with a remote device you can monitor these change notifications.

Bluetooth Mesh

There is currently no intrinsic support for Bluetooth Mesh but you can communicate with a mesh using the proxy Mesh Service over Gatt.

Profile/Service Implementations

Some specific higher-level profiles may be exposed with specific APIs for simplicity. Bluetooth SIG defined profiles are documented on the Bluetooth website. Some third-party profiles are documented here

IrDA

InTheHand.Net.IrDA supports client and server IrDA connectivity for Windows. The Object model is based on Microsoft's IrDA implementation for Windows CE / .NET Compact Framework which was ported to desktop Windows in the original release of 32feet.NET. It will be very familiar if you have used TcpClient/TcpListener classes in .NET. Few devices will have the requisite hardware to use IrDA these days but you can use it if you attach a USB IrDA dongle and enable the IrDA Subsystem in Windows 10 and above. more details...

Object Exchange (Obex)

Object Exchange allows an app to send or retrieve files using a standard protocol that is supported by a number of standard Bluetooth devices such as Printers, Cameras etc. The OBEX protocol is a highly compact format inspired by FTP. InTheHand.Net.Obex supports object exchange over Bluetooth RfComm, IrDA and TCP/IP.

Platforms

32feet.NET supports a number of different platforms and exposes the same .NET API. Not all functionality is available to all platforms and you much check that particular features are supported to avoid exceptions at runtime.

Platforms which use a sandbox may require permissions to be defined in the app manifest and or requested at runtime. Read more about Permissions.

Feature Windows Android iOS tvOS watchOS macOS Linux Tizen
RFComm Client Yes Yes Yes* Planned Planned
RFComm Server Yes Yes Planned
Discovery Yes Yes Planned Planned
Discovery Picker Yes Yes Yes* Planned
Bluetooth LE Picker Yes Yes Yes
Gatt Client Yes Yes Yes Yes Yes Yes
Gatt Server Planned Planned Planned Planned
Obex Client Yes Planned
Obex Server
IrDA Client Yes
IrDA Server Yes
  • iOS only supports Bluetooth Classic devices which are designed to Apple's Made for iOS (MFI) specification. Currently you can only connect to the first exported service name on the peripheral. Therefore you can use the BluetoothClient to connect to a single function device like a thermal printer but not any arbitrary service running on a device or another platform.