Error invoking method "Gadgeteer.Modules.GHIElectronics.Bluetooth" (check arguments to Program.BeginInvoke are correct)

Hey, Roland.

I ended up just working through the Bluetooth_Pairing_Test after modifying it to take out the serial port and the button (both of which are on order from GHI).

So, whichever driver is in there.

I had problems with PC program exceptions running on the PC side with the Listener project, but that’s before I figured out how all this pairing was supposed to work. You have to run it as Admin, and that took care of some exceptions, but then there were others. Not sure why.

Interestingly, I get exceptions sometimes when I run the Bluetooth_Pairing_Test. I think it was involved with the BTSTATE routine. I just re-run it and the problem doesn’t appear.

I’ll figure it out and post what is happening. I got so excited when I figured it out and then I had to rush home to see Denver get clobbered in the big game. :slight_smile:

What was happening was I would key in the PIN and pair the device the phone, but the app wasn’t really running. Then I would try again, but the device was already paired with the phone, and when the device would go into pairing mode, everything would get confused. I’d end up deleting the pairing on the phone and things went downhill from there.

When the pairing was messed up, the phone app would throw errors about not be able to connect to a network. Another rabbit hole.

So it came down to timing…

  1. Delete the Bluetooth profile off the phone.
  2. Fire up the device and let it go into pairing mode
  3. Pair the device on the phone with the PIN
  4. Right away, open the phone app, search for the device and open a socket it to it.

From that point on, everything seems to work fine, including checking to see if the device is connected before going into pairing mode. I could terminate the phone app, reboot the device and it all worked as expected.

And now it makes perfect sense why there has to be a physical button on the device to force it into pairing mode. You could already have an unpaired profile on the phone and the device won’t see it. Then it’ll pop into pairing mode and then you’re stuck again. I don’t believe you can actually get this to work without a physical button.

I skimmed that Pan-Head article, but haven’t studied it yet.

I ended up buying a Nokia 520 off contract for $59 and joining the MS Store developer program for $19 to do the experimentation.

Hi Willy,
thank you for your feedback.

I think on Windows 64 bit PCs the projects using the library have to be run as admin. Otherwise the .dlls must have a Certificate I think but I did not deal with this issues.
In the FEZ/PC Bluetooth file Transfer application the intergration of the library is more stable and should not throw exceptions but you need an SD-Card module to run it as it is.

Did you leave the Thread.Sleep()s in the example? If the BT-Module commands come to fast the BT-Module answeres with ERROR, this should not occur.

To improve the diver or the apps keep me informed if you find any bugs.

I think on Windows 64 bit PCs the projects using the library have to be run as admin.[/quote]
I bypass the 32feet libary on Win64 PC using bluethooth as serial port com3.
I down’t know if this possible on WindowsPhone


Everything on the phone goes through RFCOMM and I didn’t see anything that let’s me specify a COM port on the phone.

I am trying to use as many native functions as I can, so I’m sticking pretty close to their sample code.

Everything seems to be working fine now.