Mobitex IAS MDOT connector

    Table of contents
    No headers

     

     

    Note: As the Mobitex network in the UK is being shut down, this can be considered obsolete.

     

    turboExchange.DLL contains an MDOT client for connecting to a Mobitex IAS. This allows you to send and receive Turbo Dispatch text messages through the mobitex network.  It also automatically converts, and routes the messages to the Turbo Exchange network where the MAN number starts with a 9 instead of the usual 3 or 6.  It makes a direct connection to the mobitex IAS server, for which you must have an account.

    In native mode, messages routed via the Mobitex network, must be within 512 characters, otherwise the message send will fail.  In Turbo Exchange mode, the inbuilt converter takes care of processing the messages into the correct format.

    Care should also be made when disconnecting from the IAS server, as it will lock you out for around 10 minutes if the connection is not cleanly disconnected.  This is a limitation of the IAS server, and not a fault with this software.

     

    1.    Add the following .DLL files as a reference to your project.

    turboExchange.dll

    protobuff-net.dll

     

    2.    Add the following code decleration the the main static class that starts the program (Program.cs)

    static clsTurboMessageMill TurboMessage;
    static public turboExchange.Network.clsTurboClient turboClient;
    static public turboExchange.Network.Mobitex.clsMobitexMDOT MDOT;

     

     3.    Add the following code in your Main() procedure

    //Initialise TurboExchange Client
    TurboMessage = new clsTurboMessageMill();
    turboClient = new turboExchange.Network.clsTurboClient(TurboMessage);
    
    //Set username & password
    turboClient.Authentication.Username = "MyUsername";
    turboClient.Authentication.PasswordString = "MyPassword";
    
    //Start comms connection, with a 1 second delay (gives everything a chance to initialise)
    turboClient.ConnectAsyc(1000);
    
    //Include legacy Mobitex MOT support
    MDOT = new turboExchange.Network.Mobitex.clsMobitexMDOT(turboClient);
    
    //Listen to comms events
    turboClient.EventConnectionStatus += new turboExchange.Network.clsTurboClient.envStatus(turboClient_EventStatus);
    turboClient.EventUnsentMessage += new turboExchange.Network.clsTurboClient.envUnsentMessage(turboClient_EventUnsentMessage);
    
    //Listen to MDOT comms events
    MDOT.EventConnectionStatus += new turboExchange.Network.Mobitex.clsMobitexMDOT.envStatus(MDOT_EventConnectionStatus);
    //OPTIONAL Native Mode
    //MDOT.EventMessageReceived += new turboExchange.Network.Mobitex.clsMobitexMDOT.envMessageReceived(MDOT_EventMessageReceived);
    
    }
    
    static void turboClient_EventUnsentMessage(turboExchange.Messages.MessageWrapper wrap)
    {
    
    }
    
    static void turboClient_EventStatus(turboExchange.Network.clsTurboClient.enumStatus eStatus)
    {
    
    }
    
    static void MDOT_EventConnectionStatus(turboExchange.Network.Mobitex.clsMobitexMDOT.enumStatus eStatus)
    {
    }
    
    static void MDOT_EventMessageReceived(uint SourceMAN, uint DestinationMAN, string Message)
    {
        // process Mobitex message (Native Mode)
    }

     

    4.    Before your application closes

     

    turboClient.Close();
    MDOT.Close();

     

    5.    Add the following class "clsTurboExchangeMill" for processing incoming messages.  Add your own code in the switch/case block, to read the message contents.

     

    using System;
    using System.Text;
    using System.IO;
    using ProtoBuf;
    using turboExchange;
    using turboExchange.Messages;
    
    
    namespace turboExchangeExample
    {
        class clsTurboMessageMill : turboExchange.ITurboClientMill
        {
    
            public turboExchange.Network.clsTurboClient Client { get; set; }
    
            /// <summary>
            /// Authentication accepted
            /// </summary>
            public void LoggedIn()
            {
            }
    
            public void LoggedOut()
            {
            }
    
            //Incoming messages arrive here. Use Switch{Case:} to farm them out to specific procedures.
            public void ProcessMessage(turboExchange.Messages.MessageWrapper wrap)
            {
                try
                {
                    Console.WriteLine("ProcessMessage: {0}" , wrap._messageType);
                    switch (wrap._messageType)
                    {
                        case MessageWrapper.MessageType.turboRecoveryJob:
                            ProcessRecoveryJob(wrap);
                            break;
                        case MessageWrapper.MessageType.turboRecoveryJobReply:
                        case MessageWrapper.MessageType.turboRecoveryClearDown:
                        case MessageWrapper.MessageType.turboInvoice:
                        case MessageWrapper.MessageType.turboInvoiceReply:
                        case MessageWrapper.MessageType.turboInvoiceRemittance:
                        case MessageWrapper.MessageType.turboTextMessage:
                        case MessageWrapper.MessageType.turboVehicleHire:
                            
                        default:
                            Console.WriteLine("Unsupported Message Type");
                            break;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("ProcessMessage Error - " + ex.Message);
                }
    
            }
    
            /// <summary>
            /// Example procedure to display Job Data
            /// </summary>
            /// <param name="wrap"></param>
            private void ProcessRecoveryJob(MessageWrapper wrap)
            {
                if (wrap._messageFormat == MessageWrapper.MessageFormat.ProtoMessage)
                {
                    //Deserialise the Protobuffer message
                    var recoveryJob = wrap._payload.DeserializeProtoBytes<turboExchange.Messages.turboMessage.RecoveryJob>();
    
                    switch (recoveryJob._messageEvent)
                    {
                        case turboExchange.Messages.turboMessage.RecoveryJob.MessageEvent.NewJob:
                            Console.WriteLine("New Recovery Job");
                            break;
                        case turboExchange.Messages.turboMessage.RecoveryJob.MessageEvent.JobUpdate:
                            Console.WriteLine("Recovery Job Update");
                            break;
                    }
    
                    Console.WriteLine(recoveryJob._jobNumber);
                    if (recoveryJob._jobDateTimeSpecified) Console.WriteLine(recoveryJob._jobDateTime.ToDateTime());
                    if (recoveryJob._agentReferenceSpecified) Console.WriteLine(recoveryJob._agentReference);
                    if (recoveryJob._clientNameSpecified) Console.WriteLine(recoveryJob._clientName);
                    if (recoveryJob._driverLocationSpecified) Console.WriteLine(recoveryJob._driverLocation);
                    if (recoveryJob._faultDescriptionSpecified) Console.WriteLine(recoveryJob._faultDescription);
    
                    if (recoveryJob._vehicle != null)
                    {
                        if (recoveryJob._vehicle._makeSpecified) Console.WriteLine(recoveryJob._vehicle._make);
                        if (recoveryJob._vehicle._modelSpecified) Console.WriteLine(recoveryJob._vehicle._model);
                        if (recoveryJob._vehicle._registrationSpecified) Console.WriteLine(recoveryJob._vehicle._registration);
                        if (recoveryJob._vehicle._colourSpecified) Console.WriteLine(recoveryJob._vehicle._colour);
                        if (recoveryJob._vehicle._engineSpecified) Console.WriteLine(recoveryJob._vehicle._engine);
                        //.....etc ...etc
                    }
    
    
                    //Get Remarks
                    foreach (turboExchange.Messages.turboMessage.RecoveryJob.timedTextField textField in recoveryJob._remarks)
                    {
                        Console.WriteLine("{0} {1}",textField._dateTime, textField._text);
                    }
    
                    //Get Notes (typically only sent internally, and not shared with other organisations)
                    foreach (turboExchange.Messages.turboMessage.RecoveryJob.timedTextField textField in recoveryJob._notes)
                    {
                        Console.WriteLine("{0} {1}", textField._dateTime, textField._text);
                    }
    
                    //.....etc ...etc
                }
            }
    
    
            /// <summary>
            /// Connection disconnected, may reconnect
            /// </summary>
            /// <param name="reason"></param>
            public void Disconnected(turboExchange.Network.clsTurboClient.enumResonToClose reason)
            {
            }
    
            /// <summary>
            /// Triggered when the watchdog fires (~1 min or less)
            /// </summary>
            public void WatchdogTimer()
            {
            }
    
            /// <summary>
            /// Connection is closing (Forced - e.g. application shutdown)
            /// </summary>
            public void Close()
            {
            }
        }
    }