Hi,
I have tested a bit the ability to send a "large" (64KB) chunk of data from my companion app to Fitbit Versa.
I have noticed that the transfer speed is extremely low, both by splitting it into chunks for messaging API and using the File Transfer API. Now, when I am saying slow, I mean 0.8KBs slow.
Now, the question is, Bluetooth speeds are not that low (to say the least).
Is there any specific limitation that causes this issue?
Do Fitbit intent to improve this in the future?
Thanks in advance 🙂.
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
Hi,
I do have a very simple app.
This is the device app:
import * as messaging from "messaging";
import { inbox } from "file-transfer";
console.log("App code started");
messaging.peerSocket.onopen = () => {
console.log("Peer opened");
};
let num=0;
messaging.peerSocket.onmessage = evt => {
console.log("message : " + (num++));
messaging.peerSocket.send("ack");
};
function processAllFiles() {
let fileName;
while (fileName = inbox.nextFile()) {
// process each file
console.log("Received: ", fileName);
messaging.peerSocket.send("ack");
}
}
inbox.addEventListener("newfile", processAllFiles);and the companion app:
import * as messaging from "messaging";
import { outbox } from "file-transfer";
let arr = new ArrayBuffer(64*1024);
let currMsgIndex = 0;
let size = messaging.peerSocket.MAX_MESSAGE_SIZE - 3;
let count = arr.byteLength / size;
var currDate = undefined;
function sendMyData(){
if (messaging.peerSocket.readyState !== messaging.peerSocket.OPEN){
console.log("Not Read: " + messaging.peerSocket.readyState);
setTimeout(sendMyData, 100);
return;
}
messaging.peerSocket.onmessage = () =>{
currMsgIndex++;
if (currMsgIndex >= count){
var endDate = secondsDate();
console.log("DateDIff: " + (endDate - currDate));
}
else{
messaging.peerSocket.send(arr.slice(currMsgIndex * size, size));
}
};
console.log("Sending Data MaxSize:" + messaging.peerSocket.MAX_MESSAGE_SIZE);
console.log("Sending Data " + currMsgIndex);
messaging.peerSocket.send(arr.slice(currMsgIndex * size, size));
}
function sendMyData2(){
console.log("Transfering Data");
messaging.peerSocket.onmessage = () =>{
var endDate = secondsDate();
console.log("Completed DateDIff: " + (endDate - currDate));
};
outbox.enqueue("test.bin", arr).then((ft) => {
console.log("Transfer of " + ft.name + " successfully queued.");
}).catch((error) => {
console.log("Failed to queue: " + filename + ". Error: " + error);
})
}
function secondsDate(){
var x = new Date();
return x.getHours() * 60 + x.getMinutes() * 60 + x.getSeconds();
}
messaging.peerSocket.onopen = () => {
currDate = secondsDate();
sendMyData2();
};I use the default chunk size With an Android app.
My firmware version is : 32.32.12.19
This is kind of my first app (just trying to figure out what is possible with the platform).
So, any comments / suggestions will be very appreciated 🙂
Best AnswerStill waiting for a replay on this one 😔
Best AnswerHi Guys,
I am facing the same issues but from the watch to the companion. Basically I am sampling data from sensors (all of them) and trying to send everything to the companion for further analysis. However, during the transmission I noticed an increasing delay between transmitted and received packets. I have tried to send small packets or a giant packet with all the data ( still lower than the message limit), but what I've seen is a constant throughput of around 0.4-5KBs. I am using the FitBit Versa 1 and the Messaging API. I have tried multiple phones where I've noticed small improvements but still around that speed.
I have checked the BL packets using HCI Snoop Log in order to debug this problem. I have sent a text composed of around 800 characters and it took around 2 seconds and in that moment, there were no synchronization going on, just the data transfer.
The smartphones I tested are:
- S4 Mini updated to Android 6.0.1
- Sony Z2 with same Android version
- Samsung S9 + with Android 9
The Versa 1 has the firmware 32.33.1.30
Is this the Fitbit BLE throughput?
Are there any other faster ways to send data from device to companion?
Thanks
Best AnswerHi @IMorandi . Have you tried using File-Transfer API (Outbox/Inbox) available on SDK 3.0 ? I was able to send/receive data with a throughput of ~2.5 KBs.
You will first need to write the sensor data on the device file system (can be on a binary, json or any other type) and then trigger the file-transfer with an interval timer or your transfer event.
On the device
import { outbox } from "file-transfer";
function transferData() {
let queuedFile = 'FILE_NAME.bin';
outbox.enqueueFile(queuedFile)
.then((ft) => {
console.log('Transfer of ' + ft.name + ' successfully queued.');
ft.onchange = () => {
console.log('File Transfer State: ' + ft.readyState);
if (ft.readyState === 'transferred') {
console.log('Transfer of ' + ft.name + ' completed.');
}
}
})
}
On the companion
import { inbox } from "file-transfer";
// Process new files as they are received
inbox.addEventListener("newfile", processNewFile);
// Also process any files that arrived when the companion wasn’t running
processNewFile();
// Process the inbox queue for files, and read their contents as ArrayBuffer
async function processNewFile() {
let file;
filesProcessed = [];
while ((file = await inbox.pop())) {
var data = await file.arrayBuffer();
console.log('ArrayBuffer: ' + data);
}
}
Best AnswerCan confirm - file transfer is very slow: 0.4KB/s in my case.
Reproducing is really simple. In your companion app do:
outbox.enqueue("temp.txt",cbor.encode(some-jason); // log size and time hereIn your Fitbit watch app:
inbox.onnewfile = () => {
// log time here
}
Tested with Android
Best Answer