The SDK dispatches a ChunkSent event for each chunk it sends to DeepAffex Cloud. If you need to send the payloads to Nuralogix for debugging purposes, you can use the saveToDisk and downloadFile utility functions to save them as binary files.

A 30-second measurement emits 6 chunks (every 5 seconds), so these helpers will generate 2 files per chunk emitted:

  • One for the payload
  • One for the metadata

Once the measurement is complete, send all generated files to Nuralogix.

const downloadFile = (data: Uint8Array, filename: string) => {
const blob = new Blob([data.buffer], {
type: 'application/octet-stream',
});
const url = window.URL.createObjectURL(blob);
const link = window.document.createElement('a');
link.href = url;
link.download = filename;
window.document.body.appendChild(link);
link.click();
window.document.body.removeChild(link);
window.URL.revokeObjectURL(url);
}

const saveToDisk = (chunk: ChunkSent) => {
const { chunkNumber, numberChunks, payload, metadata, measurementId } = chunk;
downloadFile(payload, `${measurementId}-payload-${chunkNumber}.bin`);
downloadFile(metadata, `${measurementId}-metadata-${chunkNumber}.bin`);
};

measurement.on.chunkSent = (chunk: ChunkSent) => {
saveToDisk(chunk);
};