# Thursday, February 10, 2005

No touch deployment with Pocket PC or "How I cancelled my dental appointment with Dr Johnson"

Earlier today I posted a link from the Windows Mobile Team blog on Pocket PC Thoughts on an article being produced to describe rolling out mobile devices to your enterprise. Here is some useful additional material with a more technical twist which didn't seem appropriate to mix in with it.

This applies only to deploying Pocket PC devices in the field, and works easiest if you are rolling out a set of matching device models. The following sections are some techniques which have saved me time when deploying devices:-

  • When you first startup a Pocket PC device you are greeted by a Welcome Wizard. This is a perfectly legitimate starting point for a consumer who has just unpacked and charged their device, but is a real pain if you want to automatically deploy your software onto multiple devices.  To dismiss this wizard from appearing simply place an empty file called "welcome.not" in the root of a Storage Card.
  • No more rearranging dental appointments Great! well not quite, because this introduces two new issues - among the introductory material in the Wizard are two very important steps - Screen calibration and setting the Timezone. Both of these can be applied automatically by writing entries into the Registry or calling the appropriate APIs:-
  • Timezone is written as a binary array here:-

[HKEY_LOCAL_MACHINE\Time] "TimeZoneInformation"

  • The format of this is documented in the SDK - it's a TIME_ZONE_INFORMATION structure. Assuming your batch of devices are all deployed to the same timezone you can copy the value from an existing device, or if you set the value on first run of your managed application you can make use of the DateTimeEx.SetTimeZoneInformation method in the SDF

 

  • Screen calibration is a little more interesting, as it will depend on the hardware. So although you can copy values from an existing device its probably better to run the screen calibration on the first run of your application. If you choose the "dangerous" route you'll find the calibration settings in the string value here:-

[HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\TOUCH] "CalibrationData"

  • Kicking off the standard screen calibration applet from your code is very easy - just P/Invoke TouchCalibrate which can be defined as

[DllImport("coredll.dll")]
private static extern bool TouchCalibrate();

  • This will launch the standard calibration screen and require the user to tap the centre and four points around the screen. It will return true on success and false if if fails.

For all of this to be automatic you will need an autorun.exe file located a folder matching the processor identifier of the device, so for any ARM based Pocket PC this would be \2577\ on the storage card. While it is possible to write this application in managed code if your device has .NETCF in ROM, if you are catering for a range of devices you should write this file in native code. You can read more about this technique here and here.

Following this I am currently testing Spb Clone which allows you to create a clone image from a single unit and install it onto multiple devices, this supports either a self extracting exe installer or an autorun approach. I will post back a mini-review once I've done some more testing with it.

#    Comments [0] |
# Wednesday, February 09, 2005

Patterns & Practices Survey

Announced on Jono's blog the Patterns & Practices team are looking at what guidance they can provide for device development. They have now setup a formal online survey to capture your wishes and needs, so I recommend you stop by and add your thoughts:-

Fill in the survey

Personally I'd like to see some kind of Power Management application block and accompanying guidelines produced, along with the obvious choice of a port of the Smart Client Offline block.

#    Comments [0] |
# Monday, February 07, 2005

Upcoming .NETCF Chat

Tomorrow the .NETCF MVPs will be hosting a developer chat at MSDN. Start time is 10am PST (6pm GMT). As usual any questions related to .NETCF, Smart Device Development or OpenNETCF are welcome. Full details along with other upcoming chats on a whole raft of topics can be found at:-

http://msdn.microsoft.com/chats

 

#    Comments [0] |
# Sunday, February 06, 2005

Bluetooth Library (February Edition)

Not a huge amount of change since last months release but I just wanted to post the latest update. The download includes the same Chat application samples along with the complete solution for the library itself.

Downloads

The main changes in this release are:-

  • BluetoothRadio class which handles the radio state on a single or multiple radio device. Multiple radios are only supported on XP, Windows CE supports a single radio device.
  • BluetoothSecurity class which has a couple of methods to automate the pairing (bonding) process between devices. Using SetPin and RevokePin you can specify the PIN to use with a particular remote device. Using PairRequest you can force the device to intiate a connection and bond with the remote device with the specified PIN code. Currently the BluetoothSecurity class is built for Windows CE only, in a future update this functionality will be extended to run on the desktop too.
  • General housekeeping - P/Invokes have been moved into a single NativeMethods class and a few new ones added, though not all are used by the library yet.

Online documentation for this build can be browsed here.

#    Comments [12] |
# Thursday, February 03, 2005

Potted history (and glimpse into the future) of the .NET Compact Framework

Mike Zintel has posted a description of how the .NET Compact Framework got to where it is today, and where the team are headed in v2.0 and beyond.

Key lessons learned by the team were in performance, interop and a few bloopers like the infamous DateTimePicker - the control which should never have been left out. The good news is that all these areas are receiving attention for v2.0.

A focus for v3.0 will be managing transient networks - being able to seamlessly use a connection as and when available, based on emerging WS-* standards. We will see some improvements in this area before v3.0 as the Windows Mobile team have already announced the Notifications Broker for their next version which will support events on key system changes, however this won't be available to other Windows CE based platforms. The problems faced are not just in choosing and activating the most appropriate connection, but handling situations where the connection is lost part way through a process, a real problem when your devices are constantly on the move, in and out of network coverage.

My personal wishlist for v3.0 would add more support for location and context awareness, so that apps can be a little more smart to react to changes not just in network connectivity but also changing usage profiles such as sound and appearance for different locations and times.

Once you've read Mike's article you can check out some of his wonderful photographs too at http://www.zintel.net/.

 

#    Comments [0] |
# Tuesday, January 25, 2005

More details on Generics and Reflection for .NETCF v2.0

Nazim Lala from the .NET Compact Framework team has posted further details on the generics support in .NETCF v2.0 specifically the Reflection functionality available and how it differs from the full framework implementation.
#    Comments [0] |
# Thursday, January 20, 2005

Visually identify your Bluetooth stack

Since it's such a frequently asked question I've documented it here with some images which should hopefully clear up any confusion. The following screenshots show how to identify the Bluetooth stack on your Pocket Pc without writing any code or delving into the registry or system files.

Microsoft

Widcomm/Broadcom

Bluetooth Off

Microsoft Stack (Disabled)

Widcomm Stack (Disabled)

Bluetooth On

Microsoft Stack (Enabled)

Widcomm Stack (Enabled)

Settings (Click Icon)

Microsoft Stack Settings


Pocket PC 2003 Second Edition

Microsoft Stack Settings Second Edition

Widcomm Stack Menu

 

Finally a quick reminder, the Bluetooth.NET library only works currently with the Microsoft stack, so if you have Widcomm/Broadcom or any other you'll have to look at third-party APIs.

#    Comments [0] |
# Tuesday, January 18, 2005

Mobile and Embedded Developer Conference 2005

Announced on the Windows Mobile blog, this year will see the Mobile and Embedded developer conferences combined into one event happening in Las Vegas 9th-12th May.

This year there will be lots of exciting content around .NETCF v2.0 and Visual Studio 2005 along with coverage of Windows Mobile and Windows CE and XP Embedded.

Go on, write that date somewhere important :-)

#    Comments [0] |
# Saturday, January 15, 2005

Designing Class Libraries Series

Brad Abrams' team at Microsoft have started a series of Webcasts around class library design. The introductory session is available on the site now with a further 13 sessions to follow. A chat session is scheduled to follow on the topic of each week, the first of which will be this Wednesday. There are some exciting topics coming up in the series so it's definately something you should keep an eye out for. A full schedule is on the Designing .NET Class Libraries website:-

http://msdn.microsoft.com/netframework/programming/classlibraries/

#    Comments [0] |

Bluetooth Build 50115

I've posted an updated build of the Bluetooth library here. It adds full support for the desktop, improved class-of-device and other properties.

The sample app is now supplied in Pocket Pc, Smartphone and Desktop versions which all talk to each other.

#    Comments [8] |
# Wednesday, January 05, 2005

.NETCF Service Pack 3 is out - Go Get It!

.NETCF SP3 Redistributable can be downloaded from here:-

http://www.microsoft.com/downloads/details.aspx?amp;displaylang=en&familyid=a5a02311-194b-4c00-b445-f92bec03032f&displaylang=en

List of fixes grabbed from the above page:-

Fixed Issues:
- Transitions between managed and native code can cause memory leaks on ARM platforms.
- A NullReferenceException is thrown when a Web Method returns an empty array using the xsi:Nil attribute.
- Modifying the SoapClientMessage.ContentType property does not modify the Http requests ContentType header.
- Stack corruption can occur on SH, MIPS and x86 platforms when local variables are created but never used.
- Invoking a multicase delegate from a catch handler throws a MissingMethodException on SH, MIPS and x86 platforms.
- Command line arguments containing double byte characters are truncated to a single byte.
- An ObjectDisposedException is thrown when a asynchronous web request is aborted before the response is received.
- Invoke on a disposed control hangs the application.
- Any array containing one or more elements is not sent to the Web Service correctly.
- An application may hang when invoking a Web Method that uses multiple XmlElementAttributes on a single argument, member or property.
- Memory corruption can occur on devices that have the native security model enabled and both .NET CF V1 SP3 and a pre-release version of .NET CF V2 installed.
- Deadlocks can occur when running under severe resource constraints.
- Tool Bar's on Windows Mobile 2003 SE no longer lose their images when removed from the form.
- An uncatchable ObjectDisposedException is thrown when the server closes the socket connection.
- Setting the Minimum and Maximum properties of a progressbar no longer crashes the application.
- Unexpected exception while adding an image to an imagelist on an Hx4700 and hx4705.
- Data Misalignment occurs on Decimal fields in MIPSIV devices.

#    Comments [0] |
# Tuesday, January 04, 2005

GetEntryAssembly for .NETCF

If your application contains multiple levels of DLL files, you may want to determine the name and path of the original calling executable. On the desktop you can use Assembly.GetEntryAssembly() but this is not available in the Compact Framework. I have added an equivalent to the SDF code to work in just the same way, using Platform Invoke. It uses the GetModuleFileName API which when passed IntPtr.Zero for the module handle, returns the path of the calling exe. Assembly.LoadFrom is then used to return the Assembly object corresponding to this path. Since the exe is already loaded this will not increase the overhead of your application. From the returned Assembly object you can determine the Path, Version etc as required.

The full code for AssemblyEx is available in the online Source Browser, and will be built into a future SDF release.

#    Comments [0] |
# Friday, December 24, 2004

Rudolph the Bluetoothed Reindeer

I've uploaded a new release of the Bluetooth library which adds the key feature of hosting services over bluetooth. This now allows two-way communications between devices and to demonstrate how this works I've included a sample Bluetooth Chat application. This registers a custom bluetooth profile and listens for incoming connections, and creates outgoing connections using this service identifier to other devices. In this way it only communicates with other devices exposing this service and wont interfere with any other applications using Bluetooth.

Thanks go out to Wei-Meng Lee for giving permission to base the sample on his previous IrDA chat application available with this MSDN article. The Bluetooth version works in a very similar way, with the exception of doing a device discovery when it first loads. An enhancement yet to be added is the ability to periodically discover in a background thread. From the app screen select the target device which must also be running the software and Bluetooth must be Discoverable. Then type your message and click send and it will appear onscreen on the other device. In the below example I had a brief conversation with Santa who was half-way up a chimney at the time - such is the versatility of Bluetooth :)

Bluetooth Chat

The ZIP file below includes the Bluetooth library project and compiled output, and the BTChat sample project. As I get time to do more work on the library I'll post some other examples, and include versions for other platforms e.g. Smartphone and XP.

Known issues:-

  • Hosting services doesn't yet work on XP (some of the structures are slightly different so this requires a little more work)
  • BluetoothClient.RemoteDeviceName doesn't work so you can't retrieve the device name from an open connection (Device names work correctly during discovery on both Windows CE and XP)
  • BluetoothSerialPort (For emulating a COM port) is not fully tested and probably doesn't work - SerialPortProfile connections work great using sockets (BluetoothClient).

Requirements:-

  • SDF v1.2
  • Windows CE Device or Windows XP computer using the Microsoft Bluetooth stack (Sorry but Widcomm is not supported).

Download:-

Downloads

 

If you have any comments or questions please drop me an email. For now all that remains is for me to wish you a Very Merry Christmas!

#    Comments [2] |
# Wednesday, December 15, 2004

New in .NETCF v2.0

Jono posted a link to a new section in the online Beta documentation at MSDN which describes in some detail whats new in v2.0 of the Compact Framework. This includes new framework features and a list by namespace of the new classes introduced in v2.0.

 

#    Comments [0] |
# Monday, December 13, 2004

System.Net.IrDA for the desktop (Part 2)

Following my previous post, I did some further development to the code to make it fully match the .NETCF assembly (yes, in my haste I'd missed a few properties and cut a couple of corners). So now I have compiled a System.Net.IrDA.dll assembly which has exactly the same classes and methods as is available in device projects. So you can easily move device code over to Tablet and laptop PCs.

Download the DLL here (zip 7kb)

The package includes just the dll and xml documentation. The next task for the project is to build an installer for both the source and binaries...

This was a useful learning experience since I've based the Bluetooth code on the existing model of the IrDA library, so it was useful to spend some time studying this particular library and the classes it contains.

The functionality is now part of 32feet.NET a library for personal area networking for .NET. The downloads are here:-

http://inthehand.com/files/folders/releases/default.aspx

#    Comments [2] |