# Tuesday, March 01, 2005

Alternative View of Express Products

Thanks Bill for this excellent link - an alternative view of the Visual Studio Express products target audiences. Check it out (but don't take too seriously!):-

http://www.atrevido.net/blog/PermaLink.aspx?guid=fc395650-88e9-4f9a-82cc-3f1ceebdfc3f

#    Comments [0] |

Determine Current GSM Network

This VB.NET code will work on Smartphone and Pocket PC Phone devices and return details of the current GSM operator (though it probably works on CDMA also). It relies on Alex Feinman's excellent TAPI wrapper whish you can download here. Using the library we create a line object which we pass the handle of (line.hline) into lineGetCurrentOperator, one of the ExTAPI functions. For simplicity the structure is just passed as one big byte array then the strings are copied out from it and have trailing nulls chopped off.

'gets the textual representation of the operator
Public Function GetCurrentOperator(ByVal line As OpenNETCF.TAPI.Line) As Operator
Dim result As Integer
Dim nullindex As Integer

'stores operator details
Dim lo As New Operator

Dim buff(140) As Byte

'copy LINEOPERATOR_USEFIRSTAVAILABLEINDEX to struct
BitConverter.GetBytes(-1).CopyTo(buff, 0)

'call tapi method
result = lineGetCurrentOperator(line.hLine, buff)

If result < 0 Then
'error encountered
Throw New System.Runtime.InteropServices.ExternalException("TAPI Error getting operator: " + result.ToString())
End If

'index
lo.Index = BitConverter.ToInt32(buff, 0)
'get status
lo.Status = BitConverter.ToInt32(buff, 4)
'get valid fields
lo.ValidFields = CType(BitConverter.ToInt32(buff, 8), OperatorFormat)



'long name
If (lo.ValidFields And OperatorFormat.AlphaLong) = OperatorFormat.AlphaLong Then
lo.LongName = System.Text.Encoding.Unicode.GetString(buff, 12, 64)
nullindex = lo.LongName.IndexOf(Chr(0))
If nullindex > -1 Then
lo.LongName = lo.LongName.Substring(0, nullindex)
End If
End If


'copy short name
If (lo.ValidFields And OperatorFormat.AlphaShort) = OperatorFormat.AlphaShort Then
lo.ShortName = System.Text.Encoding.Unicode.GetString(buff, 76, 32)
nullindex = lo.ShortName.IndexOf(Chr(0))
If nullindex > -1 Then
lo.ShortName = lo.ShortName.Substring(0, nullindex)
End If
End If

'copy num name
If (lo.ValidFields And OperatorFormat.Numeric) = OperatorFormat.Numeric Then
lo.NumName = System.Text.Encoding.Unicode.GetString(buff, 108, 32)
nullindex = lo.NumName.IndexOf(Chr(0))
If nullindex > -1 Then
lo.NumName = lo.NumName.Substring(0, nullindex)
End If
End If

Return lo

End Function

Declare Function lineGetCurrentOperator Lib "cellcore.dll" (ByVal hLine As IntPtr, ByVal operator As Byte()) As Integer

Public Class Operator

   Public Index As Integer
   Public ValidFields As OperatorFormat
   Public Status As Integer
   Public LongName As String
   Public ShortName As String
   Public NumName As String

End Class

_
Public Enum OperatorFormat
   None = &H0
   AlphaShort = &H1
   AlphaLong = &H2
   Numeric = &H4
End Enum

 

#    Comments [0] |
# Thursday, February 24, 2005

MEDC Worldwide Dates Announced

The latest information on the MEDC2005 front is a list of dates and venues for the worldwide MEDC events which will follow the main MEDC conference in May. So far the following events have been announced:-

  • Korea (TBA) - 19th-20th May
  • Germany (Berlin) - 6th June
  • France (Paris) - 8th June
  • UK (Microsoft Campus) - 10th June
  • Malaysia (Kuala Lumpur) - 16th-17th June
  • Australia (Melbourne) - 20th June
  • Australia (Sydney) - 22nd June
  • China (Beijing) - 24th June

Full details, which I expect will be regularly updated can be found here at the MEDC website.

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

FolderBrowserDialog for Windows CE

To follow up from a recent enquiry on the newsgroup, neither .NETCF v1.0 or v2.0 include the FolderBrowserDialog component. The main reason for this is that this functionality is not implemented in all flavours of Windows CE, for example Windows Mobile (Pocket PC / Smartphone) doesn't include support for this dialog. If your device does support this shell feature then here is a simple wrapper I wrote which wraps the SHBrowseForFolder API in a FolderBrowserDialog class, which mimics the desktop equivelent. The code is packaged with a quick three line demonstration using the dialog. This works on the CE.NET 4.1 Emulator shipped with Visual Studio 2003.

Download InTheHand.Windows.Forms.FolderBrowserDialog.zip

If your platform is unsupported the control will throw a PlatformNotSupportedException when you call ShowDialog(). If you want to create this kind of functionality on Windows Mobile then a good starting point is the code accompanying this article at MSDN.

#    Comments [0] |
# Tuesday, February 22, 2005

Open individual documents on Pocket PC

The built in applications in Pocket PC follow a familiar model with a DocumentList screen listing files of that type, and then an "editor" screen for working with an individual document. If you launch a specific document programmatically it will open direct to that document, but when you close the app will continue to run returning to the document list. You can add the "-opendoc" argument to launch the application for that specific document and close completely once you've finished working with it. This allows you to more seamlessly use these applications from your own code and determine when they have completed. Using the Process class you would do:-

Process p = Process.Start("pword.exe","-opendoc \"\\My Documents\\mypocketwordfile.pwd\");

This argument is supported by Notes, Pocket Word, Pocket Excel and Pocket Streets

#    Comments [0] |
# Friday, February 18, 2005

Bluetooth Remote Control

Mike Hall posted a link on his blog to a channel9 interview with Anil Dhawan from the Windows Mobile team discussing Bluetooth programming, which I recommend you check out. Anil gave a demo of a native code application to remote control PowerPoint on a desktop PC. This inspired me to put some finishing touches to a test application I built for the Bluetooth .NETCF library - It is by no means finished but it works (with the wind blowing in the right direction!).

There are two components, on the Smartphone an application which you first select Search from the menu and it will do a lookup of local discoverable devices, then select one and select the Connect menu option. Once connected any d-pad or number keys are captured and sent over bluetooth. As I said it was an unfinished project, key items missing are:-

  • Store desktop address in the registry so we only have to search once
  • More intuitive interface :-)
  • Support for key mapping - map the device keys to application specific commands e.g. for media player etc

On the desktop a simple listener which listens on a custom service, incoming data is received as keycodes which are broadcast on the system using the SendKeys.Send method.

On an unrelated note, thanks to Sergey Bogdanov who has contributed an implementation of the SendKeys class to be included in the upcoming SDF v1.3 release.

With the listener application running and the Smartphone client connected you can automate (within reason) whatever app has the focus. It works great for Powerpoint browsing between slides using the d-pad on the phone. The usual disclaimer applies - this works only with the Microsoft Bluetooth stack on both device and desktop, I tested with an Orange SPV C500.

The two projects are available to download here.

#    Comments [3] |
# 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] |