title: Advertised Data too Large Eddystone Beacon
body: <p>I am trying to make an android application that is able to advertise UID frames based on Eddystone Protocol. The Code for which is as follows</p>
  
  <pre><code>private void advertise() {
      //To check if Bluetooth Multiple Advertising is supported on the Device
      if( !BluetoothAdapter.getDefaultAdapter().isMultipleAdvertisementSupported() ) {
          Toast.makeText( this, "Multiple advertisement not supported", Toast.LENGTH_SHORT ).show();
          start.setEnabled(false);
      }
  
      BluetoothLeAdvertiser advertiser = BluetoothAdapter.getDefaultAdapter().getBluetoothLeAdvertiser();
      //defining the settings used while advertising
      AdvertiseSettings settings = new AdvertiseSettings.Builder().setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED).setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH).setConnectable(true).build();
  
      //We make Parcel UUID(UUID can be generated online) and Advertise Data object
      ParcelUuid pUuid = ParcelUuid.fromString("4db3d4ff-eda4-46e8-bd89-9a7b1f63cc83");
  
      //building servicedata
      byte txPower = (byte) -16;
      byte FrameType = 0x00;
      byte[] namespaceBytes =toByteArray("01020304050607080910");
      Log.e("nB",Integer.toString(namespaceBytes.length));
      byte[] instanceBytes =toByteArray("AABBCCDDEEFF");
      Log.e("instanceIdlength",Integer.toString(instanceBytes.length));
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      try {
          os.write(new byte[]{FrameType,txPower});
          os.write(namespaceBytes);
          os.write(instanceBytes);
      } catch (IOException e) {
          e.printStackTrace();
      }
  
      byte[] serviceData =os.toByteArray();
      Log.e("Service Data Length",Integer.toString(serviceData.length));
      Log.e("ServiceData",serviceData.toString());
  
      AdvertiseData ADdata = new AdvertiseData.Builder().addServiceData(pUuid,serviceData).addServiceUuid(pUuid).setIncludeDeviceName(false).setIncludeTxPowerLevel(false).build();
  
      Log.e("Data",ADdata.toString());
  
  
  
  
       //callback to check success or failure when advertising
      AdvertiseCallback advertisingCallback = new AdvertiseCallback() {
          @Override
          public void onStartSuccess(AdvertiseSettings settingsInEffect) {
              super.onStartSuccess(settingsInEffect);
              Log.e("BLE","Advertising");
              status.setText("Advertising");
              status.setTextColor(Color.GREEN);
              }
          @Override
          public void onStartFailure(int errorCode) {
              Log.e( "BLE", "Advertising onStartFailure: " + errorCode );
              super.onStartFailure(errorCode);
              status.setText("ErrorCode: "+errorCode);
              status.setTextColor(Color.RED);
              }
      };
  
      advertiser.startAdvertising(settings, ADdata, advertisingCallback);
  }
  
  private byte[] toByteArray(String hexString) {
  // hexString guaranteed valid.
  int len = hexString.length();
  byte[] bytes = new byte[len / 2];
  for (int i = 0; i &lt; len; i += 2) {
    bytes[i / 2] = (byte) ((Character.digit(hexString.charAt(i), 16) &lt;&lt; 4)
        + Character.digit(hexString.charAt(i + 1), 16));
  }
  return bytes;}
  </code></pre>
  
  <p>I have followed all the guidelines for frame length.</p>
  
  <pre><code>InstanceID:6bytes
  NameSpaceID:10bytes
  </code></pre>
  
  <p>But I am still not able to advertise data because of Error Code.... <code>:ADVERTISE_FAILED_DATA_TOO_LARGE</code></p>
  
  <p>Is there anything I am missing here ?</p>