Over the last few weeks we have been working hard on releasing updates across our whole range of SDKs. The latest updates will include breaking changes to existing code, most notably a renaming of the SDK’s functions to replace Chirp Connect with Chirp SDK. Since connectivity is implicit when using Chirp, we felt that this should be reflected in the SDK nomenclature.

The documentation for each SDK has been updated accordingly at developers.chirp.io, where more detailed changelogs for each of the SDKs can be found at the bottom of the respective Getting Started page.


New features

Alongside this rather prosaic interface change, there have been a few new features introduced to the SDKs.

C / Arduino

The Arduino and C SDKs have new functionality introduced which allows developers to keep track of memory usage and notify them if there have been any memory leaks. This can be very useful when embedded devices have limited RAM available. The following function will return how much memory has been allocated on the heap by the Chirp SDK in bytes.

Note: this will vary for each different Chirp protocol configuration.

int32_t memory_used = chirp_sdk_get_heap_usage(chirp);

It is good practice to free all of the allocated memory used by the SDK once you have finished with it. This is done by the following method which will return an error code if there are leaks in your (Chirp related) code.

chirp_sdk_error_code_t err = del_chirp_sdk(&chirp);
if (err == CHIRP_SDK_MEMORY_LEAK) {
    fprintf(stderr, “Chirp Error: memory leaks”);	
}

The latest C SDK also includes send only support for Arm Cortex-M0+ devices. As this core does not include a floating point unit, it does not have the necessary number crunching capabilities to process input audio data. However, by converting some of our code base to use fixed point arithmetic, we have been able to add send only support to these chipsets.

WebAssembly

The WebAssembly SDK distributable .js and .wasm files have been reduced from 164kB to  133kB thanks to the latest updates from the emscripten toolchain.

The start up flow has been changed slightly to make it easier to integrate into different frameworks and environments. Now, the SDK will only request microphone permissions once the start method is called. The start method now also returns a Promise which will resolve once the permissions have been granted, and reject if they were denied or any errors occurred. A short example of how the SDK could be instantiated is shown below.

const { Chirp } = ChirpSDK;

Chirp({ key: 'CHIRP_APP_KEY' }).then(sdk => {
  sdk.start().then(() => {
    const rc = sdk.send('hello')
    if (rc !== 0) console.error(sdk.errorToString(rc))
  }).catch(console.error)
}).catch(console.error)

We have also updated our example messenger app to use Vue.js, making the code clear and concise for anyone new to JavaScript frameworks. The source code for the app can be viewed here

JavaScript

The JavaScript SDK also now makes use of Promises when sending data, making the method compatible with async/await syntax. The send method will resolve once the Chirp has finished playing, or reject if there were any errors. See the example below

import ChirpSDK from 'chirp-js-sdk'

const chirp = new ChirpSDK(CHIRP_APP_KEY)
const payload = new TextEncoder('utf-8').encode('hello')
chirp.send(payload).then(() => {
  console.log('Sent ' + payload)
}).catch(console.error)

We believe this release is our best one yet, but if you do find any issues then get in touch at https://developers.chirp.io/support.

Stay tuned for more updates in the coming months.