Most recent activity
-
I was getting some data on Android side which I assumed needed decoding.
Since I'm now advertising using NRF.setAdvertising({
- I just want to understand now how it works, does setAdvertising
advertises data just once? - I think that when this data is advertised, it tags along with
bluetooth info, i.e. when Android side code will get Puck bluetooth
info, it will get access to this data too.
So currently I do not have paired button and am accessing bluetooth info of Puck in Android code, I get some data in array but not sure how to interpret it.
Regards,
- I just want to understand now how it works, does setAdvertising
-
Hi Gordon,
Thanks, for the reply. I have found the solution to receive advertising data without pairing puck button with android device but I am not sure if I'll need to run a background thread to keep looking for this advertisement OR is there a way to listen to this?
One more thing, how ca I decode the data currently I am receiving to make sure that the data is sent from my button?
Regards
-
-
Thanks Gordon.
I agree about app being the solution. I tried your suggestion but nothing seem to work right now for me. I started by trying very simple implementation i.e. send temperature on each click.
I put following code in Puck:
setWatch(function(e)
{
NRF.setAdvertising({0x1809 : [0|E.getTemperature()]
});
}, BTN, {repeat:true,edge:"rising",debounce:50});Now, android side I tried to get this advertised data when Puck button is pressed but there is nothing there. Can you please point me to a sample/link on Android side which can do this? Also if anything done wrong here.
Regards,
-
Thanks Ollie/Gordan,
Sorry for being bit unclear in my query. I think I'm looking to build an app. Let me clarify bit more if it helps.
I need this button to work as below: Someone who is visually impaired wants to call an emergency number[say a family member] from his Android phone. Instead of dialling number/searching in phone book, he could just do a single click to call number a, double click call number b from such button which is paired with his phone.
Your guidance on this will be appreciated.
Regards, -
Hi Gordon,
I have revisited this and think for my requirement I would want to work it after device is paired with phone, otherwise device will read advert from all buttons. While looking I came across NRF.setServices() which sends data only when device is paired. I hope it work like below [see Js code below for Puck]. I now hope I'll find code which will read this service data in android code. Can you suggest your views on this?
var C = {
set : "SET",
update : "UPDATE",
every_30_sec : 3000
};
var iCounter = 0;
function publishTemp(cmd) {
//digitalPulse(LED2, 1, 200);
if (cmd == C.set)
NRF.setServices({
0x1809 : { // Health Thermometer
0x2A6E: {
readable: true,
broadcast: true,
value : iCounter
}}});
if (cmd == C.update)
NRF.updateServices({
0x1809 : { // Health Thermometer
0x2A6E: {
readable: true,
broadcast: true,
value : iCounter
}}});
}
setWatch(function(e)
{
iCounter++;
print(iCounter);
}, BTN, {repeat:true,edge:"rising",debounce:50});
// first time
publishTemp(C.set);
// every 30 sec
setInterval(publishTemp,C.every_30_sec,C.update);
Regards