Skip to content

eSDK Initialization

Warning:Commercial Hardware tools and the eSDK are available only for approved partners

To initialize the library, use the function SpInit(). The function takes a struct of type SpConfig as a parameter. Within SpConfig there are a number of required fields that need to be set to start with:

  • SpConfig::memory_block. A pointer to an application-provided memory buffer that the library uses for all its memory allocations. The library does not allocate any memory beyond the size of the buffer (other than stack variables).
  • SpConfig::unique_id. A unique id for the device on which it is running, typically the MAC address. This is used by the library to distinguish the device from other Spotify Connect-enabled devices that the user has. It is important that this ID is sufficiently unique and that it does not change between sessions. (See SpConfig::unique_id for more information.)
  • SpConfig::display_name. The name of the device that will appear when selecting the device in the Connect menu of the Spotify mobile app, for example. Typically, this is the model name of the device or the name that the device uses to announce itself via UPnP or similar protocols.
  • The fields SpConfig::brand_name and SpConfig::model_name should be set to match the brand and model name that you provided in the certification application for the hardware product.
  • SpConfig::brand_display_name and SpConfig::model_display_name. Use these fields if the brand/model strings (see previous bullet) contain characters not allowed. If used, they will override SpConfig::brand_name and SpConfig::model_name for display purposes.
  • SpConfig::device_type. The field should be set to the device type that matches the hardware product most closely.
  • SpConfig::client_id. Provide a Client ID in the field.
  • SpConfig::product_id. For each product enter a designated Product ID, a non-zero unsigned integer which enumerates this model. The simplest way to assign Product IDs for your products is to just use 1, 2, 3, and so on. The Product ID must match the value given in the New Product Application form for this particular model.
  • SpConfig::error_callback. A callback function that the library will use to report errors that happen asynchronously.

Apart from these fields, there are a number of fields you may use. For a complete list, see the SpConfig page.


_24
struct SpConfig conf;
_24
int buffer_size = SP_RECOMMENDED_MEMORY_BLOCK_SIZE;
_24
enum SpDeviceType device_type = kSpDeviceTypeSpeaker;
_24
const char *client_id = "my-client-id";
_24
_24
memset(&conf, 0, sizeof(conf));
_24
_24
conf.api_version = SP_API_VERSION;
_24
conf.memory_block = malloc(buffer_size);
_24
conf.memory_block_size = buffer_size;
_24
conf.error_callback = CallbackError;
_24
conf.error_callback_context = NULL;
_24
conf.display_name = "Example";
_24
conf.unique_id = "my-sample-unique-id";
_24
conf.brand_name = "Example_Brand";
_24
conf.model_name = "example_embedded";
_24
conf.brand_display_name = "Example Brand";
_24
conf.model_display_name = "example_embedded \u266C";
_24
conf.device_type = device_type;
_24
conf.zeroconf_serve = 1;
_24
conf.zeroconf_port = 0;
_24
conf.host_name = conf.unique_id;
_24
conf.client_id = client_id;
_24
conf.scope = SP_SCOPE_STREAMING;