Connect
This guide assumes the project is already configured (required references added, file structure in place).
Driver Manager
The DriverManager loads the sensor driver (e.g., Trimble S Series) and creates sensor instances.
Although the high‑level API is unified, the SDK still needs to know which instrument type you intend to control.
Key points in the snippet below:
IsvDetails.Developerenables development modeTrimble.Ssi.Driver.CarpoBased.Driver.SSeries.Windows.dllis loaded dynamically- A
driverinstance is created from the loaded assembly _sensoris a sensor instance from that driver (you can create more if needed)DriverManager.DriverLogFilePathis set to a folder that is created if missing
IDriverManager driverManager = new DriverManager(IsvDetails.Developer);
try
{
var driverDir = Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "..", "lib", "ssi", "Trimble.Ssi.Driver.CarpoBased.Driver.SSeries.Windows.dll");
var driverAssembly = Assembly.LoadFrom(driverDir);
driverManager.RegisterDriverAssembly(driverAssembly);
var drivers = driverManager.ListAvailableDrivers();
var driverInformation = drivers.FirstOrDefault();
var driver = driverManager.CreateDriver(driverInformation);
_sensor = driver.CreateSensor();
var logPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TPSDK_log");
if (!Directory.Exists(logPath)) Directory.CreateDirectory(logPath);
DriverManager.DriverLogFilePath = logPath;
}
catch (Exception)
{
throw; // Re-throw so upstream logic can handle/report
}
Connecting to a Sensor
You now have a valid _sensor and can query capabilities.
Typical connection types for a Trimble S Series:
- USB
- Serial
- Bluetooth
- Radio
List supported types:
var supportedConnectionTypes = _sensor.ListSupportedConnectionTypes();
Returns an IEnumerable<ConnectionType>.
USB
Simplest option (no extra parameters):
if (_sensor.IsSupported(ConnectionType.Usb))
{
var settings = new ConnectionSettings(ConnectionType.Usb);
try
{
await Task.Run(() => _sensor.Connect(settings));
Initialize();
return true;
}
catch (Exception e)
{
exceptionCallback(e);
}
}
Bluetooth
Requires a Bluetooth address:
public async Task<bool> ConnectViaBluetooth(Action<Exception> exceptionCallback, string bluetoothAddress)
{
if (_sensor.IsSupported(ConnectionType.BluetoothSocket))
{
var btParam = _sensor.CreateConnectionParameter(ConnectionParameterType.BluetoothSocketSettings) as IConnectionParameterBluetoothSocketSettings;
btParam.BluetoothParameter = btParam.CreateBluetoothParameter(bluetoothAddress);
var parameters = new List<IConnectionParameter> { btParam };
var settings = new ConnectionSettings(ConnectionType.BluetoothSocket, parameters);
try
{
await Task.Run(() => _sensor.Connect(settings));
return true;
}
catch (Exception ex)
{
exceptionCallback(ex);
}
}
return false;
}
Bluetooth Radio Bridge (e.g., EM120 via EDB10)
ConnectionType.BluetoothRadio combines Bluetooth and radio parameters:
public async Task<bool> ConnectViaBluetoothRadio(Action<Exception> exceptionCallback, string bluetoothAddress, int channel, int networkId)
{
if (_sensor.IsSupported(ConnectionType.BluetoothRadio))
{
var btParam = _sensor.CreateConnectionParameter(ConnectionParameterType.BluetoothSocketSettings) as IConnectionParameterBluetoothSocketSettings;
btParam.BluetoothParameter = btParam.CreateBluetoothParameter(bluetoothAddress);
var radioParam = _sensor.CreateConnectionParameter(ConnectionParameterType.RadioCommonSettings) as IConnectionParameterRadioCommonSettings;
radioParam.Channel = channel;
radioParam.NetworkId = networkId;
var parameters = new List<IConnectionParameter> { btParam, radioParam };
var settings = new ConnectionSettings(ConnectionType.BluetoothRadio, parameters);
try
{
await Task.Run(() => _sensor.Connect(settings));
Initialize();
return true;
}
catch (Exception ex)
{
exceptionCallback(ex);
}
}
return false;
}
Connection Parameters Pattern
Each transport uses one or more parameter objects (ConnectionParameterType):
IConnectionParameterBluetoothSocketSettings– Bluetooth addressIConnectionParameterRadioCommonSettings– radio channel + network IDIConnectionParameterSerialSettings– serial port settings
You collect the required parameter instances in a List<IConnectionParameter> and pass them — together with the desired ConnectionType — to a ConnectionSettings instance used by _sensor.Connect(...).
This pattern keeps connection logic explicit and extensible.