Android Open Source - BLEConnector B L E Buffer






From Project

Back to project page BLEConnector.

License

The source code is released under:

MIT License

If you think the Android project BLEConnector listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.felhr.bleconnector;
//  w  w  w .  j a  v a2s  .c o m
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

import com.felhr.bleconnector.BLEConnector.QueuedMessage;

public class BLEBuffer 
{
  private BlockingQueue<QueuedMessage> inputBuffer;
  private BlockingQueue<QueuedMessage> outputBuffer;
  
  public BLEBuffer(int bufferSize)
  {
    outputBuffer = new ArrayBlockingQueue<QueuedMessage>(bufferSize);
    inputBuffer = new ArrayBlockingQueue<QueuedMessage>(bufferSize);
  }
  
  public boolean putToOutput(QueuedMessage message)
  {
    try 
    {
      outputBuffer.put(message);
      return true;
    } catch (InterruptedException e) 
    {
      e.printStackTrace();
      return false;
    }
  }
  
  public boolean putToInput(QueuedMessage message)
  {
    try 
    {
      inputBuffer.put(message);
      return true;
    } catch (InterruptedException e) 
    {
      e.printStackTrace();
      return false;
    }
  }
  
  public QueuedMessage getFromOutput()
  {
    try 
    {
      return outputBuffer.take();
    } catch (InterruptedException e) 
    {
      e.printStackTrace();
      return null;
    }
  }
  
  public QueuedMessage getFromInput()
  {
    try 
    {
      return inputBuffer.take();
    } catch (InterruptedException e) 
    {
      e.printStackTrace();
      return null;
    }
  }

}




Java Source Code List

com.felhr.bleconnector.BLEAdvertisingParser.java
com.felhr.bleconnector.BLEBuffer.java
com.felhr.bleconnector.BLEConnectedDevice.java
com.felhr.bleconnector.BLEConnectedDevices.java
com.felhr.bleconnector.BLEConnector.java
com.felhr.bleconnector.BLEDevice.java