# Sysclient

Interface for the sysclient.

## File information

File | common/interface/sysclient.h
Classes | ISysClient USysClient

# Classes

## ISysClient

    class ISysClient {
    public:
        static class ISysClient * Create(class IIoMux * const iomux, class ISocketProvider * tcpSocketProvider, class ISocketProvider * tlsSocketProvider, class USysClient * uSysclient,
            const char * serverURI, class IInstanceLog * const log, const char * webserverPassword,
            const char * macAddress, const char * product, const char * version, const char * platformJson, const char * ethIfsJson = nullptr, const char * major = nullptr, bool isInnovaphoneDevice = false, const char * webserverRootPage = nullptr,
            const char * firmwareVersion = nullptr, const char * bootcodeVersion = nullptr, const char * firmwareFileName = nullptr, const char * bootcodeFileName = nullptr);
        virtual void SendIdentify(const char * provisioningCode);
        virtual void SendCustomIdentify(const void * buff, size_t len);
        virtual void Close();
        virtual void Encrypt(const char * seed, const char * data, char * out, size_t outLen);
        virtual void Decrypt(const char * seed, const char * data, char * out, size_t outLen);
        virtual void SendDevicesInstancePaths(const char * appServiceId, ISysClientDevicesInstancePaths * paths, const char * devicesType = nullptr);
        virtual void SoftwareUpdateResult(sysclient_software_update_result_t result);
    };

### Public functions

Create (static function)

  The function is used to create a sysclient object.

  #### Parameters

  class IIoMux * const iomux | To hold the architecture string
  class ISocketProvider * tcpSocketProvider | The TCP socket provider
  class ISocketProvider * tlsSocketProvider | The TLS socket provider
  class USysClient * uSysclient | The USysClient instance to receive the callbacks.
  const char * serverURI | The server URI (e.g. the Devices App URL)
  class IInstanceLog * const log | A log object for logging.
  const char * webserverPassword | The webserver password, which could be NULL
  const char * macAddress | The MAC address of the device
  const char * product | The product name
  const char * version | The complete version string (i.e. 13r1 1234566, 13r2...)
  const char * platformJson | The type of the device in JSON format (e.g. for a phone it will be { "type": "PHONE" })
  const char * ethIfsJson | A JSON string with an array of ethernet interfaces, e.g. [{"if":"ETH0","ipv4":"172.16.14.40","ipv6":"2002:91fd:9d07:14:290:33ff:fe3e:4f67"}]
  const char * major | Just the major version (i.e. 13r1, 13r2...)
  bool isInnovaphoneDevice | Boolean if this is an innovaphone device or not.
  const char * webserverRootPage | The root page of the local webserver which shall be displayed by the Devices App in an IFrame. If empty, Devices itself tries to guess the root page depending on the platformJson.
  const char * firmwareVersion | The firmware version, e.g. 14200033 .
  const char * bootcodeVersion | The bootcode version, e.g. 14200033 .
  const char * firmwareFileName | The firmware filename, e.g. ip311.bin .
  const char * bootcodeFileName | The bootcode filename, e.g. boot311.bin .
  word webserverPort | The local webserverPort, default is 80.

  #### Return value

  Returns the sysclient object.

SendIdentify

  The function is used to send the Identify message, which is built using the parameters.

  #### Parameters

  const char * provisioningCode | The provisioning code provided by Devices

SendCustomIdentify

  The function is used to send a custom Identify message.

  #### Parameters

  const char * buffer | The buffer with the JSON message
  size_t len | The length of the buffer

Close

  Closes the sysclient object. After it is closed, the function SysClientClosed will be called.

Encrypt

  Encrypts the given data with the admin password of the sysclient.

  #### Parameters

  const char * seed | A seed used for encryption.
  const char * data | The data which will be encrypted.
  char * out | The output buffer to which the encrypted data will be written.
  size_t len | The length of the output buffer

Decrypt

  Decrypts the given data with the admin password of the sysclient.

  #### Parameters

  const char * seed | A seed used for decryption.
  const char * data | The data which will be decrypted.
  char * out | The output buffer to which the decrypted data will be written.
  size_t len | The length of the output buffer

SendDevicesInstancePaths

  Not documented for now, don't use it.

SoftwareUpdateResult

  If you started a software update due to a USysClient::SysClientSoftwareUpdate callback, you must answer with this function.
  You must send an answer before the sysclient connection is closed due to a sotftware restart after an update.

  #### Parameters

  sysclient_software_update_result_t result | An enum with the result.

## USysClient

    class USysClient {
    public:
        virtual void SysClientConnected(class ISysClient * sysClient);
        virtual void SysClientAuthenticated(class ISysClient * sysClient);
        virtual void SysClientSetProvisioningCode(class ISysClient * sysClient, const char * provisioningCode);
        virtual void SysClientSetSysClientPassword(class ISysClient * sysClient, const char * password);
        virtual void SysClientSetAdminPassword(class ISysClient * sysClient, const char * password);
        virtual void SysClientSetConfig(class ISysClient * sysClient, char * buffer);
        virtual const char * SysClientGetPassword(class ISysClient * sysClient);
        virtual void SysClientSoftwareUpdate(const char * firmwareVersion, const char * firmwareUrl, const char * bootcodeVersion, const char * bootcodeUrl);
        virtual void SysClientClosed(class ISysClient * sysClient);
    };

### Public functions

SysClientConnected

  The function is called if the sysclient is connected.
  You now need to call sysclient->SendIdentify(), with or without a provisioning code, which depends on your setup.

  #### Parameters

  class ISysClient * sysClient | The ISysClient instance which will receive the callbacks.

### Public functions

SysClientAuthenticated

  The function is called if the sysclient is authenticad (added to a domain in the Devices App).

  #### Parameters

  class ISysClient * sysClient | The ISysClient instance which will receive the callbacks.

SysClientSetProvisioningCode

  The function will be called with a provisioning code, normally to delete it.

  #### Parameters

  class ISysClient * sysClient | The ISysClient instance which will receive the callbacks.
  const char * provisioningCode | The provisioning code provided by Devices.

SysClientSetSysClientPassword

  The function will be called with the sysclient password for the device.

  #### Parameters

  class ISysClient * sysClient | The ISysClient instance which will receive the callbacks.
  const char * password | The sysclient password for the device

SysClientSetAdminPassword

  This function will be called with the admin password.

  #### Parameters

  class ISysClient * sysClient | The ISysClient instance which will receive the callbacks.
  const char * password | The admin password

SysClientSetConfig

  Called with the config data of the device sent by Devices. This will be called several times and the last time the flag "last" will be set to too.

  #### Parameters

  class ISysClient * sysClient | The ISysClient instance which will receive the callbacks.
  char * buffer | The buffer with config data on JSON format

SysClientGetPassword

  The function returns the sysclient password.

  #### Parameters

  class ISysClient * sysClient | The ISysClient instance which will receive the callbacks.

  #### Return value

  Returns the sysclient password.

SysClientSoftwareUpdate

  You will get this callback if the Devices App has a software update available.
  You must answer with ISysSclient::SoftwareUpdateResult after the update installation has finished but before the sysclient connection was restarted.

  #### Parameters

  const char * firmwareVersion | The new firmware version.
  const char * firmwareUrl | A URL to the firmware.
  const char * bootcodeVersion | The new bootcode version.
  const char * bootcodeUrl | A URL to the bootcode.

  #### Remarks

  There might be an update for both firmware or bootcode or just for one of them. So you may get nullptrs here.

SysClientClosed

  After the sysclient object is closed, this function is called so that the object can be deleted.

  #### Parameters

  class ISysClient * sysClient | The ISysClient instance which will receive the callbacks.

# Data types

## sysclient_software_update_result_t

    typedef enum {
        SYSCLIENT_SOFTWARE_UPDATE_RESULT_OK,
        SYSCLIENT_SOFTWARE_UPDATE_RESULT_HTTP_DOWNLOAD_FAILED,
        SYSCLIENT_SOFTWARE_UPDATE_RESULT_INCOMPATIBLE,
        SYSCLIENT_SOFTWARE_UPDATE_RESULT_INSTALLATION,
        SYSCLIENT_SOFTWARE_UPDATE_RESULT_CONNECTION_LOST,
        SYSCLIENT_SOFTWARE_UPDATE_RESULT_UKNOWN
    } sysclient_software_update_result_t;