Source Code Examples; Modem-Ras Sample Application - Digitax 4GMCU Technical Manual

Mobile control unit
Table of Contents

Advertisement

Source Code Examples

Modem-RAS sample application

This application shows how to use modem and RAS libraries on the Digitax 4GMCU:
The modem library allows to get real time information about telephony environment;
The RAS library simply permits to open (dial) and close (hang-up) a remote dial-up
connection providing its system name.
The RAS link library tries to keep the RAS entry connected in the best way by analyzing
modem status.
The application shows the modem status in real time, allows to dial and hang-up the RAS connection,
enable and disable the RAS link manager. It also demonstrates how to send SMS messages.
Sample code:
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Text;
using
System.Windows.Forms;
using
System.Threading;
using
System.Net;
using
Digitax.Mobile.Modem;
using
Digitax.Mobile.RAS;
using
Digitax.Mobile.RAS.Link;
namespace
Digitax.Mobile.Demo
{
public partial class
Demo
{
private const string
private const int
MODEM_PORT_BAUD = 57600;
private const string
private
ModemManager
private
RasEntryManager
private
LinkManager
_rasLink;
public
Demo()
{
InitializeComponent();
// instantiate modem manager
_modem =
new
ModemManager(MODEM_PORT_NAME, MODEM_PORT_BAUD);
//_modem.PIN = "1234"; // set here you SIM PIN
// register to modem events
_modem.CellNameChanged +=
_modem.DataProtocolChanged +=
_modem.IMEIChanged +=
_modem.IMSIChanged +=
_modem.NetOperatorChanged +=
_modem.NetStatusChanged +=
_modem.SignalStrengthChanged +=
_modem.SimCardStatusChanged +=
_modem.RxSms +=
new
// check for the existance of the RAS connection name
bool
connectionNameFound = false;
foreach
(RasEntryName
{
if
(rasName.Name == RAS_ENTRY_NAME)
{
connectionNameFound = true;
break;
}
}
if
(!connectionNameFound)
{
// RAS connection name DOES NOT exist
MessageBox.Show(
"The RAS connection '"
"' does not seem to be configured. RAS connection will not be
"Demo");
return;
}
// create RAS and Link managers
_rasEntry =
new
RasEntryManager(RAS_ENTRY_NAME);
_rasLink =
new
LinkManager(_rasEntry, _modem, false);
// register to RAS events
_rasEntry.ConnectionStateChanged +=
new
RasEntryManager.ConnectionStateChangedHandler(_rasEntry_ConnectionStateChanged);
// register to Link events
:
Form
MODEM_PORT_NAME = "COM4:";
RAS_ENTRY_NAME = "GPRS";
_modem;
_rasEntry;
new
CellNameChangedHandler(_modem_CellNameChanged);
new
DataProtocolChangedHandler(_modem_DataProtocolChanged);
new
IMEIChangedHandler(_modem_IMEIChanged);
new
IMSIChangedHandler(_modem_IMSIChanged);
new
NetworkOperatorChangedHandler(_modem_NetOperatorChanged);
new
NetworkStatusChangedHandler(_modem_NetStatusChanged);
new
SignalStrengthChangedHandler(_modem_SignalStrengthChanged);
new
SimCardStatusChangedHandler(_modem_SimCardStatusChanged);
RxSmsHandler(_modem_RxSms);
rasName
in
RasManager.GetEntryNames())
+ RAS_ENTRY_NAME +
// set here Com Port Name (leave 'COM4:' for the 3GMDT+)
// set here Com Port baud rate (leave 57600 for the 3GMDT+)
// set here the system RAS connection name
opened.",
37

Advertisement

Table of Contents
loading

Table of Contents