Map27
 All Classes Functions Variables Enumerations Enumerator Pages
Classes | Public Types | Public Member Functions | List of all members
Map27NetworkLayer Class Reference

Manage the Network Layer of the Map27 protocol stack. More...

#include <Map27/NetworkLayer.h>

Public Types

enum  NetworkState {
  NETWORK_STATE_IDLE = 1, NETWORK_STATE_OUTCALL_WAIT, NETWORK_STATE_OUTCALL_INCLUDE_WAIT, NETWORK_STATE_ACTIVE,
  NETWORK_STATE_INCALL_WAIT, NETWORK_STATE_STATUS_WAIT, NETWORK_STATE_SST_WAIT, NETWORK_STATE_MST_WAIT,
  NETWORK_STATE_DIVERSION_WAIT
}
 

Public Member Functions

 Map27NetworkLayer ()
 Constructor.
 
void setDataLayer (Map27DataLayer *dataLayer)
 
Map27DataLayerdataLayer ()
 
void setApplicationLayer (Map27ApplicationLayer *applicationLayer)
 
Map27ApplicationLayerapplicationLayer ()
 
NetworkState state ()
 
bool is_idle ()
 
void power_on ()
 
void reset ()
 
void poll ()
 
Inputs from Data Layer:

These events are sent by Map27DataLAyer in repsonse to events in lower layers. You might override them in a custom subclass.

virtual void link_ready ()
 
virtual void link_failure ()
 
virtual void packet_accepted ()
 
virtual void packet_rejected ()
 
virtual void network_layer_packet (uint8_t *buf, uint16_t bufLen)
 

Protected Member Functions

Message decoders

These functions are called when for different types of mesasge. They are passed a pointer to the raw message data buffer,and are repsonsibel for decoding the mesage and calling the appropriate member funciton in the Application Layer. You may want to subclass Map27NetworkLayer and override one or more of these functions for special behaviour.

virtual void receiveStatus (uint8_t *buf, uint16_t bufLen)
 
virtual void receiveStatusAck (uint8_t *buf, uint16_t bufLen)
 
virtual void receiveSST (uint8_t *buf, uint16_t bufLen)
 
virtual void receiveSSTAck (uint8_t *buf, uint16_t bufLen)
 
virtual void receiveMST (uint8_t *buf, uint16_t bufLen)
 
virtual void receiveMSTAck (uint8_t *buf, uint16_t bufLen)
 
virtual void receiveSetupProgress (uint8_t *buf, uint16_t bufLen)
 
virtual void receiveIncomingVoiceModem (uint8_t *buf, uint16_t bufLen)
 
virtual void receiveProgress (uint8_t *buf, uint16_t bufLen)
 
virtual void receiveModemData (uint8_t *buf, uint16_t bufLen)
 
virtual void receiveCleared (uint8_t *buf, uint16_t bufLen)
 
virtual void receiveRadioPersonality (uint8_t *buf, uint16_t bufLen)
 
virtual void receiveProtocolInfo (uint8_t *buf, uint16_t bufLen)
 
virtual void receiveNumberingInfo (uint8_t *buf, uint16_t bufLen)
 
virtual void receiveRadioSettings (uint8_t *buf, uint16_t bufLen)
 
virtual void receiveOperatingCondition (uint8_t *buf, uint16_t bufLen)
 
virtual void receiveNetworkInformation (uint8_t *buf, uint16_t bufLen)
 
virtual void receiveRadioTestResult (uint8_t *buf, uint16_t bufLen)
 

Inputs from ApplicationLayer

Applications can send messages by calling these members

bool sendStatus (const Map27Address &address, uint8_t status)
 
bool sendSST (const Map27Address &address, uint8_t *buf, uint16_t bufLen)
 
bool sendMST (const Map27Address &address, uint8_t *buf, uint16_t bufLen)
 
bool setupVoiceModem (const Map27Address &address, uint8_t details)
 
bool setupEmergencyVoiceModem (const Map27Address &address, uint8_t details)
 
bool sendModemData (uint8_t *buf, uint16_t bufLen)
 
bool sendDisconnect (const Map27Address &address, uint8_t cause)
 
bool sendCleared (const Map27Address &address, uint8_t cause)
 
bool sendDiversionRequest (const Map27Address &address, uint8_t info, const Map27Address &diversionAddress)
 
bool sendDiversionCancel (const Map27Address &address, uint8_t info)
 
bool sendRadioInterrogation (uint8_t reason)
 
bool sendVolumeControl (uint8_t control_port, uint8_t volume)
 
bool sendDialledString (uint8_t *buf, uint16_t bufLen)
 
bool sendRadioTest (uint8_t *buf, uint16_t bufLen)
 
void decode_network_layer_packet (uint8_t *buf, uint16_t bufLen)
 
void request_timeout ()
 

Outputs to Application Layer

These functions are called to deliver events to the Data Layer You may want to override themfor special behaviour

virtual void output_application_error (uint8_t type)
 
static void request_timer_callback_glue (void *target)
 

Detailed Description

Manage the Network Layer of the Map27 protocol stack.

This class receives messages to be sent from the Map27ApplicationLayer and formats them for transmission to the Radio by Map27DataLayer. It also received messages from the Radio received by Map27DataLayer and delivers them to Map27ApplicationLayer.

Examples:
test.cpp, test2.cpp, and test3.cpp.

Member Enumeration Documentation

Network Layer state _network_state values. The network layer is always in exactly one of these states

Enumerator
NETWORK_STATE_IDLE 

Idle, ready to start a new transaction.

NETWORK_STATE_OUTCALL_WAIT 

Waiting for an outgoing voice/data call to be set up.

NETWORK_STATE_OUTCALL_INCLUDE_WAIT 

Waiting for an additional outgoing voice/data call to be set up.

NETWORK_STATE_ACTIVE 

Voice/data call is active.

NETWORK_STATE_INCALL_WAIT 

Waiting for an incoming voice/data call to be set up.

NETWORK_STATE_STATUS_WAIT 

Waiting for status send to complete.

NETWORK_STATE_SST_WAIT 

Waiting for an SST data send to complete.

NETWORK_STATE_MST_WAIT 

Waiting for an MST data send to complete.

NETWORK_STATE_DIVERSION_WAIT 

Waiting for a diversion request to complete.

Member Function Documentation

Map27ApplicationLayer * Map27NetworkLayer::applicationLayer ( )

Get the current Application Layer

Returns
The curent Application Layer pointer, or NULL if previously set.
Map27DataLayer * Map27NetworkLayer::dataLayer ( )

Get the current DataLayer

Returns
The current Data Layer pointer, or NULL if previously set.
Examples:
test.cpp, and test2.cpp.
void Map27NetworkLayer::decode_network_layer_packet ( uint8_t *  buf,
uint16_t  bufLen 
)
protected

Called internally when a message is recieved by the Data LAyer and requires decoding and dispatching.

Parameters
[in]bufData in the message
[in]bufLenNumber of bytes in buf
bool Map27NetworkLayer::is_idle ( )

Whether the Network Layer state machine is idle

Returns
true if the current Network Layer state mahcine state is IDLE
Examples:
test.cpp.
void Map27NetworkLayer::link_failure ( )
virtual

Called by Data Layer when the data link stops being READY

void Map27NetworkLayer::link_ready ( )
virtual

Called by Data Layer when the data link becomes READY

Examples:
test2.cpp.
void Map27NetworkLayer::network_layer_packet ( uint8_t *  buf,
uint16_t  bufLen 
)
virtual

Called by Data Layer when a message is received from the radio

Parameters
[in]bufContents of the message
[in]bufLenNumber of bytes in buf
Examples:
test2.cpp.
void Map27NetworkLayer::output_application_error ( uint8_t  type)
protectedvirtual

Tells the Application Layer about an error condition that was detected by the Network Layer

Parameters
[in]typeThe type of error. One of MAP27_APPLICATION_ERROR_*
void Map27NetworkLayer::packet_accepted ( )
virtual

Called by Data Layer when a packet is accepted by the Data Layer for transmission

void Map27NetworkLayer::packet_rejected ( )
virtual

Called by Data Layer when a packet is rejected by the DataLayer for transmission

void Map27NetworkLayer::poll ( )

Polls Network Layer timer and lower layers of the protocol stack for activity. In Unix/Linux and Arduino environments, you are required to call this at least as frequently as octets might be received from the radio. At least every 10msec would be appropriate for a 9600 baud connection. Note: Map27ApplicationLayer does this automatically when its poll() function is called.

void Map27NetworkLayer::power_on ( )

Cause the entire protocol stack to power up and intialise to its startup state. Network state is IDLE.

void Map27NetworkLayer::receiveCleared ( uint8_t *  buf,
uint16_t  bufLen 
)
protectedvirtual

Decode a CLEARED (5.2.2.6.2) message and pass it to the appropriate ApplicationLAyer function

Parameters
[in]bufPointer to the raw message data
[in]bufLenNumber of bytes in buf
void Map27NetworkLayer::receiveIncomingVoiceModem ( uint8_t *  buf,
uint16_t  bufLen 
)
protectedvirtual

Decode a INCOMING VOICE CALL / INCOMING MODEM CALL (5.2.2.4.4) message and pass it to the appropriate ApplicationLAyer function

Parameters
[in]bufPointer to the raw message data
[in]bufLenNumber of bytes in buf
void Map27NetworkLayer::receiveModemData ( uint8_t *  buf,
uint16_t  bufLen 
)
protectedvirtual

Decode a RECEIVE PROGRESS (5.2.2.4.6) message and pass it to the appropriate ApplicationLAyer function

Parameters
[in]bufPointer to the raw message data
[in]bufLenNumber of bytes in buf
void Map27NetworkLayer::receiveMST ( uint8_t *  buf,
uint16_t  bufLen 
)
protectedvirtual

Decode a RECEIVE MST (5.2.2.3.2) message and pass it to the appropriate ApplicationLAyer function

Parameters
[in]bufPointer to the raw message data
[in]bufLenNumber of bytes in buf
void Map27NetworkLayer::receiveMSTAck ( uint8_t *  buf,
uint16_t  bufLen 
)
protectedvirtual

Decode a MST ACK (5.2.2.3.3) message and pass it to the appropriate ApplicationLAyer function

Parameters
[in]bufPointer to the raw message data
[in]bufLenNumber of bytes in buf
void Map27NetworkLayer::receiveNetworkInformation ( uint8_t *  buf,
uint16_t  bufLen 
)
protectedvirtual

Decode a NETWORK INFORMATION (5.2.2.8.6) message and pass it to the appropriate ApplicationLAyer function

Parameters
[in]bufPointer to the raw message data
[in]bufLenNumber of bytes in buf
void Map27NetworkLayer::receiveNumberingInfo ( uint8_t *  buf,
uint16_t  bufLen 
)
protectedvirtual

Decode a PROTOCOL INFO (5.2.2.8.9) message and pass it to the appropriate ApplicationLAyer function

Parameters
[in]bufPointer to the raw message data
[in]bufLenNumber of bytes in buf
void Map27NetworkLayer::receiveOperatingCondition ( uint8_t *  buf,
uint16_t  bufLen 
)
protectedvirtual

Decode a OPERATING CONDITION (5.2.2.8.5) message and pass it to the appropriate ApplicationLAyer function

Parameters
[in]bufPointer to the raw message data
[in]bufLenNumber of bytes in buf
void Map27NetworkLayer::receiveProgress ( uint8_t *  buf,
uint16_t  bufLen 
)
protectedvirtual

Decode a message and pass it to the appropriate ApplicationLAyer function

Parameters
[in]bufPointer to the raw message data
[in]bufLenNumber of bytes in buf
void Map27NetworkLayer::receiveProtocolInfo ( uint8_t *  buf,
uint16_t  bufLen 
)
protectedvirtual

Decode a message and pass it to the appropriate ApplicationLAyer function

Parameters
[in]bufPointer to the raw message data
[in]bufLenNumber of bytes in buf
void Map27NetworkLayer::receiveRadioPersonality ( uint8_t *  buf,
uint16_t  bufLen 
)
protectedvirtual

Decode a RADIO PERSONALITY (5.2.2.8.2) message and pass it to the appropriate ApplicationLAyer function

Parameters
[in]bufPointer to the raw message data
[in]bufLenNumber of bytes in buf
void Map27NetworkLayer::receiveRadioSettings ( uint8_t *  buf,
uint16_t  bufLen 
)
protectedvirtual

Decode a RADIO SETTINGS (5.2.2.8.8) message and pass it to the appropriate ApplicationLAyer function

Parameters
[in]bufPointer to the raw message data
[in]bufLenNumber of bytes in buf
void Map27NetworkLayer::receiveRadioTestResult ( uint8_t *  buf,
uint16_t  bufLen 
)
protectedvirtual

Decode a RADIO TEST RESULT (5.2.2.8.13) message and pass it to the appropriate ApplicationLAyer function

Parameters
[in]bufPointer to the raw message data
[in]bufLenNumber of bytes in buf
void Map27NetworkLayer::receiveSetupProgress ( uint8_t *  buf,
uint16_t  bufLen 
)
protectedvirtual

Decode a SETUP PROGRESS (5.2.2.4.3) message and pass it to the appropriate ApplicationLAyer function

Parameters
[in]bufPointer to the raw message data
[in]bufLenNumber of bytes in buf
void Map27NetworkLayer::receiveSST ( uint8_t *  buf,
uint16_t  bufLen 
)
protectedvirtual

Decode a RECEIVE SST (5.2.2.2.2) message and pass it to the appropriate ApplicationLAyer function

Parameters
[in]bufPointer to the raw message data
[in]bufLenNumber of bytes in buf
void Map27NetworkLayer::receiveSSTAck ( uint8_t *  buf,
uint16_t  bufLen 
)
protectedvirtual

Decode a SST ACK (5.2.2.2.3) message and pass it to the appropriate ApplicationLAyer function

Parameters
[in]bufPointer to the raw message data
[in]bufLenNumber of bytes in buf
void Map27NetworkLayer::receiveStatus ( uint8_t *  buf,
uint16_t  bufLen 
)
protectedvirtual

Decode a RECIEVE STATUS (5.2.2.1.2) message and pass it to the appropriate ApplicationLAyer function

Parameters
[in]bufPointer to the raw message data
[in]bufLenNumber of bytes in buf
Examples:
test.cpp.
void Map27NetworkLayer::receiveStatusAck ( uint8_t *  buf,
uint16_t  bufLen 
)
protectedvirtual

Decode a STATUS ACK (5.2.2.1.3) message and pass it to the appropriate ApplicationLAyer function

Parameters
[in]bufPointer to the raw message data
[in]bufLenNumber of bytes in buf
void Map27NetworkLayer::request_timeout ( )
protected

Called internally when a pending request times out. Cancels the reques and reurns the Network Layer to IDLE state

void Map27NetworkLayer::reset ( )

Resets the Network Layer to its power_on state

bool Map27NetworkLayer::sendCleared ( const Map27Address address,
uint8_t  cause 
)

Sends a CLEARED 5.2.2.6.2 message to a specified radio in the network.

Parameters
[in]addressCalled, calling or connected party address
[in]causeCancellation or disconnection reason. One of MAP27_NETWORK_MESSAGE_CLEARED_CAUSE_*
Returns
true if the message was queued for transmission by Data Layer
bool Map27NetworkLayer::sendDialledString ( uint8_t *  buf,
uint16_t  bufLen 
)

Sends a DIALLED STRING 5.2.2.8.11 message to the radio.

Parameters
[in]bufThe dialled string
[in]bufLenThe number of bytes in the dialled digits
Returns
true if the message was queued for transmission by Data Layer
bool Map27NetworkLayer::sendDisconnect ( const Map27Address address,
uint8_t  cause 
)

Sends a DISCONNECT 5.2.2.6.1 message to a specified radio in the network.

Parameters
[in]addressCalled or connected party address
[in]causeCancellation or disconnection reason. One of MAP27_NETWORK_MESSAGE_DISCONNECT_CAUSE_*
Returns
true if the message was queued for transmission by Data Layer
bool Map27NetworkLayer::sendDiversionCancel ( const Map27Address address,
uint8_t  info 
)

Sends a DIVERSION CANCEL 5.2.2.7.2 message to cancel a previous diversion.

Parameters
[in]addressAddress of the party whose calls are no longer diverted
[in]infoInformation of the diversion. One of MAP27_NETWORK_MESSAGE_DIVERSION_CANCEL_*
Returns
true if the message was queued for transmission by Data Layer
bool Map27NetworkLayer::sendDiversionRequest ( const Map27Address address,
uint8_t  info,
const Map27Address diversionAddress 
)

Sends a DIVERSION REQUEST 5.2.2.7.1 message to divert messages to another unit

Parameters
[in]addressAddress of he party to which calls are diverted
[in]infoInformationof the diversion. One of MAP27_NETWORK_MESSAGE_DIVERSION_REQUEST_INFO_*
[in]diversionAddressBloked party address in a third party diversion
Returns
true if the message was queued for transmission by Data Layer
bool Map27NetworkLayer::sendModemData ( uint8_t *  buf,
uint16_t  bufLen 
)

Sends a SEND MODEM DATA 5.2.2.5.1 message to a specified radio in the network.

Parameters
[in]bufData to send
[in]bufLenNumber of bytes in buf
Returns
true if the message was queued for transmission by Data Layer
bool Map27NetworkLayer::sendMST ( const Map27Address address,
uint8_t *  buf,
uint16_t  bufLen 
)

Sends a SEND MST 5.2.2.3.1 message to a specified radio in the network.

Parameters
[in]addressCalled party address
[in]bufData to send
[in]bufLenNumber of bytes in buf
Returns
true if the message was queued for transmission by Data Layer
bool Map27NetworkLayer::sendRadioInterrogation ( uint8_t  reason)

Sends a RADIO INTERROGATION message to the radio, requesting informaiton about its state or configuration. Radio will respond some time later with a reply message.

Parameters
[in]reasonPoint of interrogation. One of MAP27_NETWORK_MESSAGE_RADIO_INTERROGATION_*
Returns
true if the message was queued for transmission by Data Layer
Examples:
test3.cpp.
bool Map27NetworkLayer::sendRadioTest ( uint8_t *  buf,
uint16_t  bufLen 
)

Sends a RADIO TESET 5.2.2.8.12 message to the radio.

Parameters
[in]bufTest controls. Depends on radio type
[in]bufLenNumber of bytes in buf.
Returns
true if the message was queued for transmission by Data Layer
bool Map27NetworkLayer::sendSST ( const Map27Address address,
uint8_t *  buf,
uint16_t  bufLen 
)

Sends a SEND SST 5.2.2.2.1 message to a specified radio in the network.

Parameters
[in]addressCalled party address
[in]bufData to send
[in]bufLenNumber of bytes in buf
Returns
true if the message was queued for transmission by Data Layer
Examples:
test.cpp.
bool Map27NetworkLayer::sendStatus ( const Map27Address address,
uint8_t  status 
)

Senda SEND STATUS 5.2.2.1.1 message to a specified radio in the network.

Parameters
[in]addressCalled party address
[in]statusStatus number. One of MAP27_NETWORK_MESSAGE_STATUS_*
Returns
true if the message was queued for transmission by Data Layer
Examples:
test.cpp.
bool Map27NetworkLayer::sendVolumeControl ( uint8_t  control_port,
uint8_t  volume 
)

Sends a VOLUME CONTROL 5.2.2.8.10 message to the radio.

Parameters
[in]control_portAddress of the volume control port. One of MAP27_NETWORK_MESSAGE_VOLUME_CONTROL_POINT_*
[in]volumeVolume set. One of MAP27_NETWORK_MESSAGE_VOLUME_SET_* and others.
Returns
true if the message was queued for transmission by Data Layer
void Map27NetworkLayer::setApplicationLayer ( Map27ApplicationLayer applicationLayer)

Sets the pointer to the ApplicationLayer to use to deliver messages to the application

Parameters
[in]applicationLayerPointer to the Application Layer
Examples:
test.cpp, and test3.cpp.
void Map27NetworkLayer::setDataLayer ( Map27DataLayer dataLayer)

Sets the pointer to the DataLayer to use to communicate with the Radio

Parameters
[in]dataLayerPointer to the Data Layer
Examples:
test.cpp, and test3.cpp.
bool Map27NetworkLayer::setupEmergencyVoiceModem ( const Map27Address address,
uint8_t  details 
)

Sends a SETUP EMERGENCY VOICE / SETUP EMERGENCY MODEM 5.2.2.4.2 message to a specified radio in the network.

Parameters
[in]addressCalled party address
[in]detailsCall details One of MAP27_NETWORK_MESSAGE_SETUP_VOICE_MODEM_DETAILS_*.
Returns
true if the message was queued for transmission by Data Layer
bool Map27NetworkLayer::setupVoiceModem ( const Map27Address address,
uint8_t  details 
)

Sends a SETUP VOICE / SETUP MODEM 5.2.2.4.1 message to a specified radio in the network.

Parameters
[in]addressCalled party address
[in]detailsCall details One of MAP27_NETWORK_MESSAGE_SETUP_VOICE_MODEM_DETAILS_*.
Returns
true if the message was queued for transmission by Data Layer
Map27NetworkLayer::NetworkState Map27NetworkLayer::state ( )

The current state of the Network Layer state machine

Returns
The current state

The documentation for this class was generated from the following files: