Wednesday 19 December 2007

Determining Broadcom vs Microsoft Bluetooth Stack on PPC

I was always under the impression that Smartphone used the Microsoft bluetooth stack and PocketPC used the Broadcom stack, but this isn't true!

OEMs for PocketPC can use any stack, so some PPC devices still use the Microsoft stack.

To determine this at runtime try loading the broadcom dll:


HINSTANCE hInst = LoadLibrary(L"btsdkce50.dll");

If this fails then try the microsoft bluetooth APIs...!

Sunday 9 December 2007

TrakAx Video Mixing Application Is Released!

I've been lucky to be involved in the development of the new Highandes TrakAx video mixing application for Windows Smartphones and PocketPC devices.

This has got to be one of the most powerful mobile video editing applications, taking phone content such as music, pictures, videos you can mix them together with effects to create a video to MMS, Email or save to your device to show your friends!

Heres a quick mix I made on my S710 (E650) 200Mhz phone from a recent skiing trip:

All mixed from the hotel bar afterwards!


A must for all Windows mobile phone owners!


See http://www.trakax.com/ for more information including a 7 day free trial!

Thursday 13 September 2007

SDHC support in Windows CE 5.0

With SD cards getting bigger and bigger many people don't realise that there is a different standard when you get up above 2GB's. This normally means 4GB and above.
A 4GB+ card is part of the SDHC (Secure Digital High Capacity, SD 2.0) Standard.
SDHC uses the FAT32 file system which supports a higher data density than FAT16. It uses the same form factor as SD, but the SD 2.0 standard in SDHC uses a different memory addressing method (sector addressing vs byte addressing). SDHC cards only work in SDHC compatible devices, but standard SD cards work in both SD and SDHC devices. The SDHC trademark is licensed to ensure compatibility.

To support this there is an update for CE 5.0, which can be found here http://support.microsoft.com/kb/933809. This enables deployment of SD 2.0 specification functionality which can theoretically take you up to 32GB. SD 2.0 functionality is available out-of-the-box in Windows CE 6.0.

Wednesday 25 July 2007

In the dark with backlights...

Nice easy one here, which is always useful...

On PPC/Smartphone if your app needs to keep the backlight on you can requst that the backlight driver is kept in a high power state (i.e. ON!)

// force backlight on
SetPowerRequirement(TEXT("BKL1:"), D0, POWER_NAME POWER_FORCE, NULL, 0);


On PPC you may need to keep the system alive as well else it'll go into suspend, but this'll work indefinately on smartphone.

Use ReleasePowerRequirement to return the backlight to system timeout control. Note unlike some SatNav software this is nicer than editing the control panel system settings...! ;)

Friday 13 July 2007

Enabling DShow Debug

Having problems debugging your new DShow filter?

When using a debug CE build (or a retail build with a debug quartz.dll) if you can enable DShow logging by turing on the following debug zones of quartz (tested in CE6.0):



Good luck debugging!

In previous OS versions (certainly CE4.2) you could edit the registry to enable these zones:

[HKEY_LOCAL_MACHINE\SOFTWARE\Debug\GLOBAL]
"TIMING"=dword:0
"TRACE"=dword:0
"MEMORY"=dword:0
"LOCKING"=dword:0
"ERROR"=dword:0

The levels go from 0 (none) to 5 (full). Try first changing TRACE and ERROR to 5 to start with.

Thursday 12 July 2007

Video Driver Speedup



I've been working recently on improving the video performance on a Samsung 2413 processor.

The platform I'm working on does not have hardware video acceleration or a hardware cursor.

Did you know that if you disable the software cursor in the driver and remove the overlap detection for emulated line and blit you can get a two fold speed increase at least with drawing polygons.

The hardware supports DMA and I've started to look at using this to accelerate line fills and various blits. Unfortunately the hardware does not support block DMA which cuts down how it could help with majority of blit operations. Another snag with this approach is the overhead it takes to setup the DMA controller and cope with odd end of line conditions.

Tuesday 19 June 2007

DeviceEmulator Slow?

Recently I was working with DeviceEmulator on Windows CE 6.0 and it seemed slow. If you are using Windows CE 6.0 and you would like debug OS images to be a little more responsive when running on DeviceEmulator here’s a couple of things we found that you can try.

Add a DWORD value in HKCU\Software\Microsoft\Platform Builder\6.00\Debug called "SynchronousDebugMessage" and set it to 0.

This tip found here:
http://groups.google.com/group/microsoft.public.windowsce.platbuilder/browse_thread/thread/860b1ff6347ed62c/0d3af9395d161fce?lnk=st&q=%22(un)load%22+windowsce&rnum=3&hl=en#0d3af9395d161fce

The other thing you can try is to ignore module loads until later.
Go to target->connectivity options dialog
Switch to the "service status" tab
Click "settings" for "Kernel Debugger OS Awareness".
Switch the "Module (un)load notification to the debugger" option

The help from the dialog says the following options are available:
Always off: Never catch notification, module changes are updated on each halt. Boot time and execution is fast, real-time, but breakpoints cannot be instantiated on time.
Always on: Catch notification of all module changes immediately. Boot time and execution is slow, non real-time, but breakpoints can be instantiated on time.
Off until first halt: Suppress notification until first target halt, then catch all notifications.

This tip found here:
http://groups.google.com/group/microsoft.public.windowsce.platbuilder/browse_thread/thread/860b1ff6347ed62c/0d3af9395d161fce?lnk=st&q=%22(un)load%22+windowsce&rnum=3&hl=en#0d3af9395d161fce

Command line (Console) over serial

I'm a big fan of command line access, if you've got a headless device or a device with a custom shell / UI this tweak is really useful...!

To configure the command processor shell on windows CE to run over a serial connection add the following to your registry

[HKEY_LOCAL_MACHINE\Drivers\Console]
OutputTo = REG_DWORD:1 // Redirects CMD to COM1
COMSpeed = REG_DWORD:19200 // Speed of serial connection

This redirects all input and output for all console applications to the serial port, hmm wonder if it'll work with bluetooth as well... :)

Thursday 14 June 2007

Using Image Factory under CE/Windows Mobile

Having trouble getting Windows CE/Windows Mobile factory working to load pictures?

The code below will load a JPG/GIF/PNG (or whatever decoders are installed on your device) etc from a file and paint it to the screen:

CoInitializeEx(NULL, 0);
IImagingFactory* pImageFactory;
IImage *pImage = NULL;

HDC dc = GetDC(0); // insert your window handle here, else this is the desktop

HRESULT hr = CoCreateInstance(CLSID_ImagingFactory, NULL,
CLSCTX_INPROC_SERVER,
__uuidof(IImagingFactory),
(LPVOID *)&pImageFactory);

// Load image from file
pImageFactory->CreateImageFromFile(bitmapName, &pImage);

// Get image information
ImageInfo info;
pImage->GetImageInfo(&info);

RECT rc={0,0,info.Width, info.Height};

// draw jpg/gif etc onto temp dc
pImage->Draw(dc, &rc, NULL);

// Clean up
pImage->Release();
pImageFactory->Release();

CoUninitialize();



Wednesday 13 June 2007

Memory Leaks with MFC CPtrArray


Just finished debugging some 3rd party code with memory leaks.

The code used the RemovalAll member operation on the MFC CPtrArray class. This operation needs to be used with care as all the array elements need to be deleted AFTER the call to RemoveAll. Calling RemoveAll before deleting all the array objects will cause a memory leak.
Another memory leak was caused by deleting a class pointer that had been passed to a function as a void pointer. When delete is executed on a void pointer the destructor of the class is obviously not called.

One final comment on memory leaks fixing is beware when using the EVC4 debug environment. Over the past few days I was chasing a memory leak that did not exist but was a symptom of using the debugger!

Tuesday 12 June 2007

Windows Mobile Device Center 6.1 for Windows Vista

You can now find the latest release of WMDC version 6.1 available.


The key updates delivered in this release include:

  • IRM activation
  • HTML mail
  • Certificate enrollment
  • File synchronization on all WM 6 devices (Yes, even Smartphone!)
  • Windows Embedded CE 6.0 support
  • Automatic device authentication
  • Product registration
  • Silent-mode install for corporate deployment
    And more!

But from our basic testing it looks like it solves the previous versions problem which is connecting Vista to a Windows Embedded CE device via it's Activesync module. Even though the MS official descriptions only indicate WinCE 6.0 I have had it tested with a WinCE 4.2 device (seen here). So I see no reason why it's not going to work with 4.0, 4.2 & 5.0 etc.

Tuesday 15 May 2007

New contributor

This is my first post and should go someway to introduce myself and let you know my relevant background and experience.

My name is Nigel Goodyear and I've spent 19 years in the mobile and embedded computer industry. 14 of these working at a rugged handheld manufacturer, Husky Computers (now Itronix) and have been with Intrinsyc since 2002.

Both jobs have led to in depth experience with mobile computers, embedded systems and wireless communications.
My Microsoft Windows Embedded experience includes:
  • Porting BSP's, device drivers and low level firmware
  • Windows Embedded CE version 2.11 to 6.0 and Windows Mobile
  • Customer Account and Project Management
(q) No prize - but does anybody remember the o/s variant and kernel this device executed?




Thursday 3 May 2007

Bluetooth Stacks and Windows Mobile

If you want to programmatically access the Bluetooth stacks on Windows Mobile its worth knowing that the Pocket PC stack is different from the stack in Smartphone.

Pocket PC uses the Broadcom stack, the SDK can be freely downloaded from Broadcom at http://www.broadcom.com/products/bluetooth_sdk.php

Smartphone uses the standard Microsoft stack that has its API set built into the Smartphone SDK, the details of which can we seen on MSDN http://msdn2.microsoft.com/en-us/library/ms834669.aspx

Wednesday 2 May 2007

Routing IP traffic via specified adapter

On a recent project it became necessary to be able to route certain IP traffic via a specified network adapter. Although rather involved this is not as hard as it may first seem. On a desktop this would be achieved by changing the IP routing tables using the ROUTE command, but how do you do this programmatically on a handheld?

First it is necessary to find the IP address, gateway address and interface index of the adapter that you wish to route over. This information can easily be obtained by calling GetAdapterAddresses() a number of times to enumerate all network device data.

Once the IP information has been obtained for the selected adapter then CreateIpForwardEntry() can be called to setup the route. The CreateIpForwardEntry() API takes a PMIB_IPFORWARDROW parameter essentially a route definition. This needs to be setup as follows:
  • dwForwardDest - Set to the IP address of server you will be connecting too.
  • dwForwardMask - Mapping IP address mask. This will need to be 255.255.255.255 for specified traffic.
  • dwForwardPolicy - Set to zero.
  • dwForwardNextHop - This needs to be set to the discovered IP adapters gateway address.
  • dwForwardIfIndex - This needs to be set to the discovered IP adapters index.
  • dwForwardType - This is set to MIB_IPROUTE_TYPE_INDIRECT.
  • dwForwardProto - This is set to MIB_IPPROTO_NETMGMT.
  • dwForwardAge - Set to zero.
  • dwForwardNextHopAS - Set to zero.
  • dwForwardMetric1 - Set to 1.
  • dwForwardMetric2-5 - Set to 0xFFFFFFFF.
It is now possible to simply use sockets to connect to the server or service that you specified in the dwForwardDest. All IP traffic over this socket will be directed via the adapter that was specified.

At the end of the session the DeleteIpForwardEntry() API should be called to tear down the route.

Changing start menu appearance

I've just read this on the newsgroup 'microsoft.public.smartphone.developer' and did not realise how easy it was to do. The display setting for the start menu is controlled by the registry key:

HKCU\Software\Microsoft\Shell\StartMenu\GridView

Set it to 0 to get a list view and a 1 to get a grid view.

Monday 30 April 2007

Using Multi/Dual Core Processors with Platform Builder

If you’re lucky enough to have a dual core development PC, try adding this to your PC environment variables to enable parallel builds on both CPUs:

set BUILD_MULTIPROCESSOR=2

You’ll then see in taskmanager that your CPU usage goes up to 100% now instead of just past 50%!

Removable disk timeouts in CE

Ever wondered why it takes ages for the Windows CE filesystem to remove SDCards from the filesystem after physically removing the card?

Well its because there are two FATFS registry settings which affect this behaviour. Also these are the reason why after a resume an SDCard can take 12 seconds to become responsive again if a ReadFile operation was called when the driver was powering down for the suspend.

"PNPUnloadDelay"
Specifies the time delay in milliseconds between unmounting and detaching a device.
Used during suspend/resume cycles where a block driver might unload and reload on resume.
Default is 5000 microseconds.

"PnPWaitIoDelay"
Specifies the amount of time waited before re-trying an I/O operation on an unavailable device.
This subkey is not present in the default registry, but may be added by the OEM. If this value is not specified, it is assumed to be three times that of PNPUnloadDelay

See :

http://msdn2.microsoft.com/en-us/library/aa912238.aspx

The default is set in CE5.0 as 4 seconds to unmount the volume after device removal, this is the delay you see in explorer. And 3 x 4 seconds if any IO operation fails (i.e. if an app is reading/writing to an SDCard whilst the device is suspending/resuming)

Wednesday 25 April 2007

Bluetooth (serial) SPP using Sockets...!

If you wondered how to connect to a BT serial device using SPP over sockets... heres how!

// create your BT socket
SOCKET s = socket (AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM);

// Create the connection information, this is the RFComm protocol for SPP
SOCKADDR_BTH sa;
memset (&sa, 0, sizeof(sa));
sa.addressFamily = AF_BTH;
sa.btAddr = device;
sa.port = BT_PORT_ANY;
sa.serviceClassId = RFCOMM_PROTOCOL_UUID;
// connect...
connect (s, (SOCKADDR *)&sa, sizeof(sa))


Once connected you can use send/recieve to send over the SPP connection:

send (connectedSocket, (char*)str, len,0)
recv( connectedSocket, str, len,0)

This way you don't have to map serial ports, this was tested on Windows XP but should also work on windows CE.

It was tested printing GPS information from a TOMTOM reciever.

CE6.0 and DumpMem()

There is a known issue with DumpMem() in Ce6.0. It does not correctly format the memory and only the memory offsets are shown. This is evident no matter which debug stream is used.

Debug in CE6.0 and PB6.0

Platform builder 6.0 supports two options for the way debug messages are handled.

Sync Mode

Here the target device waits until the host displays the debug message. The advantage being that you see messages when they were sent but it does slow down the target device.

Async Mode

Here the target device runs as fast as possible. The debug message is queued on the host to allow the device to continue. Debug is only displayed on the host as time permits.

These debug modes are available via the host's registry.

HKCU\Software\Microsoft\Platform Builder\6.00\Debug
DWORD value "SynchronousDebugMessage"
0 == ASYNC
1 == SYNC

Tuesday 24 April 2007

How to get IMEI, SIM number, Operator and country


Whilst working on my current project I discovered how to get the following information out of Windows Mobile.
  • The Modem IMEI number
  • The SIM number (not the phone number)
  • The SIM operator
  • The SIM operator ID and cell country
These can all be obtained via TAPI. The IMEI and SIM number are available via the lineGetGeneralInfo API. These are returned as the SerialNumber and SubscriberNumber. The SIM operator, ID and cell country are returned by a call to the lineGetCurrentOperator API. Check out about more ExTAPI calls on MSDN here.

Monday 23 April 2007

Taking control of the "Back" button on Windows Mobile

Ever wanted to know how to get control of the "Back" button on Windows Mobile? The answer can be found in this MSDN article.

Thursday 19 April 2007

How to get your phone number

Just discovered how to pragmatically get your phone number from Window Mobile. This is documented well on the Windows Mobile Team Blog Site here.

Wednesday 18 April 2007

EVC 4.0 Remote Tools

Having problems with EVC 4.0 tools greyed out and pointing to the wrong SDK? A collegue of mine has just found the answer. The workaround is in the online EVC 4.0 Release Notes:

View the file properties of the directories:
C:\Program Files\Common Files\Microsoft Shared\Windows CE Tools\Platman\Bin
C:\Program Files\Common Files\Microsoft Shared\Windows CE Tools\Platman\Bin\WCE500

Click the "Advance" button
Click to check the "For fast searching, allow Indexing Service to index this folder" check box
Click "OK"

Vista and ActiveSync

For the Vista users out there you have probably discovered that ActiveSync is no longer supported. What you should be using is Windows Mobile Device Center more info and available for download from Microsoft here.

One unfortunate oversight is that it will not currently Sync with the new Vista Windows Calendar or Email applications. Microsoft, however, are planning a new service release that will support this applications in the future.

Signing Windows Mobile Application Code using Miicrosoft Visual Studio 2005

This post deals with signing code against the Windows Mobile SDK developers certificates. If you have not already installed the SDK certificates on your device see this post. The first step is to install the SDK certificates on your development machine:

  • Navigate to C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 SDk\Tools
  • Double-click on the SDKSamplePrivDeveloper.pfx file
  • Press the "Next" button on the "Welcome to the Certificate Import Wizard" dialogue
  • Press the "Next" button on the "File to Import" dialogue
  • Press the "Next" button on the "Password" dialogue
  • Press the "Next" button on the "Certificate Store" dialogue
  • Press the "Finish" button on the "Completing the Certificate Import Wizard" dialogue
  • Press "Ok" on "Completed" dialogue
  • Repeat the process for the SDKSampleUnprovDeveoper.pfx file

Having installed the certificates you will now need to sign your CAB's, DLL's and EXE's against them. This is done as follows:

  • Open your Microsoft Visual Studio project solution
  • Select from the menu Project->Properties
  • Expand the "Configuration Properties" tree in the left-hand pane
  • Expand the "Authenticode Signing" in the "Configuration Properties" tree
  • Select "General"
  • In the right-hand pane change the "Authenticode Signature" selection to "Yes"
  • Select the "Certificate" field and press the "browse" ellipse to the left
  • Select the certificate you wish to sign against marked "TEST USE ONLY - Sample Privileged Root for Windows Mobile SDK" or "TEST USE ONLY - Sample UnPrivileged Root for Windows Mobile SDK" and hit OK
  • Select "OK" to properties dialogue

On your next build Visual Studio will now automatically sign your executable.

Visual Studio 2005 and Windows CE6.0 Problems

Running VS2005 with a custom CE6.0 SDK requires installing Visual Studio 2005 SP1 (see msdn.microsoft.com/vstudio/support/vs2005sp1/default.aspx) without this the application can fail to deploy to the platform correctly.

Also SP1 is needed when running on Windows Vista.

Unlocking a Smartphone for development


To develop on a Windows Smartphone you will first need to get the SDK certificates to sign against installed. This is a non-trivial process which involves a couple of registry entry changes and the installation of a CAB file.
First a signed registry editor must be located to run on your target device. These can be found by doing an Internet search for "REGEDIT.EXE". When found copy the EXE onto the device, launch it and change the following registry values:
  • Navigate to HKLM\Security\Policies\Policies\
  • Change the "00001001" value to a decimal 1
  • Change the "00001005" value to a decimal 40
  • Reboot the device
At this point your Smartphone is "Unlocked" to run any code. In the development environment we want to be able to sign code against the correct privileged certificates. The next step is to install these certificates.
  • First install the Windows Mobile Smartphone SDK. This is available here from Microsoft.
  • Copy the file C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Smartphone SDK\Tools\SDKCerts.cab onto the device.
  • Launch the CAB file.
  • Reboot the device.
It is now advisable to "Re-lock" your Smartphone so that you can check you are signing your application against the right security certificates. This is done by launching "REGEDIT.EXE" and changing the following registry values:
  • Navigate to HKLM\Security\Policies\Policies\
  • Change the "00001001" value to a decimal 2
  • Change the "00001005" value to a decimal 16
  • Reboot the device
See Stuart Preston's Blog for more information.

Cellcore on Windows CE6.0

Cellcore is the telephony component used on Windows Mobile, this enables voice, data and text functions via a GSM modem.

CE6.0 comes with two examples modem drivers (RIL - Radio Interface Layers) for the TTPCom and Enfora Modems.

Most of the sources, headers and registry entries can be found under the CE6.0 tree here:

C:\WINCE600\PUBLIC\CELLCORE


Here you’ll also find the 710 Multiplexer, this component effectively splits the single serial port that the modem is available on into two virtual serial ports (default is COM9 and COM7).

To make phone calls Cellcore uses TAPI (Telephone Application Programming Interface) see some of the Smartphone/PocketPC SDK examples for some coding examples.

Making data calls can be done using RAS Dial up, but the RAS setup needs to specify the APN for the data connection. There are no examples under Windows Mobile as this is all handled in Connection Manager on WinMobile.

CE6.0 comes with a WWANDIS component which looks like it virtualises data connections to have a ‘Virtual Ethernet’ driver over GPRS, but there aren’t any docs I can find, anyone know how this works?

Mike Hall has a demo of Cellcore in action on an electronic picture frame… see Mikes Cellcore Demo

C4All The start of a new era

This is the first post of what we hope will be many. The contributors want to share their combined experiences of the Windows Embedded operating systems. So who are these contributors?

Rob Nock
  • Spent 9 Years working with Mitsubishi PC Division (Apricot Computers) and has been with Intrinsyc since 1999.
  • Both jobs have led to in depth experience with embedded systems.
  • Worked on Windows CE from version 3.0 up to 6.0.
  • Worked on Windows Mobile 5.0 and 6.0.
  • Ported BSP's, written numerous drivers and applications.

Graeme Wintle

  • Previous to Intrinsyc (also since 1999 - Rob started the same day!) working at Nokia Telecoms and GST Technology
  • 15 Years of experience in the embedded space
  • Experience ranging from OS Porting to Application design on Windows CE and Windows Mobile
  • 17 hardware platforms under my porting belt so far...!