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".