1

Perspectively I have to create a haptic Feedback in a Unity 3D VR-Scenario. Therefore I want to make some wearable bracelets or bands to wear around arms, legs, etc., with a Adafruit Flora, some Lilypad Vibe Boards, a Flora Bluefruit LE module and a wireless chargable LiPo. So far controlling it (a.k.a. turning the Vibe Board on or off) works with the Adafruit Bluefruit App. The next step is to control Flora with a Visual Studio c# Console Apllication. And there is my problem, I'm unable to get it to work. (I'm a newbie in this whole Bluetooth-programming stuff and also not that experienced with Visual Studio and c#)

I found the Windows-Samples for the May-Update of Windows, installed this last week manually and was able to run the Samples. Unfortunately the functions of the Bluetooth LE Sample didn‘t fit my problem that well, because I can’t use a User Interface to connect/pair Flora with the PC, when I want to use the haptic feedback later in Unity VR. Nonetheless I tried the sample and was able to find Flora, but pairing wasn’t possible. That should be alright, because to my knowledge it’s not possible to pair more than 1 wearable to the PC or at least very slow to pair, disconnect and repair the different bands. So I think I just have to connect to 1 bracelet, send a command and than can connect easily to another band. So I tried to use part of the code to write my Console App, but wasn’t very succesfull. I read that you somehow have to have an UI to connect to a Bluetooth LE device. So maybe this way just doesn’t work for me. I looked for another way to achieve my goal and found the possibility of RFCOMM. It seems to be able to do, what I need it to do, but I just can’t get it to work. I found some parts of Code on https://en.baydachnyy.com/2017/05/19/uwp-working-with-bluetooth-part-5-bluetooth-rfcomm/ This example is quite similar to my task and I wanted to implement it.

Arduino:

void setup() {
   Serial.begin(115200);
   pinMode(9,OUTPUT);
}
byte vibe;
void loop() {
   if(Serial.available()) {
      vibe=Serial.read();
      Serial.write(vibe);
      if (vibe==3) {
         digitalWrite(9,HIGH);
      }
      else if(vibe==2) {
         digitalWrite(9,LOW);
      }
      Serial.write(vibe);
   }
}

RFCOMM-Fragments I found online: https://en.baydachnyy.com/2017/05/19/uwp-working-with-bluetooth-part-5-bluetooth-rfcomm/

Because I found only fragments of this code, it obviously isn't running. But there seem to be some error messages that shouldn't be there anyway. Like "Namespace RoutedEventArgs not found".

J.Lorenz
  • 51
  • 1
  • 4
  • Would you be able to trim this down to just the specific problem you are running into, so it is very concise and clear? This is good background info, while useful, say for a blog post, but not necessary for your specific issue. Mainly, it looks like you are asking about the RFCOMM, but don't have a complete example to work with. I would add a little more details, complete code, and all the error messages, and what you tried, i.e. what does 'Namespace RoutedEventArgs' lead you to? Further, one thought is to use the referenced project, is that possible: https://github.com/ms-iot/remote-wiring – michaelok Jun 13 '19 at 15:27

1 Answers1

1

It seems to be a nice project.
It's possible to do all the things you need without UI or user interaction in Windows with BLE.
Pairing is not necessary to setup a connection to read and write commands. If the device-name or Bluetooth-address is known you can just connect.

Have a look at my UWP example on Github; This example is as basic as it can be and the Main-page is complete empty: https://github.com/GrooverFromHolland/SimpleBleExample_by_Devicename

GrooverFromHolland
  • 971
  • 1
  • 11
  • 18