Example usage for android.bluetooth BluetoothGattService getUuid

List of usage examples for android.bluetooth BluetoothGattService getUuid

Introduction

In this page you can find the example usage for android.bluetooth BluetoothGattService getUuid.

Prototype

public UUID getUuid() 

Source Link

Document

Returns the UUID of this service

Usage

From source file:com.ucai.test.control.DeviceControlActivity.java

/**
 * ???GATT?/?/*from  w  ww .  ja  v a  2 s.  com*/
 * ,?ExpandableListViewUI
 *
 * @param gattServices
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private void displayGattServices(List<BluetoothGattService> gattServices) {
    if (gattServices == null)
        return;
    String uuid = null;
    String unknownServiceString = getResources().getString(R.string.unknown_service);
    String unknownCharaString = getResources().getString(R.string.unknown_characteristic);
    ArrayList<HashMap<String, String>> gattServiceData = new ArrayList<HashMap<String, String>>();
    ArrayList<ArrayList<HashMap<String, String>>> gattCharacteristicData = new ArrayList<ArrayList<HashMap<String, String>>>();
    mGattCharacteristics = new ArrayList<ArrayList<BluetoothGattCharacteristic>>();

    // Loops through available GATT Services.
    //???GATT?
    for (BluetoothGattService gattService : gattServices) {
        HashMap<String, String> currentServiceData = new HashMap<String, String>();
        uuid = gattService.getUuid().toString();
        currentServiceData.put(LIST_NAME, SampleGattAttributes.lookup(uuid, unknownServiceString));
        currentServiceData.put(LIST_UUID, uuid);
        gattServiceData.add(currentServiceData);

        ArrayList<HashMap<String, String>> gattCharacteristicGroupData = new ArrayList<HashMap<String, String>>();
        List<BluetoothGattCharacteristic> gattCharacteristics = gattService.getCharacteristics();
        ArrayList<BluetoothGattCharacteristic> charas = new ArrayList<BluetoothGattCharacteristic>();
        //Log.e("/g", "" + uuid);
        // Loops through available Characteristics.
        //???
        for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
            charas.add(gattCharacteristic);
            HashMap<String, String> currentCharaData = new HashMap<String, String>();
            uuid = gattCharacteristic.getUuid().toString();
            currentCharaData.put(LIST_NAME, SampleGattAttributes.lookup(uuid, unknownCharaString));
            currentCharaData.put(LIST_UUID, uuid);
            gattCharacteristicGroupData.add(currentCharaData);
            //TODO ?uuid
            Log.e("/t", "" + uuid);
        }
        mGattCharacteristics.add(charas);
        gattCharacteristicData.add(gattCharacteristicGroupData);
        Log.e("cst", "load over");
    }

    /*SimpleExpandableListAdapter gattServiceAdapter = new SimpleExpandableListAdapter(
        this,
        gattServiceData,
        android.R.layout.simple_expandable_list_item_2,
        new String[]{LIST_NAME, LIST_UUID},
        new int[]{android.R.id.text1, android.R.id.text2},
        gattCharacteristicData,
        android.R.layout.simple_expandable_list_item_2,
        new String[]{LIST_NAME, LIST_UUID},
        new int[]{android.R.id.text1, android.R.id.text2}
            
    );
    mGattServicesList.setAdapter(gattServiceAdapter);*/
}

From source file:undot.safedrivers.BLE.BluetoothLeService.java

private void getGattServices(List<BluetoothGattService> gattServices) {
    if (gattServices == null)
        return;//from w  ww .  j  a  va2 s.  co m
    String uuid = null;
    mModelNumberCharacteristic = null;
    mSerialPortCharacteristic = null;
    mCommandCharacteristic = null;
    mGattCharacteristics = new ArrayList<ArrayList<BluetoothGattCharacteristic>>();

    // Loops through available GATT Services.
    for (BluetoothGattService gattService : gattServices) {
        uuid = gattService.getUuid().toString();
        System.out.println("displayGattServices + uuid=" + uuid);

        List<BluetoothGattCharacteristic> gattCharacteristics = gattService.getCharacteristics();
        ArrayList<BluetoothGattCharacteristic> charas = new ArrayList<BluetoothGattCharacteristic>();

        // Loops through available Characteristics.
        for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
            charas.add(gattCharacteristic);
            uuid = gattCharacteristic.getUuid().toString();
            if (uuid.equals(ModelNumberStringUUID)) {
                mModelNumberCharacteristic = gattCharacteristic;
                System.out.println(
                        "mModelNumberCharacteristic  " + mModelNumberCharacteristic.getUuid().toString());
            } else if (uuid.equals(SerialPortUUID)) {
                mSerialPortCharacteristic = gattCharacteristic;
                System.out.println(
                        "mSerialPortCharacteristic  " + mSerialPortCharacteristic.getUuid().toString());
                //                    updateConnectionState(R.string.comm_establish);
            } else if (uuid.equals(CommandUUID)) {
                mCommandCharacteristic = gattCharacteristic;
                System.out.println(
                        "mSerialPortCharacteristic  " + mSerialPortCharacteristic.getUuid().toString());
                //                    updateConnectionState(R.string.comm_establish);
            }
        }
        mGattCharacteristics.add(charas);
    }

    if (mModelNumberCharacteristic == null || mSerialPortCharacteristic == null
            || mCommandCharacteristic == null) {
        Log.d("charactaristics", "null");
        Toast.makeText(getApplicationContext(), "characteristics null", Toast.LENGTH_SHORT);
    } else {
        mSCharacteristic = mModelNumberCharacteristic;
        setCharacteristicNotification(mSCharacteristic, true);
        readCharacteristic(mSCharacteristic);
    }

}

From source file:com.cypress.cysmart.GATTDBFragments.GattDetailsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.gattdb_details, container, false);
    this.mContainer = container;
    mApplication = (CySmartApplication) getActivity().getApplication();
    mServiceName = (TextView) rootView.findViewById(R.id.txtservicename);
    mHexValue = (TextView) rootView.findViewById(R.id.txthex);
    mCharacteristiceName = (TextView) rootView.findViewById(R.id.txtcharatrname);
    mBtnnotify = (TextView) rootView.findViewById(R.id.txtnotify);
    mBtnIndicate = (TextView) rootView.findViewById(R.id.txtindicate);
    mBtnread = (TextView) rootView.findViewById(R.id.txtread);
    mBtnwrite = (TextView) rootView.findViewById(R.id.txtwrite);
    mAsciivalue = (TextView) rootView.findViewById(R.id.txtascii);
    mTimevalue = (TextView) rootView.findViewById(R.id.txttime);
    mDatevalue = (TextView) rootView.findViewById(R.id.txtdate);
    backbtn = (ImageView) rootView.findViewById(R.id.imgback);
    mProgressDialog = new ProgressDialog(getActivity());
    /**/* w  ww .  ja  v a 2  s.co  m*/
     * Soft back button listner
     */
    backbtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            getActivity().onBackPressed();

        }
    });
    btn_descriptor = (Button) rootView.findViewById(R.id.characteristic_descriptors);
    if (mApplication.getBluetoothgattcharacteristic().getDescriptors().size() == 0) {
        btn_descriptor.setVisibility(View.GONE);
    }
    /**
     * Descriptor button listner
     */
    btn_descriptor.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            /**
             * Passing the characteristic details to GattDetailsFragment and
             * adding that fragment to the view
             */
            Bundle bundle = new Bundle();
            bundle.putString(Constants.GATTDB_SELECTED_SERVICE, mServiceName.getText().toString());
            bundle.putString(Constants.GATTDB_SELECTED_CHARACTERISTICE,
                    mCharacteristiceName.getText().toString());
            FragmentManager fragmentManager = getFragmentManager();
            GattDescriptorFragment gattDescriptorFragment = new GattDescriptorFragment().create();
            gattDescriptorFragment.setArguments(bundle);
            fragmentManager.beginTransaction().add(R.id.container, gattDescriptorFragment).addToBackStack(null)
                    .commit();
        }
    });
    RelativeLayout parent = (RelativeLayout) rootView.findViewById(R.id.parent);
    parent.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {

        }
    });
    /**
     * button listeners
     */
    mBtnread.setOnClickListener(this);
    mBtnnotify.setOnClickListener(this);
    mBtnIndicate.setOnClickListener(this);
    mBtnwrite.setOnClickListener(this);

    mServiceName.setSelected(true);
    mCharacteristiceName.setSelected(true);
    mAsciivalue.setSelected(true);
    mHexValue.setSelected(true);

    // Getting the characteristics from the application
    mReadCharacteristic = mApplication.getBluetoothgattcharacteristic();
    mNotifyCharacteristic = mApplication.getBluetoothgattcharacteristic();
    Bundle bundle = this.getArguments();
    if (bundle != null) {
        mServiceName.setText(bundle.getString(Constants.GATTDB_SELECTED_SERVICE));
        mCharacteristiceName.setText(bundle.getString(Constants.GATTDB_SELECTED_CHARACTERISTICE));
    }
    startNotifyText = getResources().getString(R.string.gatt_services_notify);
    stopNotifyText = getResources().getString(R.string.gatt_services_stop_notify);
    startIndicateText = getResources().getString(R.string.gatt_services_indicate);
    stopIndicateText = getResources().getString(R.string.gatt_services_stop_indicate);
    UIbuttonvisibility();
    setHasOptionsMenu(true);
    /**
     * Check for HID Service
     */
    BluetoothGattService mBluetoothGattService = mReadCharacteristic.getService();
    if (mBluetoothGattService.getUuid().toString()
            .equalsIgnoreCase(GattAttributes.HUMAN_INTERFACE_DEVICE_SERVICE)) {
        showHIDWarningMessage();
    }
    Logger.i("Notification status---->" + mIsNotifyEnabled);
    return rootView;
}

From source file:de.dmarcini.bt.homelight.HomeLightMainActivity.java

/**
 * Iteriere durch die gefundenen Servivces des entfernten Gertes und finde UART Service
 *
 * @param gattServices Liste von services
 *//*  w  w w .ja  v  a  2s.  com*/
private void reconGattServices(List<BluetoothGattService> gattServices) {
    if (gattServices == null) {
        return;
    }
    String uuid;
    String unknownServiceString = getResources().getString(R.string.main_ble_unknown_service);
    //
    // durchsuche die verfgbaren Services
    //
    for (BluetoothGattService gattService : gattServices) {
        uuid = gattService.getUuid().toString();
        //
        // Gibt es den UART Servive, dann gib Bescheid!
        //
        if (HM10GattAttributes.lookup(uuid, unknownServiceString).equals("HM 10 Serial")) {
            btConfig.setIsUART(true);
        } else {
            btConfig.setIsUART(false);
        }
        // get characteristic when UUID matches RX/TX UUID
        btConfig.setCharacteristicTX(gattService.getCharacteristic(ProjectConst.UUID_HM_RX_TX));
        btConfig.setCharacteristicRX(gattService.getCharacteristic(ProjectConst.UUID_HM_RX_TX));
        //
        // wenn die Kommunikation sichergestellt ist, frage nach dem Modul
        //
        askModulForType();
    }

}

From source file:com.example.ecgfile.DeviceControlActivity.java

@SuppressLint("SimpleDateFormat")
private void getGattServices(List<BluetoothGattService> gattServices) {
    System.out.println("getGattServices");
    if (gattServices == null) {
        System.out.println("getGattServices null ");
        return;//from w  w w.  ja  v a  2  s .  com
    }
    String uuid = null;

    // Loops through available GATT Services.
    for (BluetoothGattService gattService : gattServices) {
        uuid = gattService.getUuid().toString();
        if (uuid.equals("0000ffe0-0000-1000-8000-00805f9b34fb")
                || uuid.equals("0000ffe5-0000-1000-8000-00805f9b34fb")) { // 2uuid service

            List<BluetoothGattCharacteristic> gattCharacteristics = gattService.getCharacteristics();
            ArrayList<BluetoothGattCharacteristic> charas = new ArrayList<BluetoothGattCharacteristic>();

            // Loops through available Characteristics.
            for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
                charas.add(gattCharacteristic);
                uuid = gattCharacteristic.getUuid().toString();
                if (uuid.equals("0000ffe4-0000-1000-8000-00805f9b34fb")) {
                    mNotifyCharacteristic = gattCharacteristic;
                    Toast.makeText(getApplicationContext(), "", Toast.LENGTH_SHORT).show();
                }
                if (uuid.equals("0000ffe9-0000-1000-8000-00805f9b34fb")) {
                    mNCharW = gattCharacteristic;
                }
            }
        }
    }
}

From source file:com.example.android.bluetoothlegatt.DeviceControlActivity.java

/**
 * Setup {@link com.example.android.bluetoothlegatt.BluetoothLeService} by specifying default
 * {@link android.bluetooth.BluetoothGattService} and read, write, notify {@link android.bluetooth.BluetoothGattCharacteristic}.
 * Called only if the device connects to launchpad via Bluetooth.
 *//* www  .  ja  v a  2s .  c  o  m*/
private void setupBluetoothLeService() {
    if (mBluetoothLeService == null) {
        Log.w(TAG, "no BLE service in background");
        finish();
    }
    List<BluetoothGattService> gattServices = mBluetoothLeService.getSupportedGattServices();
    if (gattServices == null) {
        Log.w(TAG, "no GATT service found.");
        finish();
    }

    // Look for default service
    for (BluetoothGattService gattService : gattServices) {
        clearCharacteristicSetup();

        // MSP430 launchpad
        if (gattService.getUuid().toString().equalsIgnoreCase(DEFAULT_MSP430_SERVICE_UUID)) {
            if (bluetoothLookup(gattService, DEFAULT_MSP430_READ_CHARACTERISTIC_UUID,
                    DEFAULT_MSP430_WRITE_CHARACTERISTIC_UUID, DEFAULT_MSP430_NOTIFY_CHARACTERISTIC_UUID)) {
                isMsp430 = true;
                return;
            } else {
                clearCharacteristicSetup();
            }
        }
        // SimpleBlePeripheral
        else if (gattService.getUuid().toString().equalsIgnoreCase(GraphActivity.DEFAULT_GRAPH_SERVICE_UUID)) {
            if (bluetoothLookup(gattService, GraphActivity.DEFAULT_GRAPH_READ_CHARACTERISTIC_UUID,
                    GraphActivity.DEFAULT_GRAPH_WRITE_CHARACTERISTIC_UUID,
                    GraphActivity.DEFAULT_GRAPH_NOTIFY_CHARACTERISTIC_UUID)) {
                isMsp430 = false;
                openGraphActivity(null);
                return;
            } else {
                clearCharacteristicSetup();
            }
        }
    }
    Toast.makeText(this, "Bluetooth configuration could not be setup.", Toast.LENGTH_LONG).show();
    DeviceControlActivity.this.finish();
}

From source file:com.cypress.cysmart.BLEServiceFragments.FindMeService.java

/**
 * Method to get required characteristics from service
 */// w ww .ja  v a 2 s .  c  o  m
private void getGattData() {
    LinearLayout ll_layout = (LinearLayout) rootView.findViewById(R.id.linkloss_layout);
    LinearLayout im_layout = (LinearLayout) rootView.findViewById(R.id.immalert_layout);
    LinearLayout tp_layout = (LinearLayout) rootView.findViewById(R.id.transmission_layout);
    RelativeLayout tpr_layout = (RelativeLayout) rootView.findViewById(R.id.transmission_rel_layout);

    for (int position = 0; position < mExtraservice.size(); position++) {
        HashMap<String, BluetoothGattService> item = mExtraservice.get(position);
        BluetoothGattService bgs = item.get("UUID");
        List<BluetoothGattCharacteristic> gattCharacteristicsCurrent = bgs.getCharacteristics();
        for (final BluetoothGattCharacteristic gattCharacteristic : gattCharacteristicsCurrent) {
            String uuidchara = gattCharacteristic.getUuid().toString();
            if (uuidchara.equalsIgnoreCase(GattAttributes.ALERT_LEVEL)) {
                if (bgs.getUuid().toString().equalsIgnoreCase(GattAttributes.LINK_LOSS_SERVICE)) {
                    ll_layout.setVisibility(View.VISIBLE);
                    mSpinnerLinkLoss = (CustomSpinner) rootView.findViewById(R.id.linkloss_spinner);
                    // Create an ArrayAdapter using the string array and a
                    // default
                    // spinner layout
                    ArrayAdapter<CharSequence> adapter_linkloss = ArrayAdapter.createFromResource(getActivity(),
                            R.array.findme_immediate_alert_array, android.R.layout.simple_spinner_item);
                    // Specify the layout to use when the list of choices
                    // appears
                    adapter_linkloss.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                    // Apply the adapter to the spinner
                    mSpinnerLinkLoss.setAdapter(adapter_linkloss);
                    mSpinnerLinkLoss.setOnItemSelectedListener(new OnItemSelectedListener() {

                        @Override
                        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

                            if (parent.getItemAtPosition(position).toString().equalsIgnoreCase("No Alert")) {
                                byte[] convertedBytes = convertingTobyteArray(IMM_NO_ALERT);
                                BluetoothLeService.writeCharacteristicNoresponse(gattCharacteristic,
                                        convertedBytes);
                                Toast.makeText(getActivity(),
                                        getResources().getString(R.string.find_value_written_toast)
                                                + IMM_NO_ALERT_TEXT
                                                + getResources().getString(R.string.find_value_success_toast),
                                        Toast.LENGTH_SHORT).show();
                            }
                            if (parent.getItemAtPosition(position).toString().equalsIgnoreCase("Mid Alert")) {
                                byte[] convertedBytes = convertingTobyteArray(IMM_MID_ALERT);
                                BluetoothLeService.writeCharacteristicNoresponse(gattCharacteristic,
                                        convertedBytes);
                                Toast.makeText(getActivity(),
                                        getResources().getString(R.string.find_value_written_toast)
                                                + IMM_MID_ALERT_TEXT
                                                + getResources().getString(R.string.find_value_success_toast),
                                        Toast.LENGTH_SHORT).show();
                            }
                            if (parent.getItemAtPosition(position).toString().equalsIgnoreCase("High Alert")) {
                                byte[] convertedBytes = convertingTobyteArray(IMM_HIGH_ALERT);
                                BluetoothLeService.writeCharacteristicNoresponse(gattCharacteristic,
                                        convertedBytes);
                                Toast.makeText(getActivity(),
                                        getResources().getString(R.string.find_value_written_toast)
                                                + IMM_HIGH_ALERT_TEXT
                                                + getResources().getString(R.string.find_value_success_toast),
                                        Toast.LENGTH_SHORT).show();
                            }

                        }

                        @Override
                        public void onNothingSelected(AdapterView<?> parent) {
                            // TODO Auto-generated method stub

                        }
                    });
                }
                if (bgs.getUuid().toString().equalsIgnoreCase(GattAttributes.IMMEDIATE_ALERT_SERVICE)) {
                    im_layout.setVisibility(View.VISIBLE);
                    mSpinnerImmediateAlert = (CustomSpinner) rootView.findViewById(R.id.immediate_spinner);
                    // Create an ArrayAdapter using the string array and a
                    // default
                    // spinner layout
                    ArrayAdapter<CharSequence> adapter_immediate_alert = ArrayAdapter.createFromResource(
                            getActivity(), R.array.findme_immediate_alert_array,
                            android.R.layout.simple_spinner_item);
                    // Specify the layout to use when the list of choices
                    // appears
                    adapter_immediate_alert
                            .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                    // Apply the adapter to the spinner
                    mSpinnerImmediateAlert.setAdapter(adapter_immediate_alert);
                    mSpinnerImmediateAlert.setOnItemSelectedListener(new OnItemSelectedListener() {

                        @Override
                        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

                            if (parent.getItemAtPosition(position).toString().equalsIgnoreCase("No Alert")) {
                                byte[] convertedBytes = convertingTobyteArray(IMM_NO_ALERT);
                                BluetoothLeService.writeCharacteristicNoresponse(gattCharacteristic,
                                        convertedBytes);
                                Toast.makeText(getActivity(),
                                        getResources().getString(R.string.find_value_written_toast)
                                                + IMM_NO_ALERT_TEXT
                                                + getResources().getString(R.string.find_value_success_toast),
                                        Toast.LENGTH_SHORT).show();
                            }
                            if (parent.getItemAtPosition(position).toString().equalsIgnoreCase("Mid Alert")) {
                                byte[] convertedBytes = convertingTobyteArray(IMM_MID_ALERT);
                                BluetoothLeService.writeCharacteristicNoresponse(gattCharacteristic,
                                        convertedBytes);
                                Toast.makeText(getActivity(),
                                        getResources().getString(R.string.find_value_written_toast)
                                                + IMM_MID_ALERT_TEXT
                                                + getResources().getString(R.string.find_value_success_toast),
                                        Toast.LENGTH_SHORT).show();
                            }
                            if (parent.getItemAtPosition(position).toString().equalsIgnoreCase("High Alert")) {
                                byte[] convertedBytes = convertingTobyteArray(IMM_HIGH_ALERT);
                                BluetoothLeService.writeCharacteristicNoresponse(gattCharacteristic,
                                        convertedBytes);
                                Toast.makeText(getActivity(),
                                        getResources().getString(R.string.find_value_written_toast)
                                                + IMM_HIGH_ALERT_TEXT
                                                + getResources().getString(R.string.find_value_success_toast),
                                        Toast.LENGTH_SHORT).show();
                            }

                        }

                        @Override
                        public void onNothingSelected(AdapterView<?> parent) {
                            // TODO Auto-generated method stub

                        }
                    });
                }

            }
            if (uuidchara.equalsIgnoreCase(GattAttributes.TRANSMISSION_POWER_LEVEL)) {
                tp_layout.setVisibility(View.VISIBLE);
                tpr_layout.setVisibility(View.VISIBLE);
                mReadCharacteristic_tp = gattCharacteristic;
                mTransmissionPower = (ImageView) rootView.findViewById(R.id.findme_tx_power_img);
                mTransmissionPowerValue = (TextView) rootView.findViewById(R.id.findme_tx_power_txt);
                if (mReadCharacteristic_tp != null) {
                    prepareBroadcastDataReadtp(mReadCharacteristic_tp);
                }

            }

        }
    }

}

From source file:com.cypress.cysmart.CommonFragments.ProfileScanningFragment.java

/**
 * Check whether SensorHub related services are present in the discovered
 * services//from  w  w  w.  ja v a  2 s. c om
 *
 * @param gattServices
 * @return {@link Boolean}
 */
boolean isSensorHubPresent(List<BluetoothGattService> gattServices) {
    boolean present = false;
    for (BluetoothGattService gattService : gattServices) {
        String uuid = gattService.getUuid().toString();
        if (uuid.equalsIgnoreCase(GattAttributes.BAROMETER_SERVICE)) {
            present = true;
        }
    }
    return present;
}

From source file:io.v.android.impl.google.discovery.plugins.ble.Driver.java

public void onGattRead(BluetoothDevice device, BluetoothGattService service) {
    Map<String, byte[]> characteristics;
    ImmutableMap.Builder<String, byte[]> builder = new ImmutableMap.Builder();
    for (BluetoothGattCharacteristic c : service.getCharacteristics()) {
        builder.put(c.getUuid().toString(), c.getValue());
    }/*w w w.j  ava2 s  .  c om*/
    characteristics = builder.build();

    synchronized (this) {
        if (mScanSeens == null) {
            return;
        }
        Integer rssi = mScanSeens.get(device);
        if (rssi == null) {
            return;
        }
        mScanHandler.onDiscovered(service.getUuid().toString(), characteristics, rssi);
        mOnServiceReadCallbacks++;
    }
}

From source file:com.cypress.cysmart.CommonFragments.ProfileScanningFragment.java

private void prepareSensorHubData(List<BluetoothGattService> gattServices) {

    boolean mGattSet = false;
    boolean mSensorHubSet = false;

    if (gattServices == null)
        return;//w w w .  j a  v  a2s . co  m
    // Clear all array list before entering values.
    gattServiceData.clear();
    gattServiceMasterData.clear();
    gattServiceSensorHubData.clear();

    // Loops through available GATT Services.
    for (BluetoothGattService gattService : gattServices) {
        HashMap<String, BluetoothGattService> currentServiceData = new HashMap<String, BluetoothGattService>();
        String uuid = gattService.getUuid().toString();

        // Optimization code for SensorHub Profile
        if (uuid.equalsIgnoreCase(GattAttributes.LINK_LOSS_SERVICE)
                || uuid.equalsIgnoreCase(GattAttributes.TRANSMISSION_POWER_SERVICE)
                || uuid.equalsIgnoreCase(GattAttributes.IMMEDIATE_ALERT_SERVICE)
                || uuid.equalsIgnoreCase(GattAttributes.BAROMETER_SERVICE)
                || uuid.equalsIgnoreCase(GattAttributes.ACCELEROMETER_SERVICE)
                || uuid.equalsIgnoreCase(GattAttributes.ANALOG_TEMPERATURE_SERVICE)
                || uuid.equalsIgnoreCase(GattAttributes.BATTERY_SERVICE)
                || uuid.equalsIgnoreCase(GattAttributes.DEVICE_INFORMATION_SERVICE)) {
            currentServiceData.put(LIST_UUID, gattService);
            gattServiceMasterData.add(currentServiceData);
            if (!gattServiceSensorHubData.contains(currentServiceData)) {
                gattServiceSensorHubData.add(currentServiceData);
            }
            if (!mSensorHubSet && uuid.equalsIgnoreCase(GattAttributes.BAROMETER_SERVICE)) {
                mSensorHubSet = true;
                gattServiceData.add(currentServiceData);
            }

        } // Optimization code for GATTDB
        else if (uuid.equalsIgnoreCase(GattAttributes.GENERIC_ACCESS_SERVICE)
                || uuid.equalsIgnoreCase(GattAttributes.GENERIC_ATTRIBUTE_SERVICE)) {
            currentServiceData.put(LIST_UUID, gattService);
            gattdbServiceData.add(currentServiceData);
            if (!mGattSet) {
                mGattSet = true;
                gattServiceData.add(currentServiceData);
            }

        } else {
            currentServiceData.put(LIST_UUID, gattService);
            gattServiceMasterData.add(currentServiceData);
            gattServiceData.add(currentServiceData);
        }
    }
    application.setGattServiceMasterData(gattServiceMasterData);
    application.setGattServiceData(gattServiceData);

    // All service discovered and optimized.Dismiss the alert dialog
    if (gattdbServiceData.size() > 0) {
        mConnectHandler.removeCallbacksAndMessages(null);
        if (mpdia != null && mpdia.isShowing()) {
            mpdia.dismiss();
        }
        /**
         * Setting the handler flag to false. adding new fragment
         * ProfileControlFragment to the view
         */
        HANDLER_FLAG = false;
        if (receiverEnabled) {
            getActivity().unregisterReceiver(mGattUpdateReceiver);
            receiverEnabled = false;
            FragmentManager fragmentManager = getFragmentManager();
            ProfileControlFragment profileControlFragment = new ProfileControlFragment().create(mDeviceName,
                    mDeviceAddress);
            fragmentManager.beginTransaction()
                    .add(R.id.container, profileControlFragment, Constants.PROFILE_CONTROL_FRAGMENT_TAG)
                    .addToBackStack(null).commit();
        }

    }

}