Closed BenLaKnet closed 2 years ago
Perhaps https://github.com/nativescript-community/ble/issues/134 might contain some hints.
There appears to be a Bluetooth standard for these, that you might have some luck finding in https://www.bluetooth.com/specifications/specs/ and by searching for glucose references in https://btprodspecificationrefs.blob.core.windows.net/assigned-values/16-bit%20UUID%20Numbers%20Document.pdf
An application like nrf Connect may help you discover the details for yourself here. I'd suggest install that and see if you can figure out those identifiers from there 🙂
Closing this for now as there's no plugin related impact. However, feel free to continue the discussion here!
@peitschie Many thanks.
I found these 2 values :
service_uuid = "0x1808"; characteristic_uuid = "0x2A51";
How must I inject values for reading characteristic.
You would pass those into the ble.read
instruction. For example:
ble.read(device_uuid, service_uuid, characteristic_uuid,
(data) => console.log("data received:", data),
(error) => console.error("Read failed:", error));
I do that, but it returns read failed.
service_uuid = "0x1808"; characteristic_uuid = "0x2A51";
ble.read(localStorage.getItem('ACMid'), service_uuid, characteristic_uuid,
function(data){
addMyContenu("Hooray we have data : " + JSON.stringify(data), 1);
console.log("Hooray we have data : " + JSON.stringify(data));
},
function(failure){
addMyContenu("Failed to read characteristic from device.", 1);
console.log("Failed to read characteristic from device.");
}
);
It is necessary to transform values into something ?
What's the exact read error you get? I'd suggest logging the failure
variable somewhere.
I presume you have connected to the device already?
This is my code :
service_uuid = "1808";
characteristic_uuid = "2A51";
ble.read(localStorage.getItem('ACMid'), service_uuid, characteristic_uuid,
function(data){
addMyContenu("Hooray we have data : " + JSON.stringify(data), 1);
console.log("Hooray we have data : " + JSON.stringify(data));
},
function(failure){
addMyContenu("Failed to read characteristic from device." + JSON.stringify(failure), 1);
console.log("Failed to read characteristic from device." + JSON.stringify(failure));
}
);
And now I do not have error message, but an empty string for results "{}"
data
there is usually an ArrayBuffer
. Try doing new Uint8Array(data)
, and see if that gives you any extra data?
I do that
ble.read(localStorage.getItem('ACMid'), service_uuid, characteristic_uuid, function(data){
data = new Uint8Array(data);
addMyContenu("Hooray we have data : " + JSON.stringify( data ), 1);
console.log("Hooray we have data : " + JSON.stringify( data ));
},
function(failure){
addMyContenu("Failed to read characteristic from device. " + JSON.stringify(failure), 1);
console.log("Failed to read characteristic from device. " + JSON.stringify(failure));
}
);
it returns : "Hooray we have data : {"0":32,"1":1}"
🎉
Glad to hear it @BenLaKnet
OK, Many thanks @peitschie
I obtain different values : manufacturer, model name, serial number.
//manufacturer
//service_uuid = "180A";
//characteristic_uuid = "2A29";
//modele name
//service_uuid = "1800";
//characteristic_uuid = "2A00";
//serial number
//service_uuid = "180A";
//characteristic_uuid = "2A25";
I'm searching for glucose...
@peitschie I do not understand how to obtain glucose measurement. I am trying to read GATT documentation.
I do that :
glucose["glucosemeasurement"] = { service_uuid : "1808", characteristic_uuid : "2A52", decodeASCII : false }
function connectACMglucosemeasurement() {
var data = new Uint8Array(2);
data[0] = 0x01;
data[1] = 0x01;
service_uuid = glucose["glucosemeasurement"].service_uuid;
characteristic_uuid = glucose["glucosemeasurement"].characteristic_uuid;
ble.write(localStorage.getItem('ACMid'), service_uuid, characteristic_uuid, data.buffer,
function(data){
int8data = new Uint8Array(data);
console.log("Hooray we have data : " + JSON.stringify( int8data ));
},
function(failure){
addMyContenu("Failed to write characteristic from device. " + JSON.stringify(failure), 1);
console.log("Failed to write characteristic from device. " + JSON.stringify(failure));
});
}
It fails with failure message : 129.
@BenLaKnet What you're trying to do here (write to the characteristic rather than read it) sounds a bit funny to me... but I'm not at all familiar with the glucose measurement specification.
I'd highly recommend using nrf Connect or a similar tool to get familiar with how to read and work with the data.
Reading the GATT spec itself is not necessarily the best approach to learning Bluetooth. I'd suggest googling a bit more as there seems to be some stackoverflow answers on the topic, as well as simpler demo code snippets available when you google something like "bluetooth glucose measurement read dev"
@peitschie I am using nrf Connect to discover and control services and characteristics.
But I read that I need to write something to :
service_uuid : "1808",
characteristic_uuid : "2A52",
for obtaining all datas measurement or last or first : https://stackoverflow.com/questions/45029498/reading-from-a-notify-characteristic-ionic-bluetooth
But I do not know how to do that.
@peitschie I do that and it is running, now I have to decrypt value :
var databuffer = new Uint8Array(2); databuffer[0] = 0x01; databuffer[1] = 0x01;
console.log("startnotif");
ble.startNotification(localStorage.getItem('ACMid'), "1808", "2A18",
function(datanotif){
int8data = new Uint8Array(datanotif);
console.log("Hooray we have data notif : " + JSON.stringify( int8data ));
},
function(failure){
addMyContenu("Failed notif from device. " + JSON.stringify(failure), 1);
console.log("Failed notif characteristic from device. " + JSON.stringify(failure));
});
console.log("startwrite");
ble.write(localStorage.getItem('ACMid'), "1808", "2A52", databuffer.buffer,
function(data){
console.log("Hooray we have data write : " + JSON.stringify( data ));
},
function(failure){
addMyContenu("Failed write from device. " + JSON.stringify(failure), 1);
console.log("Failed write characteristic from device. " + JSON.stringify(failure));
});
@peitschie Many thanks, I convert correctly values :
int8data = new Uint8Array(datanotif);
id = int8data[1] & 255;
id |= (int8data[2] & 255) << 8;
val = int8data[12];
annee = int8data[3] & 255;
annee |= (int8data[4] & 255) << 8;
mois = addZero(int8data[5]);
jour = addZero(int8data[6]);
h = addZero(int8data[7]);
m = addZero(int8data[8]);
s = addZero(int8data[9]);
datehms = annee + "-" + mois + "-" + jour + "T" + h +":"+m+":"+s;
Sounds like you've made great progress there @BenLaKnet ... nice job!
If you weren't already aware of it, the DataView class might make the decoding step there a bit easier to do: https://devdocs.io/javascript/global_objects/dataview/getuint16
@peitschie many thanks,
I will try that.
Hi,
I try to read datas from Accu Chek Mobile with Bluetooth adaptator but I do not know what is the values for :
service_uuid, characteristic_uuid
Could you help me please.
Many thanks