Integrating the Jasper Control Center API with Force.com

Jasper's Control Center platform manages IoT devices on the mobile network, allowing mobile network operators to deliver services tailored to the requirements of connected products. Learn how the Force.com Toolkit for Jasper allows Force.com apps to manage connected devices via the Control Center platform.

By definition, connected devices need connectivity, and currently the mobile data network provides the broadest reach. Connected vehicles, logistics solutions, and security systems rely on 2G, 3G and 4G Internet access via embedded wireless modules, allowing them to reach cloud services from anywhere with cell coverage.

Jasper, in the news recently as Cisco announced its intent to acquire the company, created its Control Center platform to manage IoT devices on the mobile network. They partner with mobile network operators to deliver services tailored to the requirements of companies in any industry bringing connected products to market. The Control Center (CC) API gives applications access to the platform via the SOAP protocol, while a Push API notifies applications of events such as a device coming online, data consumption crossing a threshold, devices connecting more or less often than expected, and even the SIM card connecting from a different device than expected.

Force.com Toolkit for Jasper

The Force.com Toolkit for Jasper enables Force.com applications to call all of the functions of the CC API. Now, from Salesforce, you can:

  • Activate or deactivate network access for devices
  • Send and receive SMS to and from devices
  • Retrieve session data to diagnose issues

The toolkit also includes an endpoint to receive Control Center Push API notifications, by default creating a custom object record for each event. It’s straightforward to then define a process to, for example, create a Case when a device is close to its data limit.

This first iteration of the toolkit includes an example custom object, representing a device, and a corresponding Visualforce page. The custom object holds the unique SIM identifier or, more properly ‘integrated circuit card identifier’ (ICCID), for the device. When the page loads, its Apex controller extension calls a Jasper API to get details such as the device’s IMEI, IMSI and MSISDN, its SIM activation status etc, and retrieves recent SMS messages to and from the device. A related list of SIM State Changes is also shown.

The DeviceExtension Apex class shows how to use the toolkit to interact with CC. Here’s how we create an API client, and then retrieve device details and SMS messages:

// Jasper API credentials are stored in a custom setting
settings = JasperSettings__c.getInstance(UserInfo.getUserId());

device = (Device__c)stdController.getRecord();

// Get the API clients for the device ('terminal') and SMS APIs
terminalPort = new JasperTerminal.TerminalPort(settings.Username__c, 
    settings.Password__c, settings.License_Key__c, settings.API_Server__c);
smsPort = new JasperSMS.SmsPort(settings.Username__c, settings.Password__c, 
    settings.License_Key__c, settings.API_Server__c);

// The 'Name' standard field holds the device ICCID
JasperAPI.iccids_element iccids = new JasperAPI.iccids_element();
iccids.iccid = new List<String>{device.Name};

try {
    terminal = terminalPort.GetTerminalDetails(iccids).terminal[0];
    // Map from internal API status - e.g. 'ACTIVATED_NAME' - to 
    // more readable form - e.g. 'Activated'
    terminalStatus = statusMap.get(terminal.status);
    smsMessages = getSMSMessages(device.Name);
    status = 'Retrieved device details successfully';
} catch (Exception e) {
    // Most common error is a mistyped password or misconfigured API endpoint
    status = e.getMessage();
}

As well as retrieving device details, you can modify SIM activation status via the dropdown list on the page. Again, the Apex controller extension shows you how it’s done:

try {
    // changeType argument signifies which attribute should be set - '3' is SIM status.
    // Download JasperAPI.xsd from Control Center resources page for the full list
    JasperAPI.EditTerminalResponse_element res = terminalPort.EditTerminal(device.Name,
        null, terminal.status, '3');
    status = 'New status effective '+res.effectiveDate.format();
} catch (Exception e) {
    status = e.getMessage();
}

SMS can be used to send messages to devices on the mobile data network. This is a very convenient channel for provisioning settings, sending control messages etc. The sample device page allows you to send an SMS to the device. Here’s the code – it’s very straightforward:

try {
    Long smsMsgId = smsPort.SendSMS(device.Name, message, null);
    status = 'Sent SMS with message id ' + smsMsgId;
    message = null;
    // Reload list of SMS messages so we see the new one
    smsMessages = getSMSMessages(device.Name);
} catch (Exception e) {
    status = e.getMessage();
}

In this video, I’m using the toolkit with a prototype connected device built from an Arduino Uno, Seeed Studio GPRS Arduino Shield and Grove Shield. The Grove Shield has a temperature sensor and LED attached, giving the device some input and output capability. The Arduino connects to the mobile data network via the GPRS shield, and logs temperature readings to Force.com via Liquid, a demo Heroku app.

The Force.com Toolkit for Jasper allows you to integrate the Force.com platform with mobile devices connected on the Jasper Control Center platform through any Jasper partner operator with minimum effort. If you’re looking for mobile data connectivity, and Jasper sounds like it fits the bill, you can get a trial Control Center account with test SIMs from any of Jasper’s partner operators, and grab the toolkit source code from GitHub.

Leave your comments...

Integrating the Jasper Control Center API with Force.com