# Thursday, May 26, 2005

Bluetooth v1.3

Today I've completed the v1.3 release of Bluetooth. This pulls together the latest binaries, source code, samples and help documentation into a single package. There are few differences in the public interface from previous releases, notably the BluetoothSerialPort class has been fixed and re-introduced, also the BondedDevices property for retrieving previously bonded devices from the registry.

I've also prepared a class-library diagram to accompany this release:-


OpenNETCF.Net.Bluetooth.1.3.50525.png (136.1 KB)

You can download the installation package from here.

#    Comments [4] |
# Monday, May 23, 2005

Change Device Assigned to Outbound COM Port

With the Microsoft Bluetooth stack a single outbound virtual COM port is supported, to set this up you have to bond with the device. If you want to switch between several devices at different times this is awkward. You can however alter the registry settings between connections to switch devices.

1. Setup an Outbound COM port for the first device

2. Bond with the other device(s) you wish to use

3. Make a note of the bluetooth IDs of these bonded devices - see the subkeys of [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Bluetooth\Device] for details

4. Before switching devices ensure you do not have the outbound virtual COM port opened (often COM 5 but check on your device).

5. Replace the value of "OBBDaddr" in the key [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Bluetooth\SerialPort] with the bluetooth address of your required device.

6. Open the COM port - now connects to the device specified in the above registry key.

#    Comments [0] |
# Saturday, May 21, 2005

SDF 1.3 Known Issues

Firstly an apology to recent visitors to our website, we've just moved to a new server and are experiencing teething problems, so currently OpenNETCF forums and blogs are not working.

This post is designed to highlight a few issues found with v1.3 and workarounds (if possible), I expect we will produce a refresh release shortly to resolve these:-

  • OpenNETCF.Configuration - in order to use these classes you'll need to replace the \windows\config\machine.config file with an amended version which correctly references the v1.3 runtimes (http://www.peterfoot.net/OpenNETCFConfigurationV13Workaround.aspx)
  • OpenNETCF.VisualBasic - This assembly is unusable in the compact framework as it references the desktop version of mscorlib.dll. No current workaround (other than using the functionality from elsewhere in the SDF since all of the methods here are wrappers to other parts of the SDF
  • OpenNETCF.WindowsCE.Forms - It appears this assembly is not correctly registered in the GAC on devices, this will cause a TypeLoadException when you reference a class from this library. To workaround this you can manually copy the assembly to your program folder on the device e.g. over activesync or add to your project as "Content" file
  • All assemblies appear as "Smart Device Framework" in the add reference dialog. If you scroll across (you may need to extend the columns) to the path you'll be able to determine the name of each assembly.
  • IDE Plugins for v1.3 may not correctly install on your machine. You may find the custom menu items don't do anything when clicked. You can still access all of the SDF and Application Blocks functionality by manually adding references to your project through the Add Reference dialog
  • (Update) Integrated help is not included in the v1.3 installer. However I've built a standalone installer with compiled help for all our libraries.

Please use our bug submission tool if you encounter other errors, and try to give as much detail as possible. We will try and make arrangements for a refresh release shortly to overcome these issues, thanks for your patience.

#    Comments [2] |
# Friday, May 20, 2005

Bluetooth Comparison

Now that the dust has settled on MEDC, I'm thinking about how to move forward with the Bluetooth library. I had essentially put development on hold when I first heard that Microsoft were preparing their own source package prior to MEDC. When it was released, I was a little disappointed in their functionality (and compatibility) so I've decided to press on improving the Bluetooth.NET library. It's going to take a few weeks to put together the next version, one key aim is to synchronise the source, samples, documentation and binaries with this next release, some of the previous releases have been binary only.

In the meantime here is a comparison of the functionality available today in the widely available Bluetooth libraries/SDKs:-

  Managed libraries Native code SDKs
  Bluetooth.NET Microsoft Windows Embedded Source Tools for Bluetooth Technology High-Point BTAccess Microsoft Windows CE SDK Broadcom SDK
Bluetooth Functionality  
Toggle Radio * *   *  
Device Discovery *   * * *
Service Discovery     * * *
Client Sockets * * * * *
Server Sockets * * * * *
COM Port mapping *   * * *
Bluetooth Stacks  
Microsoft Stack * *   *  
Broadcom Stack     *   *
Runtimes  
.NET v1 *      
.NET v2 *    
.NETCF v1 *   *
.NETCF v2 * *  
Platforms  
Pocket PC 2002     *   *
Windows CE.NET 4.2 *     *  
Windows Mobile 2003 *   * * *
Windows CE 5.0 * *   *  
Windows Mobile 5.0 * *   *  
Windows XP (SP1 and above) *     *
Package features  
Help documentation *   * * *
Source code * *      
Sample projects *     *  
Price FREE FREE $750 FREE $1,395

Obviously your feedback will help shape the library, so what are the key features you'd like to see added or improved?

#    Comments [1] |

ADOCE In The Hand v1.7 Completed

The ADOCE wrapper is the first of our libraries to be updated with full support for Visual Studio 2005 Beta, integrating both the libraries and the help content.

The main update is the v1.7 version of the COM Interop library which now has functionality for translating domain specific HResults into particular exception types, previously any ADO errors would result in a cryptic error code. I've also added some functionality to upsize databases from Pocket Access to Sql Server CE (.sdf).

The v1.7 interop library shipped with the WindowsMobile community preview and will be used with the upcoming update of PocketOutlook In The Hand along with some further cool Windows Mobile stuff...

#    Comments [1] |
# Thursday, May 19, 2005

OpenNETCF.Configuration v1.3 Workaround

As I suspect many of you will be doing too, I'm recompiling one of our apps against the latest v1.3 release of the SDF. There is a minor bug in this release when using the OpenNETCF.Configuration classes due to the machine.config file which is installed with the SDF containing references to the v1.2 assemblies. The workaround is luckily quite straight-forward, simply replace your \windows\config\machine.config with an updated file referencing the v1.3 versions. You can use the version attached below:-

machine.config.zip (1.72 KB)
#    Comments [0] |
# Tuesday, May 17, 2005

Windows Mobile 5.0 "Old Skool" Start Menu

Personally I like the new icons based start menu in Windows Mobile 5.0 Smartphone, however some people have asked if it's possible to revert to the old list view. The answer is yes, via a simple registry tweak. For this I'm using the Remote Registry Editor from VS2005. Locate the key

HKEY_CURRENT_USER\Software\Microsoft\Shell\StartMenu

Change the value "GridView" from 1 to 0. The change takes effect immediately when you next open the start menu. As with the large icons view the full 9 items are listed with the more option mapped to the left softkey. This always bugged me with SP2003 especially when a menu had 9 items with the 9th requiring a whole new page. You can change the value back to 1 for the new WM5 experience.

#    Comments [0] |
# Monday, May 16, 2005

SDF v1.3 for Visual Studio 2005

So, I've heard a few requests for VS2005 support for the SDF. The reason we don't have this fully integrated into VS2005 yet is because the extensibility model is significantly changed from VS2003, and since it's a Beta product is still changing. Therefore we'll have a fully integrated installer nearer to the release of VS2005.

In the mean time you can pull the dlls off of a machine with VS2003 and SDF v1.3 installed, or grab them here in a zip file. These are the exact same dlls as you'll get in the v1.3 setup. Just to set your expectations you wont get automatic deployment of the SDF cab files (these are included in the zip for manual deployment). You also won't get the full designer experience - if you use any of our forms controls you'll have to add it through code.

If you encounter any issues using this version from within VS2005, be sure to file a bug report, and make sure you tell us what version of the .NETCF you are targetting (1 or 2) and what platform type (Pocket PC 2003, Windows Mobile 5.0 Smartphone etc) and which version of VS2005, though I wouldn't recommend using anything prior to Beta 2 now it is available.

#    Comments [0] |
# Sunday, May 15, 2005

Windows Mobile Managed APIs Diagram

During his session at MEDC, Robert Levy handed out copies of a cool class library diagram for the new Windows Mobile 5.0 managed APIs, thanks to Robert for allowing me to post the diagram here - simply print to a large sheet of paper and enjoy :)


WM5APIs.gif (242.62 KB)

#    Comments [0] |
# Tuesday, May 10, 2005

Windows Mobile 5.0 Managed APIs

The much anticipated update to Windows Mobile has been announced by Bill Gates this morning. This new platform will be the first platform from Microsoft to include device specific managed APIs in ROM (separate from the .NET Compact Framework itself). These allow access to configuration, telephony, pocket outlook etc from managed code.

But what about existing devices? To add to our existing PocketOutlook library we have produced a WindowsMobile suite which includes a large proportion of WindowsMobile 5.0 APIs for previous versions. More details are available here.

As well as supporting older generations of Windows Mobile, the suite also supports Windows Mobile 5.0, and one library in particular InTheHand.WindowsMobile.Gps provides a managed wrapper around the native GPS API in Windows Mobile 5.0

In due time the PocketOutlook library v1.7 will be released with an object model more closely aligned to Windows Mobile 5.0 APIs.

#    Comments [0] |
# Friday, May 06, 2005

Blog updates during MEDC

MEDC 2005 is nearly upon us. Like many other mobile (and embedded) developers I'm looking forward to this years event which promises to cover the whole range of topics: devices, tools, managed code, native code etc

I'll be acting as roving reporter for Pocket PC Thoughts during the event so I don't expect to be posting updates here. However I hope you will join us over at Pocket PC Thoughts to catch up on what is happening during MEDC.

#    Comments [0] |
# Monday, May 02, 2005

Emulate Screen Taps

You can simulate user activity on your touch-screen device by using the mouse_event API to send the system screen taps. There are a number of reasons you might want to do this from testing your application through to automating some third-party application, the following is example code to send a tap (and release) to any screen co-ordinate:-

[DllImport("coredll")]
private static extern void mouse_event(MOUSEEVENTF dwFlags, int dx, int dy, int dwData, int dwExtraInfo);

[Flags()]
private enum MOUSEEVENTF
{
MOVE = 0x1, /* mouse move */
LEFTDOWN = 0x2, /* left button down */
LEFTUP = 0x4, /*left button up */
RIGHTDOWN = 0x8, /*right button down */
RIGHTUP = 0x10, /*right button up */
MIDDLEDOWN = 0x20, /*middle button down */
MIDDLEUP = 0x40, /* middle button up */
WHEEL = 0x800, /*wheel button rolled */
VIRTUALDESK = 0x4000, /* map to entrire virtual desktop */
ABSOLUTE = 0x8000, /* absolute move */
TOUCH = 0x100000, /* absolute move */
}

public void SendTap(int x, int y)
{
mouse_event(MOUSEEVENTF.LEFTDOWN | MOUSEEVENTF.ABSOLUTE, (int)((65535 / Screen.PrimaryScreen.Bounds.Width) * x), (int)((65535 / Screen.PrimaryScreen.Bounds.Height) * y), 0, 0);
mouse_event(MOUSEEVENTF.LEFTUP, 0, 0, 0, 0);
}

 

The mouse_event method is fairly straight-forward, one thing to notice is that it doesn't accept screen co-ordinates but rather a value from 0 to FFFF in each direction, where FFFF, FFFF is the bottom right corner.


#    Comments [0] |
# Tuesday, April 26, 2005

MEDC 2005 UK Registration now open

Following the main MEDC 2005 which I'm sure you've all heard about, there are a number of smaller events happening worldwide to bring the highlights to the wider audience. One of these is happening in the UK at Microsoft's campus in Reading on Friday the 10th of June. You can now register for the event, which is free but places are limited.

More details on Marcus Perryman's Blog, and the MEDC 2005 UK site.

#    Comments [0] |
# Monday, April 18, 2005

.NETCF v2.0 Beta 2 Redistribuable Package

I'm sure I don't need to mention that Microsoft recently released Beta 2 of their Visual Studio 2005 tools. Alongside this release a redistributable version of the .NETCF v2.0 runtime is available so that you can download to your devices and test code you can download the package here.

Ilya Tumanov posted some useful information on the release on the newsgroup:-

"Visual Studio 2005 download is not required; installation of NETCF V2 Beta
2 won't break existing VS 2003 and/or NETCF V1.
It also works side by side with CF V1 on device (in ROM or RAM).

If you're planning to install VS 2005 Beta 2 later on, you would have to
uninstall NETCF V2 prior to VS installation.

We would appreciate if you try your CF V1 application(s) under V2 and
report incompatibilities so we could fix them.

Here's how to run existing V1 applications under V2:

1. Install V2 on to the device (via Active Sync or copy CAB file to the
device and click on it).
2. Create a configuration file named <App_Name>.exe.config as follows:

<configuration>
<startup>
<supportedRuntime version="v2.0.5056"/>
</startup>
</configuration>

To try application without V1 compatibility enabled, the following section
can be added:

<runtime>
  <compatibilityversion major="2" minor="0"/>
  </runtime>

To run V2 application in V1 compatibility mode (for example if V2 app uses
V1 component), section can be changed as follows:

<runtime>
  <compatibilityversion major="1" minor="0"/>
  </runtime>

3. Copy configuration file to the application folder.
4. Run application as usual.

Please report problems with installation and/or compatibility to this NG.
For CAB problems, please attach CAB log file "Microsoft .NET CF
2.0.LOG.TXT" which can be found in device's root folder. Thanks."

Even if you are not currently evaluating the Visual Studio 2005 tools, I would recommend downloading these runtimes and testing your existing code - there are a number of cases where behaviour has changed in v2.0 but as you can see above you can run an app with v1.0 compiled code in compatibility mode.

#    Comments [0] |
# Friday, April 15, 2005

The great Media Player 10 Automation Challenge!

Media Player 10 is the first device version to have an automation model. Previous versions could be controlled via some undocumented windows messages but that was about it. The Media Player 10 Mobile object model is COM based, so you can't use it directly from .NETCF v1.0. I set about creating a wrapper months ago but it got left due to lack of time. However I've decided there is enough functionality available in it now for it to function. I've not had time to create a sample application, so your challenge if you choose to accept it (and I'll be honest there isn't a prize!) is to create something using the assembly.

Because theres no support for hooking com events with a sink interface the wrapper exposes no events, also because there isn't ActiveX hosting support you won't get any UI - so this is useful for audio content only. The other big limitation is that you must have Media Player 10 on your device.

Other than that feel free to have a play and see what fun you can have with it, any issues suggestions or cool creations you build with it please drop me an email or post a comment.

Download InTheHand.MediaPlayer.zip

#    Comments [2] |
# Monday, April 04, 2005

Time to turn out the lights...

Time to provide a little balance to the previous piece on SetPowerRequirement for Smartphone which looked at the scenario of ensuring the backlight remained on. You might also want to manually turn off the backlight (or another peripherial) to save power. You can do this with SetDevicePower. You pass in the identifier of the hardware device ("BKL1:" being the backlight on most devices), and a power state - thus the backlight can be powered off with the following:-

SetDevicePower("BKL1:", POWER_NAME, DevicePowerState.D4);

POWER_NAME is passed in to the flags argument to indicate that the first argument represents a device name. The Power states run from D0 full power to D4 power off. And without further ado, the P/Invoke:- 

public enum DevicePowerState : int
{
Unspecified = -1,
D0 = 0, // Full On: full power, full functionality
D1, // Low Power On: fully functional at low power/performance
D2, // Standby: partially powered with automatic wake
D3, // Sleep: partially powered with device initiated wake
D4, // Off: unpowered
}

private const int POWER_NAME = 0x00000001;

[DllImport("coredll")]
private static extern int SetDevicePower(
string pvDevice,
int dwDeviceFlags,
DevicePowerState DeviceState);

#    Comments [6] |