Example #1
0
 /// <summary>
 /// This is the call that needs to be included in the main data processing loop to get
 /// data from a Bluetooth stream.
 /// </summary>
 /// <param name="bs"></param>
 public void GetSensorData(BluetoothController btc,int type)
 {
     calls++;
     bytesFound = btc.read(btc.BluetoothBytesBuffer);
     byteCounter += bytesFound;
     if (calls >= 20)
     {
         calls = 0;
         if (byteCounter == 0)  
             throw new Exception();
         
         byteCounter = 0;
     }
     //UpdateDataRate(bytesFound);
     if (bytesFound > 0)
     {
         Debug("Bytes from fill: " + bytesFound);
         someMITesDataIndex = 0;
         if (type==MITES_SENSOR)
             someMITesDataIndex = DecodeMITesData(btc.BluetoothBytesBuffer, bytesFound, someMITesData, someMITesDataIndex);
         else if (type == WOCKETS_SENSOR)
             someMITesDataIndex = DecodeWocketsData(btc.BluetoothBytesBuffer, bytesFound, someMITesData, someMITesDataIndex);
         else if (type == SPARKFUN_SENSOR)
             someMITesDataIndex = DecodeSparkfunData(btc.BluetoothBytesBuffer, bytesFound, someMITesData, someMITesDataIndex);
     }
     else
     {
         someMITesDataIndex = 0;
     }
 }
 public MainWindow()
 {
     InitializeComponent();
     bluetoothController = new BluetoothController();
     this.DataContext    = bluetoothController;
 }