Press "Enter" to skip to content

[태그:] Characteristic

블루투스 Characteristic 조회

{
    List<BluetoothGattService> gattServices = bBluetoothLeService.agetInstance().lmBGatt.getServices();

    if ( gattServices == null )
    {
        return;
    }
    String uuid = null;
    String unknownServiceString = "모르는 서비스";
    String unknownCharaString = "모르는 특성";

    ArrayList<HashMap<String, String>> gattServiceData = new ArrayList<HashMap<String, String>>();
    ArrayList<ArrayList<HashMap<String, String>>> gattCharacteristicData = new ArrayList<ArrayList<HashMap<String, String>>>();
    ArrayList<ArrayList<BluetoothGattCharacteristic>> mGattCharacteristics = new ArrayList<ArrayList<BluetoothGattCharacteristic>>();

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

        gattServiceData.add( currentServiceData );

        ArrayList<HashMap<String, String>> gattCharacteristicGroupData = new ArrayList<HashMap<String, String>>();
        List<BluetoothGattCharacteristic> gattCharacteristics = gattService.getCharacteristics();
        ArrayList<BluetoothGattCharacteristic> charas = new ArrayList<BluetoothGattCharacteristic>();

        // Loops through available Characteristics.
        for ( BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics )
        {
            charas.add( gattCharacteristic );
            HashMap<String, String> currentCharaData = new HashMap<String, String>();
            uuid = gattCharacteristic.getUuid().toString();
            gattCharacteristicGroupData.add( currentCharaData );

            List<BluetoothGattDescriptor> diss = gattCharacteristic.getDescriptors();
            for ( BluetoothGattDescriptor d : diss )
            {

                uuid = d.getUuid().toString();
                uuid = d.getUuid().toString();


            }
        }
        mGattCharacteristics.add( charas );
        gattCharacteristicData.add( gattCharacteristicGroupData );
    }
}