Link the Connector
In Applications, the Connector is separated to isolate use-case & visualization from the connectivity, device management and data transformation layer. This also allowed to associate a single device to multiple Applications or add different devices hardware to a single Application.
Learn more about the West Connectivity data-flow.
The following assumes you already have an Application ready.
For Connector Owners
If you connect devices to West Connectivity by yourself, we will assume you already created a Connector.
Note
If you link 1 Standard Connector
to multiple Applications, by default all Applications will receive the data from all connected devices. If you wish to isolate which devices are available to which application you need to customize the routing logic in the connector device2
eventhandler. For example based on a device Tag
.
Manage Linked Connectors
Note: Following steps assume you have managing access to your application.
1. On the West Connectivity Solution list 'Home' page
2. Go to your Application management page
3. There Click on the 'Services' tab then 'Connector Setup' sub menu.
You will see your available Connectors.
To connect one to your Application just check the checkbox and click 'Apply'.
Notice the 'Lua Script Alias' field on the right. By default to ensure unique naming across the system Connectors are accessible to scripting using their unique generated solution ID. However, as the random string is not handy to use in scripting a customized alias can be provided as default to the Connector name.
4. Once applied you will see a new entry in your services list matching your Connector name. Click on it.
You will get to the Connector Event-Handler scripting editor.
You can here define the logic handling data coming from your devices through the Connector.
Handling Connector events
Note
If you use an End-to-End Application this part is already handled for you by the application default scripts, so there is no need of doing any scripting and below section would be only for your reference.
For Compatible Connectors (Including Basic, As-a-Service) the provided payload will match the one from the Device2 micro-service event.
Once your device sends data, you can find the message in your Application log.
Also have a look at the Device Metrics with Keystore service guide for a further example.
West Connectivity enables many Connectors to be linked with many Applications.
Multi-Applications
By default when a device message is emitted by a Connector all linked applications will received it.
Connector script can be updated to change this behavior and send events to targeted applications only.
To do so, replace the Inteface.trigger(..)
function call in the Connector Device2 event
event-handler script with Interface.triggerOne(..).
Multi-Connectors
If you have multiple Connectors linked to your Application, you can distinguish them with the scripting Context data.
print(context.service) -- print the Connector solution ID
print(context.script_key) -- print the Connector script alias
You can dynamically list which Connectors are linked to your Application from scripting with the Config Service listServices operation
Note
- In scripting, Connectors are referenced as product.
- Connectors are listed and configured the same way as other services like Keystore or Email. The reason is solution-to-solution communication, or in this case Connectors to Application, is done by exposing the [Connector] solution capability as a dynamic West Connectivity Service using the Interface Micro-Service.
Call the Connector API
In a similar way, you can interact with your Connector API the same way you would with the Device2 micro-service.
Example: Listing your devices with:
Where 'Myfirstconnector' must match the 'Lua Script Alias' defined in the Connector Setup.
You can also use the Connector solution ID with:
Find more info about services calls on the West Connectivity Scripting reference