BLE Accelerometer bytes

edited March 2016 in Android
I'm building a small app using bluetooth low energy communication, for new C series board (firmware version 1.2.1)

so i was able to control LED lights, and to subscribe for notifys of button push event

but I can't make accelerometer to work

one of the reasons being - can't find documented description of what bytes to send, I've tried to analyze some of available examples i could find and it seems like Accelerometer is module number 3, then seems like i should be sending 3 in the second byte, then 01 or 00? - and I'm going through this "guessing" process instead of just being able to read somewhere this byte means this, and this byte - that

also which UUID should I allow notifications from to receive accelerometer updates?

I'm setting it to main RX characteristic, and that's how i get butten push notifications, but may be problem with accelerometer is that i am not addressing right UUID or characteristic?

this is greeting from my board when i connect it:

["1800","1801","180f","180a","326a9000-85cb-9195-d9dd-464cfbbae75a"],"characteristics":[
{"service":"1800","characteristic":"2a00","properties":["Read","Write"]},
{"service":"1800","characteristic":"2a01","properties":["Read"]},
{"service":"1800","characteristic":"2a04","properties":["Read"]},
{"service":"1801","characteristic":"2a05","properties":["Indicate"],"descriptors":[{"uuid":"2902"}]},
{"service":"180f","characteristic":"2a19","properties":["Read","Notify"],"descriptors":[{"uuid":"2902"}]},
{"service":"180a","characteristic":"2a29","properties":["Read"]},
{"service":"180a","characteristic":"2a24","properties":["Read"]},
{"service":"180a","characteristic":"2a25","properties":["Read"]},
{"service":"180a","characteristic":"2a27","properties":["Read"]},
{"service":"180a","characteristic":"2a26","properties":["Read"]},
{"service":"326a9000-85cb-9195-d9dd-464cfbbae75a","characteristic":"326a9001-85cb-9195-d9dd-464cfbbae75a","properties":["Read","WriteWithoutResponse","Write"]}, ------------(main TX uuid)
{"service":"326a9000-85cb-9195-d9dd-464cfbbae75a","characteristic":"326a9006-85cb-9195-d9dd-464cfbbae75a","properties":["Read","Notify"],"descriptors":[{"uuid":"2902"}]}]} --------------- (main RX uuid)

I've tried 180f->2a19 and it fires some single number(usually in range from 46 to 52) every... 10 seconds and that's it, so it's not an accelerometer

I have tried Reading all the other uuid->chars from this least, they read some static numbers, none of them begins with byte "3" - so not an accelerometer neither (btw would be also nice to see description of those uuids and where they come from)

variants of calling accelerometer I have tried so far are:

0x03, 0x03, 0x00, 0x00, 0x20, 0x00, 0x00 -> sample code says it's the command to start the accelerometer
0x03, 0x02, 0x01 - "enable x axis"
0x03, 0x04, 0x01 - "enable y axis"
0x03, 0x01, 0x01 - "enable z axis"

taken from: https://github.com/ldeluca/metawear/blob/master/plugins/com.lisaseacat.metawear/www/metawear.js

for example setting button to send notifications is 0x01, 0x01, 0x01 - and it works fine after I also setup notify subscription to main RX channel

another variant of accelerometer call, which I found in some JAVA program for more advanced CPro board or something like that was:

0x03, 0x0d, 0x04, 0x0a
0x03, 0x0a, 0x00, 0x14, 0x14, 0x14
0x03, 0x03, 0x20, 0x0c
0x03, 0x07, 0x07, 0x30, 0x81, 0x0b, 0xc0
0x03, 0x01, 0x01

taken from some java example... from this example: https://github.com/brainexe/node-metawear/blob/master/src/registers/accelerometer.js

so only thing I can understand from here is that 03 is truly accelerometer module ID, but what do other parameters do - unkown, neither of these examples start acelerometer(or I am not reading proper UUID/char combination)

no error is returned from Cboard neither, button push and LED control keeps on working properly

thanks for any help


Comments

  • Is there a reason why you are not using the Android API?  
  • I'm writing on phonegap and will need to integrate this functionality into a lot of different things also developed using phonegap
  • The C++ library serves as the documentation of the MetaWear protocol; you should check out the source code + unit tests to find what you need.  Since you're using a C board, the bmi160 accelerometer implementation and unit tests will be of particular interest.

    Alternatively, if I understand how PhoneGap works, we have a Cordova plugin that should cover what you need.
  • I'll check everything above

    about cordova plugin: I was unable to import it to application, either it's outdated version or something doesn't work with it

    neither pgb nor npm versions can be found by phonegap
  • as much as i understand from C++ example, BMI160 start command should look as 3,1,1 right?

    will accelerometer updates coming in through the normal Rx port ( 9006) or different one?
  • edited March 2016
    so thank you, i was able to find appropirate bytes in .py test files

    for anyone who might be looking for same data, for BMi160 accelerometer, starting commands are:

    0x03, 0x04, 0x01
    0x03, 0x01, 0x01
    0x03, 0x02, 0x01, 0x00

    this pretty much fires it up and the information comes flowing into main Rx "port" (incase if u have subscribed for it's notifications beforehand ofcourse)

    for some basic configuration use:

    0x03, 0x03, 0x27, 0x03 (setting to 50 hz)
    0x02, 0x03, 0x28, 0x0c (setting range to 16G)

    turning off:
    0x03, 0x02, 0x00, 0x01
    0x03, 0x04, 0x00
    0x03, 0x01, 0x00

  • Were you using the Cordova plugin here https://github.com/mbientlab-projects/cordova-plugin-metawear  ?  I'm circling back around to this,  but have already implemented accelerometer and LED functionality in the current version.

    Can you give me some more information about your application so that I can help to get this plugin working for you?  IE:  What is the problem you are running into when trying to include the plugin,  what version of phonegap/cordova are you running etc..

    Long term it is going to save you a lot of work the one we are working on instead of you needing to roll your own.
This discussion has been closed.