You are here

Service data in advertisement packet | Cypress Semiconductor

Service data in advertisement packet

Summary: 1 Reply, Latest post by BMAH on 31 Oct 2015 01:54 PM PDT
Verified Answers: 1
Last post
Log in to post new comments.
lipens26_1483021's picture
7 posts

Hello! I want to include service data in advertisement packet. So far I have made it so i can actually see that field changing in CySmart App, but when I try to program Android app to read that field something something goes wrong.

So at the attachment you can see the setup for BLE. In the field data I have written in "00" because otherwise I don't have an index for that field. So in the code I use these three lines to update that field:


#define advPayload                                  (cyBle_discoveryModeInfo.advData->advData)

advPayload[29u] = 0x01;

CyBle_GapUpdateAdvData(cyBle_discoveryModeInfo.advData, cyBle_discoveryModeInfo.scanRspData);


Through CySmart app i can see the changes (I have to stop scan and then start it again). But when I try to write code for android to read that data with these lines:

public static final ParcelUuid THERM_SERVICE = ParcelUuid.fromString("00000000-0000-1000-8000-00805F9B34FB");

public TemperatureBeacon(ScanRecord record, String deviceAddress, int rssi) {

mSignal = rssi;

mAddress = deviceAddress;

mName = record.getDeviceName();

byte[] data = record.getServiceData(THERM_SERVICE);

if (data != null) { mCurrentTemp = data[0]; }

else {

mCurrentTemp = 123; } }


The function just returns NULL, like when no data with such uuid is found. Everything else like address and name is acquired properly. I am using the same parcel uuid for the scan filter and that works fine. So I don't understand what is the problem. Have I set up BLE component wrong?

BMAH's picture
Cypress Employee
189 posts

The BLE component configuration looks right, that is why you are able to observe the updated adv packets in CySmart. This most likely seems to be the custom Android App issue. Have you referred to the CySmart Android App source code?

Log in to post new comments.