I'm developing a Windows phone 8 OS application which should connect to the Bluetooth device (by id/ name).
I tried to use by PeerFinder.FindAllPeersAsync()
to find all the active devices and I got the following error:
A method was called at an unexpected time. (Exception from HRESULT: 0x8000000E)
.
How can I connect to Bluetooth? What do I need to do?
Is it possible?
I need the answer ASAP.
Thank a lot
Had the same problem and couldn't find anyone with a solution. After an hour or so of trial and error I have come up with the following:
You need to call PeerFinder.Start() before PeerFinder.FindAllPeersAsync() or you will get the error "A method was called at an unexpected time" (which is caught in Microsoft's sample application "Bluetooth app to app sample" - ERR_NOT_ADVERTISING = 0x8000000E).
But after saying all that I couldn't find any Bluetooth devices. The only way I worked out how to connect to a Bluetooth device was to pair using the control panel and then use PeerFinder.AlternateIdentities["Bluetooth:Paired"] = string.Empty; Now this didn't seem to require PeerFinder.Start() to return results but if you don't do it you will get exceptions later on.
I couldn't find information about this on the Microsoft API's - it seems like these API's are unpolished.
WP8 supports the RFCOMM Bluetooth profile. This is a serial emulation profile. So in theory, any Bluetooth device that can be paired via RFCOMM should work.
User contributions licensed under CC BY-SA 3.0