jgeiger
Posts: 21
Joined: Sat Sep 20, 2008 2:14 am

Devices are not being detected

Wed Oct 01, 2008 1:31 am

I am a former user of the 32feet.net package, which only supports the Microsoft stack. I switched because I need to run on most Windows Mobile PDAs and most of them are running Widcomm.

Anyway, I have converted my projects and everything is fine and dandy, but I can't seem to discover devices...sometimes. I have a device here, it's powered on. When I run my old software, there it is, connection made, end of story. With Bluetools, it doesn't get discovered, the and the async event DeviceDiscovered never gets called. The real interesting thing is, it DID get called for a while. Now it does no longer. In production units, generally we can connect to the associated device a few times but then after a while it no longer gets discovered. It's just missing, forever, never to be found again. This is on both MS and WD stack devices.

I'm not expecting a solution here, but, just... where do I even look/start. I know that when you re-discover devices that it does not load cached devices that are already in Network.Devices[] but this doesn't explain the same symptom after a software restart or even a PDA reset.

Once this symptom starts, as I said earlier, I cannot find the device using my software using Bluetools. If I use the MS stack tools on the PDA, it does find it. Same with the WD tools.

I will post more as I learn more.

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: Devices are not being detected

Wed Oct 01, 2008 1:48 am

Well, is the device in the Network.Devices? A bonded device will always be in the device cache and never give any DeviceDiscovered event.

Regards,
Jonas

jgeiger
Posts: 21
Joined: Sat Sep 20, 2008 2:14 am

RE: Devices are not being detected

Wed Oct 01, 2008 1:53 am

I am working to look at that. My VS 2005 just broke and I can no longer set breakpoints. I'll be in touch.

jgeiger
Posts: 21
Joined: Sat Sep 20, 2008 2:14 am

RE: Devices are not being detected

Mon Oct 06, 2008 10:35 pm

Visual studio was acting funky here, and I don't know what was going on. Device discovered events are now firing. I have a new post regarding that event.

jgeiger
Posts: 21
Joined: Sat Sep 20, 2008 2:14 am

RE: Devices are not being detected

Mon Oct 27, 2008 8:38 pm

New information:

I have a Microsoft stack device here (Dell Axim X51.) When I use the MS bluetooth manager to search for devices, it lists nothing as bonded, and it will search and find many devices here in my office. But when I run my own code, it finds nothing. The Async device detected event never fires once, and there is nothing in the Network.Devices[] from any previous bonds.

When I run this same code on a HP 110, there is no problem.

I would think this is a hardware issue, but, the hardware on the Dell seems to work. I have no conditional code statements for the type of stack to be used, so the code should be running line by line identically on both devices.

Any suggestions as where to start looking?

jgeiger

jgeiger
Posts: 21
Joined: Sat Sep 20, 2008 2:14 am

RE: Devices are not being detected

Mon Oct 27, 2008 9:01 pm

The HP110 is a Widcom stack device

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: Devices are not being detected

Mon Oct 27, 2008 9:42 pm

The HP is as you say a Widcomm device, so it uses the Widcomm stack.

I have never encountered this problem before with the MS stack as it is generally a better stack. I have an Dell x51 for testing as well and it has never given this kind of error.

Have you made sure you have installed the BlueToolsMS.dll? Have you tried running the FindAndConnect sample and see if the problem exists in that sample as well?

Regards,
Jonas

jgeiger
Posts: 21
Joined: Sat Sep 20, 2008 2:14 am

RE: Devices are not being detected

Mon Oct 27, 2008 9:45 pm

Later today I am going to try to FindAndConnect to see if it's my code or somehow the device.

My customers have just reported some HP devices that are now doing the same thing....

More info coming.

jgeiger
Posts: 21
Joined: Sat Sep 20, 2008 2:14 am

RE: Devices are not being detected

Wed Oct 29, 2008 5:52 am

I have now seen this on my PC. The FindAndConnect app still works, but my app just stops.

My code is nearly identical to the FindAndConnect code. If I take a look at m_network in the DiscoveryCompleted it shows zero devices in the collection. This is really quite frustrating because it is all so similar to FindAndConnect. I am curious if I run FindAndCOnnect enough times if it will start not finding devices there too.... that is literally all that changes when this problem occurs... time has passed and that is the only thing because it's happening on my development PDAs and PCs and in my runtime deployments on customer PDAs.

Code

//Global to the class
//Bluetooth devices
private Manager manager = null;
private Network m_network = null;
private RemoteService currentService = null;
private Stream BTstream = null;
private bool BTAvailable;

//I pass in the calling form so I can set the parent
public bool SetupBluetooth(System.Windows.Forms.Control Main)
{
manager = Manager.GetManager();
Franson.BlueTools.License license = new Franson.BlueTools.License();
license.LicenseKey = "...removed...";

// Call events in GUI thread
manager.Parent = Main;
manager.AutoPowerOn = true;

// Get first netowrk
m_network = manager.Networks[0];

BTAvailable = m_network.IsHardwareAvailable;

m_network.DiscoverDevicesAsync();

return true;
}

private void Bluetooth_DeviceDiscoveryStarted(object sender, BlueToolsEventArgs eventArgs)
{
// Search for devices on the network started

ClearBluetoothDevices();

mnuBTSearch.Enabled = false;

mnuBTSearch.Text = "Searching... ...";
}
private void Bluetooth_DeviceDiscovered(object sender, BlueToolsEventArgs eventArgs)
{
// A new device was discovered!
// Note that this event is only called for NEW devices on the network

// Use Network.Devices for a complete list of discovered devices.

RemoteDevice device = (RemoteDevice)((DiscoveryEventArgs)eventArgs).Discovery;
tsddBTDevices.ComboBox.Items.Add(device);
}
private void Bluetooth_DeviceDiscoveryCompleted(object sender, BlueToolsEventArgs eventArgs)
{
// Search for devices on the network ended.
mnuBTSearch.Enabled = true;
mnuBTSearch.Text = "Refresh List...";

}
private void Bluetooth_DeviceLost(object sender, BlueToolsEventArgs eventArgs)
{
RemoteDevice device = (RemoteDevice)((DiscoveryEventArgs)eventArgs).Discovery;
if (tsddBTDevices.ComboBox.Items.Contains(device)) tsddBTDevices.ComboBox.Items.Remove(device);

}

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: Devices are not being detected

Wed Oct 29, 2008 9:10 am


DiscoveryCompleted it shows zero devices in the collection

Is this Network.Devices or the collection returned in the eventArgs? The latter is the result set of the discovery and that one might very well be empty.

Regards,
Jonas

jgeiger
Posts: 21
Joined: Sat Sep 20, 2008 2:14 am

RE: Devices are not being detected

Wed Oct 29, 2008 7:29 pm

It is Network.Devices, not the returned eventArgs.

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: Devices are not being detected

Wed Oct 29, 2008 11:27 pm

Okay, well I don't have any good advice for you here.
If you can recreate this on "any" device I'll have a look at it (though I will be on vacation and will not have access to my development machine for the next 10 days)

Regards,
Jonas

jgeiger
Posts: 21
Joined: Sat Sep 20, 2008 2:14 am

RE: Devices are not being detected

Thu Oct 30, 2008 7:28 pm

So, I am not sure if this is helpful of not, but here it is anyway. Food for thought.
I'm just hoping to turn on a light bulb in your head, or perhaps mine.

On the PDA, I have two seperate programs and what I noticed was that one of them no longer sees any BT devices, but one still does. As with FindAndConnect. So, maybe this is project related.

Thinking this, I made a brand new project and copied all of my forms and classes in because I was thinking this strange problem was somehow related to the project itself. I ran that and it still will not pick up BT devices. Closing that and running FindAndConnect, it finds everything just fine. So it's related to my code set some how, and in some way that once it stops working, it doesn't appear to work ever again. This is happening on my Widcomm stack PC, and both a Widcomm and Microsoft set of PDAs. This is very strange.

J

jgeiger
Posts: 21
Joined: Sat Sep 20, 2008 2:14 am

RE: Devices are not being detected

Thu Oct 30, 2008 7:59 pm

More on this...

For the most part, my Bluetooth and communications routines are classed out. So, I started a new project, added that class file with all of the Bluetooth code, and copied and pasted the few lines of code to my main form to get everything started.... and it works just fine.

Is there a possibility that my computer/PDAs are running different copies of the DLL and certain copies don't work anymore? I don't think this is the case, as I did copy the DLL for this new project over from the old, but it's something to chew on.

If the hardware is working, and the bluetooth code is working, this leads me to believe that my code surrounding the BT code is causing it to not work correctly. It appears to run all events fire, and whatnot, but it just never finds any devices. What in my code could even touch this?

And again, this comes back to the original question - this is starting not initially, but later down the road. Sometimes we see it on production devices using the installed runtime, and I have personally seen it take down a PDA or two and my PC, but only after working on it for a while.

I am going to fiddle with this new project I made and slowly add the rest of my project code into it to see if and when it will break....

jgeiger
Posts: 21
Joined: Sat Sep 20, 2008 2:14 am

RE: Devices are not being detected

Thu Oct 30, 2008 8:31 pm

By slowly adding my code into this project, it got it to work again. This makes no sense.

Return to “BlueTools”