The SysSync library makes your application over-the-air update-able (OTA). Further details about update concepts, the necessary features and considerations of an OTA systems can be found here.

To use this library

#include "SysSync.h"

The library needs access the internet by means of a HTTPClient instance of the kind that your hardware variant provides:

Now the only thing left for your application is to establish the underlying technology (WiFi, LTE, Ethernet) and to call the function i_doSysSync() regularly.

Example

The following example makes use of the CANIP library to access the internet. That is why it can be tested on all dice devices.
Hint: Click on ‘provide internet access’ in the CAN2SER monitor.

#include "SysSync.h"
#include "CANIP.h"

CANIP_Client t_postClient(&MCAN0, &BOOTLOADER_SETTING);
void setup()
{
  Serial.println("STARTUP: "+BOOTLOADER_SETTING.s_get_app_name()+" (V" + BOOTLOADER_SETTING.u32_get_app_version()+")");
}

void loop()
{
  i_doSysSync(&t_postClient);
}

The library is designed non-blocking so that it does not bother your main application processes. Still it connects to the SysSync server in intervals (by default: at startup and then every 15 minutes) and might take a second. If it finds an update-package on the server then the succeeding steps (e.g. file downloads) will be broken down in small packages so that the main application should still not be impacted much.

The return value of i_doSysSync() informs your application about the status and needs of the update process. This can be e.g. ‘internet is required’, ‘update start warning’, ‘reset warning’ or ‘idle’ if there is nothing to do. This gives the application the opportunity to react accordingly.

Components:

An update concept consists of:

  • the SysSync Web-server that provisions the update-jobs and -data to the
  • the Devices running the SysSync library. The devices and server share
  • the Credentials of each device for authentication. The device owner has to have
  • a Account on the server so that he can create und monitor update jobs via
  • the Server GUI.

In most cases the function i_doSysSync() can be used in its simplest form. It only needs a HTTP_Client instance and an internet connection. A typical application should check the return value. It would then establish the internet connection and/or stop accessing the serial flash memory according to this return value.
The following examples could be understood as templates for an application that uses the update-concept and also provides CANIP service to other CAN nodes.

SysSync & CANIP – Wifi application example

// dice-WiFi - - SysSync + CANIP provider
// 
// - WiFi internet management via Console and
// - WiFi SSID/Pass stored (in bootloader settings)
// - SysSync remote update client
// - CANIP provider


#include "SysSync.h"
#include <WiFiNINA.h>
#include "CANIP.h"
#include "LowPowerSAMC.h"
#include "consoleLogin.h"
#include "utils/consoleWiFiConfig.h"


WiFiHTTPClient clientForSysSync;
WiFiHTTPClient clientForProvider;
CANIP_Provider myIP_provider(&MCAN0, &BOOTLOADER_SETTING, &clientForProvider);


void setup()
{
  Serial.println("STARTUP: "+BOOTLOADER_SETTING.s_get_app_name()+" (V" + BOOTLOADER_SETTING.u32_get_app_version()+")");
  console_init(&Serial);
  myIP_provider.begin();
}

void loop()
{
  int i_ret;
  static uint32_t nextConnectAttempt = 0;
  String s_console_string = s_console_routine();
  s_console_string = s_console_wifi_config_cmds(s_console_string);
  i_ret = backgroundProcesses();
  if(i_ret == 1)	// background process needs internet connection
  {
    if( (WiFi.status() != WL_CONNECTED) &&(cons_get_stored_wifi_settings()) )
    {
      if(nextConnectAttempt < millis())
      {
        Serial.println("Establishing WiFi connection");		
         WiFi.begin(t_cons_curr_wifi_settings.ac_ssid, t_cons_curr_wifi_settings.ac_pass);
        nextConnectAttempt = millis()+10000;
      }
    }
  }
  else if(i_ret != 1)
  {
    if(WiFi.status() == WL_CONNECTED)
    {
      Serial.println("Shutdown WiFi connection");
      WiFi.disconnect();
    }
  }
  if(i_ret == -1)
  {
    Serial.println("Reset warning!");
    delay(1000);
  }	
}

int backgroundProcesses()
{
  int i_SysSyncState 	= 0;
  int i_inet_required = 0;
  int i_inet_status 	= (WiFi.status() == WL_CONNECTED) ? 1 : 0;
	
  do{
    i_SysSyncState = i_doSysSync(&clientForSysSync);
    myIP_provider.run(i_inet_status);
    yield();
  }while( i_SysSyncState == SYSSYNC_RET_PROCESSING );	
  i_inet_required = ((i_SysSyncState >= SYSSYNC_RET_INET_DEMAND) || (myIP_provider.hasInternetDemand())) ? 1 : 0;
  i_inet_required = (i_SysSyncState == SYSSYNC_RET_RESET_WARN) ? -1 : i_inet_required;	
	
  return i_inet_required;
}

Find the source code in the example menu within the Arduino IDE under
File -> Examples -> SysSync ->

SysSync getting started steps:

Step by step tutorial:

  • Open the diceConfig tool (with connected dice device)
  • Create an account on the SysSync server
  • Register your device at the server (this creates and sysnchronises the device unique credentials on the device and the server & associates the device to your account)
  • Write, compile, flash and run your application_A (template) on the device
  • Create and compile application_B and Export the application binary
  • Logon to the SysSync server https://syssync.di-ce.de (that also the button on our website)
  • Create an update job for your device (update is to application_B)
  • Activate and monitor your update-job

Further information

The SysSync system is build on top of numerous other libraries (CRC, Update, SerialFlash, CAN2SER etc.). Find further information about the libraries below.

Remote update system – General requirements and considerations
HTTP_Client Class
SerialFlash – Library
BOOTLOADER SETTINGS – Library
Update – Library
CAN2SER – Library

SysSync library functions

Methodes: