1 Reply Latest reply on Oct 31, 2015 1:54 PM by maheshb_81

    Service data in advertisement packet

      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?