3232import java .util .TimerTask ;
3333import java .util .UUID ;
3434
35+ import org .slf4j .Logger ;
36+ import org .slf4j .LoggerFactory ;
37+
3538import se .bitcraze .crazyflielib .crazyradio .ConnectionData ;
3639import se .bitcraze .crazyflielib .crtp .CrtpDriver ;
3740import se .bitcraze .crazyflielib .crtp .CrtpPacket ;
4952import android .bluetooth .BluetoothProfile ;
5053import android .content .Context ;
5154import android .content .Intent ;
52- import android .util .Log ;
5355
5456@ SuppressLint ("NewApi" )
5557public class BleLink extends CrtpDriver {
5658
57- private static final String TAG = "BleLink" ;
59+ final Logger mLogger = LoggerFactory . getLogger ( "BLELink" ) ;
5860
5961 // Set to -40 to connect only to close-by Crazyflie
6062 private static final int rssiThreshold = -100 ;
@@ -120,7 +122,7 @@ public void onServicesDiscovered(BluetoothGatt gatt, int status) {
120122 descriptor .setValue (BluetoothGattDescriptor .ENABLE_NOTIFICATION_VALUE );
121123 gatt .writeDescriptor (descriptor );
122124
123- Log . d ( TAG , "Connected!" );
125+ mLogger . debug ( "Connected!" );
124126
125127 mConnected = true ;
126128 mWritten = false ;
@@ -133,35 +135,35 @@ public void onServicesDiscovered(BluetoothGatt gatt, int status) {
133135 @ Override
134136 public void onCharacteristicWrite (BluetoothGatt gatt , BluetoothGattCharacteristic characteristic , int status ) {
135137 super .onCharacteristicWrite (gatt , characteristic , status );
136- //Log.d(TAG, "On write called for char: " + characteristic.getUuid().toString());
138+ //mLogger.debug( "On write called for char: " + characteristic.getUuid().toString());
137139 mWritten = true ;
138140 }
139141
140142 @ Override
141143 public void onDescriptorWrite (BluetoothGatt gatt , BluetoothGattDescriptor descriptor , int status ) {
142144 super .onDescriptorWrite (gatt , descriptor , status );
143- Log . d ( TAG , "On write called for descriptor: " + descriptor .getUuid ().toString ());
145+ mLogger . debug ( "On write called for descriptor: " + descriptor .getUuid ().toString ());
144146 mWritten = true ;
145147 }
146148
147149 @ Override
148150 public void onCharacteristicRead (BluetoothGatt gatt , BluetoothGattCharacteristic characteristic , int status ) {
149151 super .onCharacteristicRead (gatt , characteristic , status );
150- Log . d ( TAG , "On read call for characteristic: " + characteristic .getUuid ().toString ());
152+ mLogger . debug ( "On read call for characteristic: " + characteristic .getUuid ().toString ());
151153 }
152154
153155 @ Override
154156 public void onCharacteristicChanged (BluetoothGatt gatt , BluetoothGattCharacteristic characteristic ) {
155157 //super.onCharacteristicChanged(gatt, characteristic);
156- Log . d ( TAG , "On changed call for characteristic: " + characteristic .getUuid ().toString ());
158+ mLogger . debug ( "On changed call for characteristic: " + characteristic .getUuid ().toString ());
157159 }
158160 };
159161
160162 private LeScanCallback mLeScanCallback = new LeScanCallback () {
161163 @ Override
162164 public void onLeScan (BluetoothDevice device , int rssi , byte [] anounce ) {
163165 if (device != null && device .getName () != null ) {
164- Log . d ( TAG , "Scanned device \" " + device .getName () + "\" RSSI: " + rssi );
166+ mLogger . debug ( "Scanned device \" " + device .getName () + "\" RSSI: " + rssi );
165167
166168 if (device .getName ().equals (CF_DEVICE_NAME ) && rssi >rssiThreshold ) {
167169 mBluetoothAdapter .stopLeScan (this );
0 commit comments