-
• #2
Sorry for the delay - I was out at an exhibition all last week.
Are you still connected to the Puck.js with another device? That tends to stop advertising.
I'd install
nRF Connect
on your Android phone and check that the Puck really is advertising the correct information - then you can narrow down where the problem lies. -
• #3
Thanks for your response Gordon.. I downloaded nRF Connect and i used the presses example..
Where should i see the number of presses though?? Also if i want to display temp and brightness every so often, what my code should be like?? -
• #4
Ok,
Put this on Puck.js:
function updateAdv() { var data = [Puck.light()*255, Math.round(E.getTemperature())]; NRF.setAdvertising({},{manufacturer: 0x0590, manufacturerData:data}); } updateAdv(); // start off right now setInterval(updateAdv, 30000); // update every 30 seconds
Disconnect from Puck.js, so it starts Advertising
Run nRF Connect
Go to the
Scanner
tab, clickScan
in the top rightFind your Puck.js device, and tap on it (not on the connect button, just the text)
In the data there, you should see 'Manufacturer data', a company ID
0x0590
, and a hex code like0xCA14
.In
0xCA14
,0xCA
is the light value (between 0 and 255) and0x14
is the temperature in degrees C
Hopefully when that works, you can start to figure out about writing your own Android app to receive the data too.
-
• #5
I think it works.. but the other question is how to display in the right format the brightness and temperature values into my Android app?
I tried to use the bluetooth advertisements example https://github.com/googlesamples/android-BluetoothAdvertisements
but what exactly i have to do in order to achieve my goal??
What UUID do i need to include in my Constants class? -
• #6
I'd make sure that you're not filtering the advertisements based on anything at all
Basically you should be getting callbacks with a bunch of
ScanResult
entries: https://github.com/googlesamples/android-BluetoothAdvertisements/blob/master/Application/src/main/java/com/example/android/bluetoothadvertisements/ScannerFragment.java#L202-L228Then you can do
ScannerFragment.getScanRecord(). getManufacturerSpecificData(0x0590)
- the same ID as used in the code I posted above.If you get null, it's not one of your devices. If it is, you should have an array of 2 bytes. First is the light value between 0 and 255, the second is the temperature in degrees C.
-
• #7
Unfortunately can't manage to get it work.. Could you please provide me with more specific info?? I know I'm a bit annoying but i want to get it done.. Where do i have to add the ScannerFragment.getScanRecord(). getManufacturerSpecificData(0x0590) line??
Thanks in advance!
-
• #8
You could just stick it in here: https://github.com/googlesamples/android-BluetoothAdvertisements/blob/master/Application/src/main/java/com/example/android/bluetoothadvertisements/ScanResultAdapter.java#L110
That should get called for every new advertising packet that is received.
-
• #10
Yes - but then obviously you have to do something with the array of byte values that function returns - even if it's only printing them to a log file.
edit: also - you just filed that bug? I'd avoid doing that on people's GitHub - especially Google's one. Just upload the screenshot to the forum :)
-
• #11
Hello Gordon, I want to know how I can send commands to my Puck device from my android custom application classes.. Is it "Bluetooth.write("/n")??
-
• #12
If your using Droidscript, this is how I do it to send data to the Puck.
function OnStart(){ ble = app.CreateBluetoothLE(); } function send(){ ble.SendUart("Hello World"); }
Read it on the Puck with.
Bluetooth.on('data', function(d) { data += d; console.log(data) });
-
• #13
I don't use Droidscript so what to do inside android class?
Hi,
I want to display my Puck's data (temperature and brightness) every 30 minutes in my Android Application.
Can anyone tell me the exact steps to do that?
I have tried this example: https://github.com/googlesamples/android-BluetoothAdvertisements
but nothing is being displayed..