cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC™ 4

Anonymous
Not applicable

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:

   

 <code> 

   

#define advPayload                                  (cyBle_discoveryModeInfo.advData->advData)

   

advPayload[29u] = 0x01;

   

CyBle_GapUpdateAdvData(cyBle_discoveryModeInfo.advData, cyBle_discoveryModeInfo.scanRspData);

   

 </code> 

   

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:

   

 <code> 
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; } }

   

 </code> 

   

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?

0 Likes
1 Solution
Anonymous
Not applicable

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?

View solution in original post

0 Likes
1 Reply
Anonymous
Not applicable

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?

View solution in original post

0 Likes