test_class.declarator: mockSerialService
test_class.original_string: BluetoothGattService mockSerialService;
test_class.type: BluetoothGattService
test_class.var_name: mockSerialService
test_class.declarator: mockScratchService
test_class.original_string: BluetoothGattService mockScratchService;
test_class.type: BluetoothGattService
test_class.var_name: mockScratchService
test_class.declarator: mockChar
test_class.original_string: BluetoothGattCharacteristic mockChar;
test_class.type: BluetoothGattCharacteristic
test_class.var_name: mockChar
test_class.declarator: mockGattClient
test_class.original_string: GattClient mockGattClient;
test_class.type: GattClient
test_class.var_name: mockGattClient
test_class.declarator: mockHandler
test_class.original_string: Handler mockHandler;
test_class.type: Handler
test_class.var_name: mockHandler
test_class.declarator: mockListener
test_class.original_string: GattSerialTransportProfile.SerialListener mockListener;
test_class.type: GattSerialTransportProfile.SerialListener
test_class.var_name: mockListener
test_class.declarator: gstp
test_class.original_string: GattSerialTransportProfile gstp;
test_class.type: GattSerialTransportProfile
test_class.var_name: gstp
test_class.file: sdk/src/test/java/com/punchthrough/bean/sdk/internal/serial/GattSerialTransportProfileTest.java
test_class.identifier: GattSerialTransportProfileTest
test_case.body: @Test
      public void testOnCharacteristicChanged() throws NoEnumFoundException {
          // More setup
          byte[] value = {1, 2, 3};
          int index = 1;
          ScratchBank bank = EnumParse.enumWithRawValue(ScratchBank.class, index);
          gstp.setListener(mockListener);
          BluetoothGattCharacteristic mockChar = mock(BluetoothGattCharacteristic.class);
          when(mockChar.getUuid()).thenReturn(Constants.UUID_SCRATCH_CHAR_1);
          when(mockChar.getValue()).thenReturn(value);
  
          // Test and verify
          gstp.onCharacteristicChanged(mockGattClient, mockChar);
          verify(mockListener).onScratchValueChanged(bank, value);
      }
test_case.class_method_signature: GattSerialTransportProfileTest.testOnCharacteristicChanged()
test_case.full_signature: @Test public void testOnCharacteristicChanged()
test_case.identifier: testOnCharacteristicChanged
test_case.invocations: enumWithRawValue setListener mock thenReturn when getUuid thenReturn when getValue onCharacteristicChanged onScratchValueChanged verify
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testOnCharacteristicChanged()
focal_class.declarator: TAG = "GattSerialXportProfile"
focal_class.modifier: protected static final
focal_class.original_string: protected static final String TAG = "GattSerialXportProfile";
focal_class.type: String
focal_class.var_name: TAG
focal_class.declarator: PACKET_TX_MAX_PAYLOAD_LENGTH = 19
focal_class.modifier: public static final
focal_class.original_string: public static final int PACKET_TX_MAX_PAYLOAD_LENGTH = 19;
focal_class.type: int
focal_class.var_name: PACKET_TX_MAX_PAYLOAD_LENGTH
focal_class.declarator: BEAN_SCRATCH_UUIDS = Arrays.asList(
              Constants.UUID_SCRATCH_CHAR_1,
              Constants.UUID_SCRATCH_CHAR_2,
              Constants.UUID_SCRATCH_CHAR_3,
              Constants.UUID_SCRATCH_CHAR_4,
              Constants.UUID_SCRATCH_CHAR_5
      )
focal_class.modifier: private static final
focal_class.original_string: private static final List<UUID> BEAN_SCRATCH_UUIDS = Arrays.asList(
              Constants.UUID_SCRATCH_CHAR_1,
              Constants.UUID_SCRATCH_CHAR_2,
              Constants.UUID_SCRATCH_CHAR_3,
              Constants.UUID_SCRATCH_CHAR_4,
              Constants.UUID_SCRATCH_CHAR_5
      );
focal_class.type: List<UUID>
focal_class.var_name: BEAN_SCRATCH_UUIDS
focal_class.declarator: mListener
focal_class.modifier: private
focal_class.original_string: private SerialListener mListener;
focal_class.type: SerialListener
focal_class.var_name: mListener
focal_class.declarator: mSerialCharacteristic
focal_class.modifier: private
focal_class.original_string: private BluetoothGattCharacteristic mSerialCharacteristic;
focal_class.type: BluetoothGattCharacteristic
focal_class.var_name: mSerialCharacteristic
focal_class.declarator: mHandler
focal_class.modifier: private
focal_class.original_string: private Handler mHandler;
focal_class.type: Handler
focal_class.var_name: mHandler
focal_class.declarator: mMessageAssembler = new MessageAssembler()
focal_class.modifier: private
focal_class.original_string: private MessageAssembler mMessageAssembler = new MessageAssembler();
focal_class.type: MessageAssembler
focal_class.var_name: mMessageAssembler
focal_class.declarator: ready = false
focal_class.modifier: private
focal_class.original_string: private boolean ready = false;
focal_class.type: boolean
focal_class.var_name: ready
focal_class.declarator: mReadyToSend = false
focal_class.modifier: private
focal_class.original_string: private boolean mReadyToSend = false;
focal_class.type: boolean
focal_class.var_name: mReadyToSend
focal_class.declarator: mPendingPackets = new ArrayList<>(32)
focal_class.modifier: private
focal_class.original_string: private List<GattSerialPacket> mPendingPackets = new ArrayList<>(32);
focal_class.type: List<GattSerialPacket>
focal_class.var_name: mPendingPackets
focal_class.declarator: mOutgoingMessageCount = 0
focal_class.modifier: private
focal_class.original_string: private int mOutgoingMessageCount = 0;
focal_class.type: int
focal_class.var_name: mOutgoingMessageCount
focal_class.declarator: mDequeueRunnable = new Runnable() {
          @Override
          public void run() {
              if (!mPendingPackets.isEmpty()) {
                  if (mReadyToSend && mSerialCharacteristic != null) {
                      mReadyToSend = false;
                      GattSerialPacket packet = mPendingPackets.remove(0);
                      mSerialCharacteristic.setValue(packet.getPacketData());
                      if (!mGattClient.writeCharacteristic(mSerialCharacteristic)) {
                          Log.e(TAG, "Failed char write");
                      }
                  } else {
                      mHandler.postDelayed(this, 150);
                  }
              }
          }
      }
focal_class.modifier: private final
focal_class.original_string: private final Runnable mDequeueRunnable = new Runnable() {
          @Override
          public void run() {
              if (!mPendingPackets.isEmpty()) {
                  if (mReadyToSend && mSerialCharacteristic != null) {
                      mReadyToSend = false;
                      GattSerialPacket packet = mPendingPackets.remove(0);
                      mSerialCharacteristic.setValue(packet.getPacketData());
                      if (!mGattClient.writeCharacteristic(mSerialCharacteristic)) {
                          Log.e(TAG, "Failed char write");
                      }
                  } else {
                      mHandler.postDelayed(this, 150);
                  }
              }
          }
      };
focal_class.type: Runnable
focal_class.var_name: mDequeueRunnable
focal_class.file: sdk/src/main/java/com/punchthrough/bean/sdk/internal/serial/GattSerialTransportProfile.java
focal_class.identifier: GattSerialTransportProfile
focal_class.class_method_signature: GattSerialTransportProfile.GattSerialTransportProfile(GattClient client, Handler handler)
focal_class.full_signature: public  GattSerialTransportProfile(GattClient client, Handler handler)
focal_class.identifier: GattSerialTransportProfile
focal_class.modifiers: public
focal_class.parameters: (GattClient client, Handler handler)
focal_class.signature:  GattSerialTransportProfile(GattClient client, Handler handler)
focal_class.class_method_signature: GattSerialTransportProfile.onProfileReady()
focal_class.full_signature: @Override public void onProfileReady()
focal_class.identifier: onProfileReady
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void onProfileReady()
focal_class.class_method_signature: GattSerialTransportProfile.onCharacteristicWrite(GattClient client, BluetoothGattCharacteristic characteristic)
focal_class.full_signature: @Override public void onCharacteristicWrite(GattClient client, BluetoothGattCharacteristic characteristic)
focal_class.identifier: onCharacteristicWrite
focal_class.modifiers: @Override public
focal_class.parameters: (GattClient client, BluetoothGattCharacteristic characteristic)
focal_class.return: void
focal_class.signature: void onCharacteristicWrite(GattClient client, BluetoothGattCharacteristic characteristic)
focal_class.class_method_signature: GattSerialTransportProfile.onCharacteristicChanged(GattClient client, BluetoothGattCharacteristic characteristic)
focal_class.full_signature: @Override public void onCharacteristicChanged(GattClient client, BluetoothGattCharacteristic characteristic)
focal_class.identifier: onCharacteristicChanged
focal_class.modifiers: @Override public
focal_class.parameters: (GattClient client, BluetoothGattCharacteristic characteristic)
focal_class.return: void
focal_class.signature: void onCharacteristicChanged(GattClient client, BluetoothGattCharacteristic characteristic)
focal_class.class_method_signature: GattSerialTransportProfile.onReadRemoteRssi(GattClient client, int rssi)
focal_class.full_signature: @Override public void onReadRemoteRssi(GattClient client, int rssi)
focal_class.identifier: onReadRemoteRssi
focal_class.modifiers: @Override public
focal_class.parameters: (GattClient client, int rssi)
focal_class.return: void
focal_class.signature: void onReadRemoteRssi(GattClient client, int rssi)
focal_class.class_method_signature: GattSerialTransportProfile.abort(String message)
focal_class.full_signature: public void abort(String message)
focal_class.identifier: abort
focal_class.modifiers: public
focal_class.parameters: (String message)
focal_class.return: void
focal_class.signature: void abort(String message)
focal_class.class_method_signature: GattSerialTransportProfile.sendMessage(Buffer message)
focal_class.full_signature: public void sendMessage(Buffer message)
focal_class.identifier: sendMessage
focal_class.modifiers: public
focal_class.parameters: (Buffer message)
focal_class.return: void
focal_class.signature: void sendMessage(Buffer message)
focal_class.class_method_signature: GattSerialTransportProfile.setListener(SerialListener listener)
focal_class.full_signature: public void setListener(SerialListener listener)
focal_class.identifier: setListener
focal_class.modifiers: public
focal_class.parameters: (SerialListener listener)
focal_class.return: void
focal_class.signature: void setListener(SerialListener listener)
focal_class.class_method_signature: GattSerialTransportProfile.getName()
focal_class.full_signature: public String getName()
focal_class.identifier: getName
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getName()
focal_class.class_method_signature: GattSerialTransportProfile.isReady()
focal_class.full_signature: public boolean isReady()
focal_class.identifier: isReady
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isReady()
focal_class.class_method_signature: GattSerialTransportProfile.clearReady()
focal_class.full_signature: public void clearReady()
focal_class.identifier: clearReady
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void clearReady()
focal_class.superclass: extends BaseProfile
focal_method.body: @Override
      public void onCharacteristicChanged(GattClient client, BluetoothGattCharacteristic characteristic) {
          if (characteristic == mSerialCharacteristic) {
              byte[] data = mMessageAssembler.assemble(new GattSerialPacket(characteristic.getValue()));
              if (data != null) {
                  if (BuildConfig.DEBUG) {
                      Log.d(TAG, "Received data");
                  }
                  if (mListener != null) {
                      mListener.onMessageReceived(data);
                  } else {
                      client.disconnect();
                  }
              }
          } else {
              // scratch
              int index = BEAN_SCRATCH_UUIDS.indexOf(characteristic.getUuid());
              if (index > -1) {
                  index += 1;
                  if (BuildConfig.DEBUG) {
                      Log.d(TAG, "Received scratch bank update (" + index + ")");
                  }
                  if (mListener != null) {
                      try {
                          ScratchBank bank = EnumParse.enumWithRawValue(ScratchBank.class, index);
                          mListener.onScratchValueChanged(bank, characteristic.getValue());
                      } catch (NoEnumFoundException e) {
                          Log.e(TAG, "Couldn't parse bank enum from scratch bank with index " +
                                  index);
                          e.printStackTrace();
                      }
                  } else {
                      client.disconnect();
                  }
              }
          }
      }
focal_method.class_method_signature: GattSerialTransportProfile.onCharacteristicChanged(GattClient client, BluetoothGattCharacteristic characteristic)
focal_method.full_signature: @Override public void onCharacteristicChanged(GattClient client, BluetoothGattCharacteristic characteristic)
focal_method.identifier: onCharacteristicChanged
focal_method.invocations: assemble getValue d onMessageReceived disconnect indexOf getUuid d enumWithRawValue onScratchValueChanged getValue e printStackTrace disconnect
focal_method.modifiers: @Override public
focal_method.parameters: (GattClient client, BluetoothGattCharacteristic characteristic)
focal_method.return: void
focal_method.signature: void onCharacteristicChanged(GattClient client, BluetoothGattCharacteristic characteristic)