TPSDK C# - go to homepage
TPSDK C# logo


C# facade integration

The following few steps explain how to integrated the TPSDK facade into an Visual Studio Xamarin Solution. Note that the following steps are meant to guide the developer - as always there are multiple ways to achieve the same.

Create a new Project

Create a new project in Visual Studio - typically this is a Mobile App (Xamarin.Forms) or similar. The template or style of the app does not matter in this context.

Cross platform mobile apps have usually a platform specific project and a shared one. Within TPSDK the shared code is within the portable project while platform specific implementations are in the corresponding platform projects.


Add projects and references

Adding the facade to your solution

After the solution is created add the CatalystFacade.Portable and CatalystFacade.Droid projects to your solution.

The purpose of adding those two is that you can easily improve the facade interface and extend it to your needs. You can also just reference the CatalystFacade.Portable.dll and CatalystFacade.Droid.dll libraries.

After adding the projects you need to reference both in your main project. Therefore click on your platform project (TpsdkDemoXm.Android in this example) and either

  • Select Add and Reference and select Projects and tick the check boxes for both facade projects
  • Select Add and Reference and browse to the two Facade dlls as part of the facade sample

Adding references to your solution

After adding the facade and portable projects its necessary to add the remaining libraries as available in the libs folder of TPSDK.

To do so just copy the complete content of the libs folder into your project main directory.

A typical structure may look like this:

|- TpsdkDemoXM                              //imported Catalyst facade module
    |- TpsdkDemoXM                          //shared business logic
    |- TpsdkDemoXM.Android                  //the actual Android application 
    |- TpsdkDemoXM.iOS
    |- CatalystFacade.Droid                 //Android specific stuff like Bluetooth socket handling, TDC150 communication etc
    |- CatalystFacade.Portable              //shared business logic
    |- libs                                 //native files within the main application
        |- arm64-v8a                        //ARM64bit folder
        |- armeabi-v7a                      //ARM32bit folder
        |- x86                              //x86 folder (rare and optional)
        |- x86_64                           //x64 folder (rare and optional)
        |- AIDLService.dll
        |- Trimble.Licensing.Android.dll
|- TpsdkDemoXm.sln

After all files are copied the libraries need to get referenced in a similar way as above.

Its important to keep the structure of the libs folder as the native files look explicitly for this structure.

Click Add and Reference and browse to libs folder and add all needed/ wanted libraries.

File Details
Trimble.Licensing.Android Licensing lib needed to decode the licensing details and platform specific
Trimble.Licensing.Portable Licensing lib needed to decode the licensing details
Trimble.Ssi.Components.Core.Portable Shared components/ interfaces
Trimble.Ssi.Core.Portable Core interfaces
Trimble.Ssi.Driver.AndroidService.Driver.Catalyst.Android The Trimble Catalyst driver
Trimble.Ssi.Driver.AndroidService.Driver.Catalyst.JavaBindings A binding lib for the Catalyst driver
Trimble.Ssi.Driver.CarpoBased.Driver.RSeries.Android The Trimble RSeries driver
Trimble.Ssi.DriverManagement.Android Driver management interfaces
Trimble.Ssi.Interfaces.Gnss.Portable GNSS interfaces
Trimble.Ssi.Interfaces.Portable Shared interfaces

You may have noticed that the folder contains more dlls then mentioned above - for example Trimble.Ssi.Driver.MockGnss.Android.dll. These are mostly optional libraries or get loaded dynamically. For example the already mentioned Trimble.Ssi.Driver.MockGnss.Android.dllis a mock driver that simulates a receiver and can be used for testing purpose. There are other optional libraries like Trimble.EMPOWER.*.dll that handle most things related to Trimble EMPOWER modules. In case you are missing a specific hardware feature its best to double check the content of the lib folder - if the hardware in question has a specific optional library.

Adding native so files

The last step is importing or better linking the native so files into the platform specific project in your solution. To do so click on your platform specific project (TpsdkDemoXm.Android in this example) and select Add and Add existing item.

Now browse to the libs folder, go into one of the platform specific folder like arm64-v8a and select all so files. Ensure to select Add as link and accept the dialog. The Add as link will allow an easy drop-in update in case a new TPSDK version is available. Note the icon of linked files in Microsoft Visual Studio.

The last step before the project setup is finally completed is to mark the type of the file as AndroidNativeLibrary. This is necessary so Xamarin knows how to deal with the so files.


Using the facade

At this stage we have a project which builds successfully and is ready to go. We can now initialize that facade via something like

CatalystFacade.Droid.CatalystFacade _catalystFacade = new CatalystFacade.Droid.CatalystFacade(myAppGUID, this);

where myAppGUID is either the GUID from the facade sample or the received GUID from Trimble.

Note that the manifests permission need some adjustment before deploying the application. For details on manifest permission please check the documentation.