This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to read advertising/service data from Smartphone?

Hi everyone, after i made fast progress with my last "problem" (devzone.nordicsemi.com/.../), my Arduino and nRF8001 is working without an error.

Within my sketch, i use 'lib_aci_open_adv_pipe' on an broadcasting-pipe (pipe 1) and then 'lib_aci_set_local_data' for pipe 2 to send/update my "service data" and in my opinion the Arduino is now broadcasting that it's there (smartphones can see my BLE device) and send "service data" for every device that is in range.

Service.h looks like this:

/* Service: GPS_info - Characteristic: GPSsend - Pipe: BROADCAST */
#define PIPE_GPS_INFO_GPSSEND_BROADCAST          1
#define PIPE_GPS_INFO_GPSSEND_BROADCAST_MAX_SIZE 2

/* Service: GPS_info - Characteristic: GPSsend - Pipe: SET */
#define PIPE_GPS_INFO_GPSSEND_SET          2
#define PIPE_GPS_INFO_GPSSEND_SET_MAX_SIZE 2

Now, i don't know how to display this "service data" on my smartphone. I can see the address of my device (looks like a MAC address) and an an address with 32 characters (i think UUID? It's beginning with A9EBB62D-E34F-3A59....) but this address does not match my characteristic UUID i've set in nRFGo. All the Services, Characteristics and UUID is confusing me.

If i am right, i should listen to my specific characteristic on my smartphone to get the "service data" displayed. But i don't know how to do this. Is there any working example where i can change UUID to my own UUID (characteristic UUID?) to test if smartphone can receive my "service data" ?

Would be very nice if someone could help me. I feel a little bit "lost".

  • You can use the master control panel for Android and verify that your BTLE board is actually advertising. You should be able to see the advertising with Service Data. The format for the Service Data is

    <Length(1 byte)> <AD type(1 byte) = 0x016>

    You will also see the flags AD type i,e < AD data>, then you may see the AD types for Name (shortened or complete) and other AD types for Services.

    Open the XML file that you are using in the nRFgo studio -> nRF8001 Configuration -> GAP Settings Look the the "Select fields to advertise" and "Resulting Advertising Packet" , to see what is actually getting advertised.

  • Hi Star Destroyer, yes, you are right, i can see now "some" data in nRF Master Control Panel. I can see this types: 0x01 0x03 0x09 0x16

    In type 0x16 the Value is "0x400009". In my sketch, there is this part:

    uint8_t test1 = 9; lib_aci_set_local_data(&aci_state, 2, &test1, sizeof(test1));

    So i can see this "9" in nRF Master Control as Service Data. But my new problem is, uint8 maximum value is "255". Change to uint16 doesn't work.

    I think its not possible to send a String like "4829.7450,N,00908.1385,E" (thats the String i want to send as Service Data, two coordinates from GPS Shield).

    If this is not possible, the BLE-Stuff is useless for me :(

    And i still have the question to WHAT i have to listen for to get my service data displayed, if i write my own android app with Eclipse or Android Studio.

    EDIT: An important question: How often can i update service data in sketch?

Related