MSN Direct Sample Application

Windows CE 5.0 Not SupportedWindows Embedded NavReady 2009 Supported

10/16/2008

The MSN Direct sample application (MSNDirectApp.exe) implements the base functionality of an application that receives and processes up-to-date data from MSN Direct services. The sample application runs on a Windows Embedded CE standard development board (SDB) and is used to receive and process simulated data sent from the MSN Direct receiver emulator, which receives and processes simulated data. It also displays text output about the data it receives from the serial connection in the sample user interface (UI).

MSN Direct Sample Application Overview

The MSN Direct sample application creates a subclass of the DBR701 class called DBRHost and overrides the ProcessInMessageFromReceiver function. It processes incoming messages according to their MSN Direct service type.

The sample application also provides necessary mechanisms to parse, cache, and store up-to-date data received from the class library.

DBRHost

The DBRHost class implements the host-side of the MSN Direct protocol. It listens for messages received from the MSN Direct receiver emulator through the serial connection and dispatches the messages to their relevant message handlers. Then, the message handlers handle and cache the messages themselves. For each message type supported by the sample application (except for the aggregated messages for movies and gas), there are at least three files:

  • An XXXHandler.cpp source-code file, which receives messages sent by the MSN Direct receiver and caches or otherwise stores the relevant data
  • An XXXForm.cpp source-code file, which displays the data stored in the corresponding XXXHandler.cpp file by using the command prompt
  • A XXXMsg.cpp source-code file, which maps to the different types of messages relevant to MSN Direct data

DBRHost is a relatively small class. Its main purpose is to pass messages along to the appropriate message handlers. The handlers perform the caching and aggregation required by each application type. The handlers also provide member functions that add messages, or read and parse stored data. XXXForm classes are used to display the parsed contents of each message to the developer as text in a simple user interface (UI).

For example, local-weather messages are represented by the WeatherMsg class and cached in the WeatherHandler class, and are displayed as output by using the code stored in the WeatherForm.cpp file. For non-system messages, the definition of the message and its implementation is also provided.

MSNDirectApp

The MSNDirectApp.cpp file provides the entry point for the sample application. The program declares a global variable named DBRHostInstance, which is of type DBRHost*.

There are three steps to be performed in order to connect to the MSN Direct receiver and process messages:

  1. The application code creates an instance of the DBRHost class.
  2. The application code calls the Open method on the DBRHost instance to start the serial communication to receive data from the radio receiver.
  3. The application code destroys the DBRHost instance, which terminates the serial communication.

In the user interface (UI) of the sample application that runs on the Windows Embedded NavReady powered device, the Connect button starts the serial communication with the receiver, while the Disconn button terminates the communication. The Request button can be used to perform custom requests at any time. The Request button extracts the user-supplied string that is typed in the text box and converts it into an integer value that can be used to request specific data. For a list of possible integer values, see MSN Direct Service Type Constants.

Other types of requests are handled when the developer presses a button in the menu or presses a Request button on a specific form.

The message classes show a possible implementation of the serial-communication protocol between the radio receiver and the Windows Embedded NavReady powered device.

Path to the MSN Direct Sample Application

The sample application is located at %_WINCEROOT%\PUBLIC\SERVERS\SDK\SAMPLES\MSNDIRECT.

See Also

Concepts

MSN Direct Services Development Tools
How to Use the MSN Direct Development Tools