Skip to content

32feet.NET and shells

Peter Foot edited this page Apr 29, 2017 · 2 revisions

32feet.NET and shells, including PowerShell

The library can be used simply from PowerShell. The only 'trick' is knowing how to reference the assembly in the first place, and that's accomplished using PowerShell's Add-Type cmdlet. Thus:

Add-Type -path ".\some path\InTheHand.Net.Personal.dll"

Some examples

Connecting a BluetoothClient for data transfer

PS C:\Users\alan\Documents> $cli = New-Object InTheHand.Net.Sockets.BluetoothClient {{ New-Object : Cannot find type InTheHand.Net.Sockets.BluetoothClient: make sure the assembly containing this type is loaded. ... }} PS C:\Users\alan\Documents> Add-Type -path ".\some path\InTheHand.Net.Personal.dll" PS C:\Users\alan\Documents> $cli = New-Object InTheHand.Net.Sockets.BluetoothClient

One device in range PS C:\Users\alan\Documents> $cli.DiscoverDevicesInRange() {{

DeviceAddress : F01C13EF940E DeviceName : LG LG-E906 ClassOfDevice : 5A020C Rssi : -2147483648 InstalledServices : {} Connected : False Remembered : False Authenticated : False LastSeen : 17/10/2013 18:44:57 LastUsed : 01/01/0001 00:00:00

}} Now no devices in range PS C:\Users\alan\Documents> $cli.DiscoverDevicesInRange() PS C:\Users\alan\Documents> $arr = $cli.DiscoverDevicesInRange() PS C:\Users\alan\Documents> $arr.Length {{ 0 ?? PS C:\Users\alan\Documents>

Enabling a service

{{ $addr = InTheHand.Net.BluetoothAddress::Parse("00:11:22:33:44:55") $dev = New-Object InTheHand.Net.Sockets.BluetoothDeviceInfo($addr) $dev.SetServiceState(InTheHand.Net.Bluetooth.BluetoothService::SerialPort, 1, 1) }}

Which when the address is wrong for instance fails with: {{ Exception calling "SetServiceState" with "3" argument(s): "The specified service does not exist as an installed service" ... }}

Clone this wiki locally