Map27
 All Classes Functions Variables Enumerations Enumerator Pages
NetworkLayer.h
1 // NetworkLayer.h
2 //
3 // Author: Mike McCauley (mikem@airspayce.com)
4 // Copyright (C) 2013 Mike McCauley
5 // $Id: NetworkLayer.h,v 1.6 2013/07/14 06:32:28 mikem Exp $
6 
7 
8 #ifndef MAP27_NETWORKLAYER_H
9 #define MAP27_NETWORKLAYER_H
10 
11 #include <stdint.h>
12 
13 #include "Timer.h"
14 
15 // Timeout for pending Netwrok Layer requests in msec
16 #define MAP27_NETWORK_REQUEST_TIMEOUT 10000
17 
18 // Largest network layer message
19 #define MAP27_NETWORK_MESSAGE_MAX_MESSAGE_LEN 43
20 
21 // From Table 5-1
22 // Note that bother send and receive message numbers are here, and in some cases the same number
23 // appears twide, one for D->R and one for R->D
24 #define MAP27_NETWORK_MESSAGE_TYPE_SEND_STATUS 0x80
25 #define MAP27_NETWORK_MESSAGE_TYPE_RECEIVE_STATUS 0x80
26 #define MAP27_NETWORK_MESSAGE_TYPE_ACK_POSITIVE 0xc0
27 #define MAP27_NETWORK_MESSAGE_TYPE_ACK_QUEUEING 0xd0
28 #define MAP27_NETWORK_MESSAGE_TYPE_ACK_NEGATIVE 0xe0
29 #define MAP27_NETWORK_MESSAGE_TYPE_SEND_SST 0x81
30 #define MAP27_NETWORK_MESSAGE_TYPE_RECEIVE_SST 0x81
31 #define MAP27_NETWORK_MESSAGE_TYPE_SEND_MST 0x82
32 #define MAP27_NETWORK_MESSAGE_TYPE_RECEIVE_MST 0x82
33 #define MAP27_NETWORK_MESSAGE_TYPE_SETUP_VOICE_MODEM 0xa4
34 #define MAP27_NETWORK_MESSAGE_TYPE_SETUP_EMERGENCY_VOICE_MODEM 0xa5
35 #define MAP27_NETWORK_MESSAGE_TYPE_SETUP_PROGRESS_POSITIVE 0xc4
36 #define MAP27_NETWORK_MESSAGE_TYPE_SETUP_PROGRESS_QUEUEING 0xd4
37 #define MAP27_NETWORK_MESSAGE_TYPE_SETUP_PROGRESS_NEGATIVE 0xe4
38 #define MAP27_NETWORK_MESSAGE_TYPE_INCOMING_VOICE_MODEM 0xa4
39 #define MAP27_NETWORK_MESSAGE_TYPE_INCOMING_EMERGENCY_VOICE_MODEM 0xa5
40 #define MAP27_NETWORK_MESSAGE_TYPE_RECEIVE_PROGRESS_POSITIVE 0xc5
41 #define MAP27_NETWORK_MESSAGE_TYPE_RECEIVE_PROGRESS_WARNING 0xd5
42 #define MAP27_NETWORK_MESSAGE_TYPE_RECEIVE_PROGRESS_NEGATIVE 0xe5
43 #define MAP27_NETWORK_MESSAGE_TYPE_SEND_MODEM_DATA 0xa3
44 #define MAP27_NETWORK_MESSAGE_TYPE_RECEIVE_MODEM_DATA 0xa3
45 #define MAP27_NETWORK_MESSAGE_TYPE_DISCONNECT_NORMAL 0x86
46 #define MAP27_NETWORK_MESSAGE_TYPE_DISCONNECT_CANCEL 0xa6
47 #define MAP27_NETWORK_MESSAGE_TYPE_CLEARED_NORMAL 0x86
48 #define MAP27_NETWORK_MESSAGE_TYPE_CLEARED_ABNORMAL 0xa6
49 #define MAP27_NETWORK_MESSAGE_TYPE_DIVERSION_REQUEST 0x87
50 #define MAP27_NETWORK_MESSAGE_TYPE_DIVERSION_CANCEL 0xa7
51 #define MAP27_NETWORK_MESSAGE_TYPE_DIVERSION_ACK_POSITIVE 0xc7
52 #define MAP27_NETWORK_MESSAGE_TYPE_DIVERSION_ACK_NEGATIVE 0xe7
53 #define MAP27_NETWORK_MESSAGE_TYPE_RADIO_INTERROGATION 0xb0
54 #define MAP27_NETWORK_MESSAGE_TYPE_RADIO_PERSONALITY 0xb0
55 #define MAP27_NETWORK_MESSAGE_TYPE_NUMBERING_INFORMATION 0xb1
56 #define MAP27_NETWORK_MESSAGE_TYPE_RADIO_CONTROL 0xb2
57 #define MAP27_NETWORK_MESSAGE_TYPE_OPERATING_CONDITION 0xb2
58 #define MAP27_NETWORK_MESSAGE_TYPE_NETWORK_INFORMATION 0xb5
59 #define MAP27_NETWORK_MESSAGE_TYPE_RADIO_MANAGEMENT 0xb3
60 #define MAP27_NETWORK_MESSAGE_TYPE_RADIO_SETTINGS 0xb3
61 #define MAP27_NETWORK_MESSAGE_TYPE_PROTOCOL_INFO 0xb4
62 #define MAP27_NETWORK_MESSAGE_TYPE_VOLUME_CONTROL 0xb6
63 #define MAP27_NETWORK_MESSAGE_TYPE_DIALLED_STRING 0xb7
64 #define MAP27_NETWORK_MESSAGE_TYPE_RADIO_TEST 0x01
65 #define MAP27_NETWORK_MESSAGE_TYPE_RADIO_TEST_RESULT 0x01
66 #define MAP27_NETWORK_MESSAGE_TYPE_RESERVED 0x00
67 
68 // Status 5.2.2.1.1, 5.2.2.1.2
69 // Values 0..31 are permitted
70 // Need to see MPT1327 for these, section 13
71 #define MAP27_NETWORK_MESSAGE_STATUS_OFF_HOOK 0x00
72 // The user defined messages 00001 to 11110 are not given here
73 #define MAP27_NETWORK_MESSAGE_STATUS_ON_HOOK 0x1f
74 
75 // Status Ack cause 5.2.2.1.3
76 // For type 0xc0
77 #define MAP27_NETWORK_MESSAGE_STATUS_CAUSE_SUCCESS 0x00
78 // For type 0xd0
79 #define MAP27_NETWORK_MESSAGE_STATUS_CAUSE_BUSY_WAIT 0x02
80 #define MAP27_NETWORK_MESSAGE_STATUS_CAUSE_ENGAGED_WAIT 0x0a
81 #define MAP27_NETWORK_MESSAGE_STATUS_CAUSE_DIVERTING_WAIT 0x26
82 // For type 0xe0
83 #define MAP27_NETWORK_MESSAGE_STATUS_CAUSE_ABORTED 0x08
84 #define MAP27_NETWORK_MESSAGE_STATUS_CAUSE_INVALID 0x03
85 #define MAP27_NETWORK_MESSAGE_STATUS_CAUSE_OVERLOAD 0x0b
86 #define MAP27_NETWORK_MESSAGE_STATUS_CAUSE_ABANDONED 0x04
87 #define MAP27_NETWORK_MESSAGE_STATUS_CAUSE_ENGAGED 0x0c
88 #define MAP27_NETWORK_MESSAGE_STATUS_CAUSE_DIVERTED 0x06
89 #define MAP27_NETWORK_MESSAGE_STATUS_CAUSE_DIVERTED_GROUP 0x16
90 #define MAP27_NETWORK_MESSAGE_STATUS_CAUSE_DIVERTED_NOT_AVAILABLE 0x07
91 
92 // For Send SST 5.2.2.2.1
93 #define MAP27_NETWORK_MESSAGE_SEND_SST_CODING_MASK 0xf0
94 #define MAP27_NETWORK_MESSAGE_SEND_SST_CODING_FREE_FORMAT 0x00
95 #define MAP27_NETWORK_MESSAGE_SEND_SST_CODING_BCD_RADIO_PATH 0x10
96 #define MAP27_NETWORK_MESSAGE_SEND_SST_CODING_CCITT_RADIO_PATH 0x20
97 #define MAP27_NETWORK_MESSAGE_SEND_SST_CODING_BINARY 0x80
98 #define MAP27_NETWORK_MESSAGE_SEND_SST_CODING_BCD 0x90
99 #define MAP27_NETWORK_MESSAGE_SEND_SST_CODING_CCITT2 0xa0
100 #define MAP27_NETWORK_MESSAGE_SEND_SST_CODING_ASCII 0xb0
101 #define MAP27_NETWORK_MESSAGE_SEND_SST_CODING_OCTETS 0xf0
102 
103 // For SST ACK 5.2.2.2.3 and MST ACK 5.2.2.3.3
104 // For type 0xc0
105 #define MAP27_NETWORK_MESSAGE_SST_ACK_SUCCESS 0x00
106 // For type 0xd0
107 #define MAP27_NETWORK_MESSAGE_SST_ACK_BUSY_WAIT 0x02
108 #define MAP27_NETWORK_MESSAGE_SST_ACK_ENGAGED_WAIT 0x0a
109 #define MAP27_NETWORK_MESSAGE_SST_ACK_DIVERTED_WAIT 0x26
110 #define MAP27_NETWORK_MESSAGE_MST_ACK_MST_NOT_SUPPORTED_SST 0x22
111 #define MAP27_NETWORK_MESSAGE_SST_ACK_ABORTED 0x08
113 #define MAP27_NETWORK_MESSAGE_SST_ACK_INVALID 0x03
114 #define MAP27_NETWORK_MESSAGE_SST_ACK_OVERLOAD 0x0b
115 #define MAP27_NETWORK_MESSAGE_SST_ACK_ABANDONED 0x04
116 #define MAP27_NETWORK_MESSAGE_SST_ACK_ENGAGED 0x0c
117 #define MAP27_NETWORK_MESSAGE_SST_ACK_DIVERTED 0x06
118 #define MAP27_NETWORK_MESSAGE_SST_ACK_DIVERTED_GROUP 0x16
119 #define MAP27_NETWORK_MESSAGE_SST_ACK_DIVERTED_NOT_AVAILABLE 0x07
120 #define MAP27_NETWORK_MESSAGE_MST_ACK_MST_NOT_SUPPORTED_ABORTED 0x0d
121 
122 // For Setup Voice/Modem 5.2.2.4.1
123 // Also for Setup Emergency Voice/Modem 5.2.2.4.2
124 #define MAP27_NETWORK_MESSAGE_SETUP_VOICE_MODEM_DETAILS_INCLUDE 0x40
125 #define MAP27_NETWORK_MESSAGE_SETUP_VOICE_MODEM_DETAILS_GROUP 0x20
126 #define MAP27_NETWORK_MESSAGE_SETUP_VOICE_MODEM_DETAILS_MODEM 0x10
127 #define MAP27_NETWORK_MESSAGE_SETUP_VOICE_MODEM_DETAILS_PRIORITY 0x08
128 #define MAP27_NETWORK_MESSAGE_SETUP_VOICE_MODEM_DETAILS_SPECIAL 0x01
129 
130 // For Setup Progress 5.2.2.4.3
131 // For type 0xc4
132 #define MAP27_NETWORK_MESSAGE_SETUP_PROGRESS_CAUSE_CALL_CONNECTED 0x00
133 #define MAP27_NETWORK_MESSAGE_SETUP_PROGRESS_CAUSE_INCLUDE_CALL_CONNECTED 0x00
134 // For type 0xd4
135 #define MAP27_NETWORK_MESSAGE_SETUP_PROGRESS_CAUSE_ALERTING 0x01
136 #define MAP27_NETWORK_MESSAGE_SETUP_PROGRESS_CAUSE_BUSY 0x02
137 #define MAP27_NETWORK_MESSAGE_SETUP_PROGRESS_CAUSE_ENGAGED_WAIT 0x0a
138 #define MAP27_NETWORK_MESSAGE_SETUP_PROGRESS_CAUSE_EMERGENCY_PROCEEDING 0x05
139 #define MAP27_NETWORK_MESSAGE_SETUP_PROGRESS_CAUSE_DIVERTED_WAIT 0x26
140 #define MAP27_NETWORK_MESSAGE_SETUP_PROGRESS_CAUSE_DIVERTED_GROUP_WAIT 0x36
141 // For type 0xe4
142 #define MAP27_NETWORK_MESSAGE_SETUP_PROGRESS_CAUSE_ABORTED 0x08
143 #define MAP27_NETWORK_MESSAGE_SETUP_PROGRESS_CAUSE_INVALID 0x03
144 #define MAP27_NETWORK_MESSAGE_SETUP_PROGRESS_CAUSE_OVERLOAD 0x0b
145 #define MAP27_NETWORK_MESSAGE_SETUP_PROGRESS_CAUSE_ABANDONED 0x04
146 #define MAP27_NETWORK_MESSAGE_SETUP_PROGRESS_CAUSE_ENGAGED 0x0c
147 #define MAP27_NETWORK_MESSAGE_SETUP_PROGRESS_CAUSE_DIVERTED 0x06
148 #define MAP27_NETWORK_MESSAGE_SETUP_PROGRESS_CAUSE_DIVERTED_GROUP 0x16
149 #define MAP27_NETWORK_MESSAGE_SETUP_PROGRESS_CAUSE_DIVERTED_NOT_AVAILABLE 0x0e
150 #define MAP27_NETWORK_MESSAGE_SETUP_PROGRESS_CAUSE_CALLBACK_ACCEPTED 0x07
151 
152 // For Incoming Voice/Modem 5.2.2.4.4
153 // and Incoming Emergency Voice/Modem 5.2.2.4.5
154 #define MAP27_NETWORK_MESSAGE_INCOMING_VOICE_MODEM_DETAILS_INCLUDE 0x40
155 #define MAP27_NETWORK_MESSAGE_INCOMING_VOICE_MODEM_DETAILS_GROUP 0x20
156 #define MAP27_NETWORK_MESSAGE_INCOMING_VOICE_MODEM_DETAILS_DATA 0x10
157 #define MAP27_NETWORK_MESSAGE_INCOMING_VOICE_MODEM_DETAILS_HOOK_REQUIRED 0x08
158 #define MAP27_NETWORK_MESSAGE_INCOMING_VOICE_MODEM_DETAILS_CUSTOM_SERVICE_1 0x05
159 #define MAP27_NETWORK_MESSAGE_INCOMING_VOICE_MODEM_DETAILS_CUSTOM_SERVICE_2 0x06
160 #define MAP27_NETWORK_MESSAGE_INCOMING_VOICE_MODEM_DETAILS_CUSTOM_SERVICE_3 0x07
161 
162 // For Receive Progress 5.2.2.4.6
163 // For type 0xc5
164 #define MAP27_NETWORK_MESSAGE_RECEIVE_PRGRESS_CAUSE_CONNECTED 0x00
165 // For type 0xd5
166 #define MAP27_NETWORK_MESSAGE_RECEIVE_PRGRESS_CAUSE_TRANSMISSION_DISABLED 0x01
167 #define MAP27_NETWORK_MESSAGE_RECEIVE_PRGRESS_CAUSE_BUSY_WAIT 0x02
168 #define MAP27_NETWORK_MESSAGE_RECEIVE_PRGRESS_CAUSE_CLEAR_DOWN_TIMER 0x0a
169 // For type 0xe5
170 #define MAP27_NETWORK_MESSAGE_RECEIVE_PRGRESS_CAUSE_REJECTED 0x03
171 #define MAP27_NETWORK_MESSAGE_RECEIVE_PRGRESS_CAUSE_CALLBACK 0x07
172 
173 // For Disconnect 5.2.2.6.1
174 // For type 0x86
175 #define MAP27_NETWORK_MESSAGE_DISCONNECT_CAUSE_NORMAL 0x07
176 // For type 0xa6
177 #define MAP27_NETWORK_MESSAGE_DISCONNECT_CAUSE_CANCEL_TRANS 0x08
178 #define MAP27_NETWORK_MESSAGE_DISCONNECT_CAUSE_CANCEL_INCLUDE 0x09
179 #define MAP27_NETWORK_MESSAGE_DISCONNECT_CAUSE_ABORT_DIVERSION 0x0a
180 #define MAP27_NETWORK_MESSAGE_DISCONNECT_CAUSE_CANCEL_DATA_SETUP 0x0c
181 
182 // For Cleared 5.2.2.6.2
183 // For type 0x86
184 #define MAP27_NETWORK_MESSAGE_CLEARED_CAUSE_NORMAL 0x0b
185 // For type 0xa6
186 #define MAP27_NETWORK_MESSAGE_CLEARED_CAUSE_UNSPECIFIED 0x00
187 #define MAP27_NETWORK_MESSAGE_CLEARED_CAUSE_RADIO_GENERATED 0x01
188 #define MAP27_NETWORK_MESSAGE_CLEARED_CAUSE_NOT_AVAILABLE 0x04
189 #define MAP27_NETWORK_MESSAGE_CLEARED_CAUSE_TOO_LONG 0x05
190 #define MAP27_NETWORK_MESSAGE_CLEARED_CAUSE_CODING_NOT_POSSIBLE 0x06
191 #define MAP27_NETWORK_MESSAGE_CLEARED_CAUSE_ABNORMAL 0x0e
192 
193 // For Diversion Request Info 5.2.2.7.1
194 #define MAP27_NETWORK_MESSAGE_DIVERSION_REQUEST_INFO_SPEECH_DATA 0x00
195 #define MAP27_NETWORK_MESSAGE_DIVERSION_REQUEST_INFO_SPEECH 0x08
196 #define MAP27_NETWORK_MESSAGE_DIVERSION_REQUEST_INFO_DATA 0x10
197 #define MAP27_NETWORK_MESSAGE_DIVERSION_REQUEST_INFO_THIRD_PARTY 0x01
198 
199 // For Diversion Cancel Info 5.2.2.7.2
200 #define MAP27_NETWORK_MESSAGE_DIVERSION_CANCEL_INFO_SPEECH_DATA 0x00
201 #define MAP27_NETWORK_MESSAGE_DIVERSION_CANCEL_INFO_SPEECH 0x08
202 #define MAP27_NETWORK_MESSAGE_DIVERSION_CANCEL_INFO_DATA 0x10
203 #define MAP27_NETWORK_MESSAGE_DIVERSION_CANCEL_INFO_SELF 0x00
204 #define MAP27_NETWORK_MESSAGE_DIVERSION_CANCEL_INFO_THIRD_PARTY 0x01
205 #define MAP27_NETWORK_MESSAGE_DIVERSION_CANCEL_INFO_RECIPIENT 0x02
206 
207 // For Radio Interrogation 5.2.2.8.1
208 #define MAP27_NETWORK_MESSAGE_RADIO_INTERROGATION_PERSONALITY 0x00
209 #define MAP27_NETWORK_MESSAGE_RADIO_INTERROGATION_NUMBERING 0x01
210 #define MAP27_NETWORK_MESSAGE_RADIO_INTERROGATION_STATUS 0x02
211 #define MAP27_NETWORK_MESSAGE_RADIO_INTERROGATION_OPERATING_CONDITION 0x03
212 #define MAP27_NETWORK_MESSAGE_RADIO_INTERROGATION_NETWORK_INFORMATION 0x04
213 // SPARE and Reserved not defined here
214 
215 // For RADIO PERSONALITY 5.2.2.8.2
216 #define MAP27_NETWORK_MESSAGE_RADIO_PERSONALITY_FACILITIESA_VOICE 0x80
217 #define MAP27_NETWORK_MESSAGE_RADIO_PERSONALITY_FACILITIESA_MODEM 0x40
218 #define MAP27_NETWORK_MESSAGE_RADIO_PERSONALITY_FACILITIESA_STATUS 0x20
219 #define MAP27_NETWORK_MESSAGE_RADIO_PERSONALITY_FACILITIESA_SST 0x10
220 #define MAP27_NETWORK_MESSAGE_RADIO_PERSONALITY_FACILITIESA_MST 0x08
221 #define MAP27_NETWORK_MESSAGE_RADIO_PERSONALITY_FACILITIESA_DIVERSION 0x04
222 #define MAP27_NETWORK_MESSAGE_RADIO_PERSONALITY_FACILITIESA_LOGGING 0x02
223 #define MAP27_NETWORK_MESSAGE_RADIO_PERSONALITY_FACILITIESA_SHORT_DATA 0x01
224 
225 #define MAP27_NETWORK_MESSAGE_RADIO_PERSONALITY_CODINGS_BCD_RADIO_PATH 0x80
226 #define MAP27_NETWORK_MESSAGE_RADIO_PERSONALITY_CODINGS_CCITT_RADIO_PATH 0x40
227 #define MAP27_NETWORK_MESSAGE_RADIO_PERSONALITY_CODINGS_BINARY 0x20
228 #define MAP27_NETWORK_MESSAGE_RADIO_PERSONALITY_CODINGS_BCD 0x10
229 #define MAP27_NETWORK_MESSAGE_RADIO_PERSONALITY_CODINGS_CCITT2 0x08
230 #define MAP27_NETWORK_MESSAGE_RADIO_PERSONALITY_CODINGS_ASCII 0x04
231 #define MAP27_NETWORK_MESSAGE_RADIO_PERSONALITY_CODINGS_OCTETS 0x02
232 
233 // For Protocol Info 5.2.2.8.9
234 #define MAP27_NETWORK_MESSAGE_PROTOCOL_INFO_UNRECOGNISED 0x01
235 #define MAP27_NETWORK_MESSAGE_PROTOCOL_INFO_NOT_SUPPORTED 0x02
236 #define MAP27_NETWORK_MESSAGE_PROTOCOL_INFO_STATE_MISMATCH 0x03
237 #define MAP27_NETWORK_MESSAGE_PROTOCOL_INFO_CODING_NOT_SUPPORTED 0x04
238 #define MAP27_NETWORK_MESSAGE_PROTOCOL_INFO_BUSY 0x05
239 #define MAP27_NETWORK_MESSAGE_PROTOCOL_INFO_READY 0x06
240 // SPARE and RESERVED not given here
241 
242 // For Radio Management 5.2.2.8.7 and Radio Settings 5.2.2.8.8
243 // Masks for controls_a
244 #define MAP27_NETWORK_MESSAGE_RADIO_MANAGEMENT_CONTROLS_VOICE 0x80
245 #define MAP27_NETWORK_MESSAGE_RADIO_MANAGEMENT_CONTROLS_MODEM 0x40
246 #define MAP27_NETWORK_MESSAGE_RADIO_MANAGEMENT_CONTROLS_STATUS 0x20
247 #define MAP27_NETWORK_MESSAGE_RADIO_MANAGEMENT_CONTROLS_SST 0x10
248 #define MAP27_NETWORK_MESSAGE_RADIO_MANAGEMENT_CONTROLS_MST 0x08
249 #define MAP27_NETWORK_MESSAGE_RADIO_MANAGEMENT_CONTROLS_DIVERSION 0x04
250 #define MAP27_NETWORK_MESSAGE_RADIO_MANAGEMENT_CONTROLS_LOGGING 0x02
251 
252 // For Operating Condition 5.2.2.8.5
253 #define MAP27_NETWORK_MESSAGE_OPERATING_CONDITION_CONDITION_IN_CONTACT 0x04
254 #define MAP27_NETWORK_MESSAGE_OPERATING_CONDITION_CONDITION_OFF_HOOK 0x02
255 #define MAP27_NETWORK_MESSAGE_OPERATING_CONDITION_CONDITION_TRANSMITTING 0x01
256 #define MAP27_NETWORK_MESSAGE_OPERATING_CONDITION_FIELD_STRENGTH_DUMMY 0x00
257 #define MAP27_NETWORK_MESSAGE_OPERATING_CONDITION_CALL_DURATION_RESERVED 0x00
258 #define MAP27_NETWORK_MESSAGE_OPERATING_CONDITION_CALL_DURATION_INFINITE 0xff
259 
260 // For Volume Control 5.2.2.8.10
261 #define MAP27_NETWORK_MESSAGE_VOLUME_CONTROL_POINT_MODEM 0x04
262 #define MAP27_NETWORK_MESSAGE_VOLUME_CONTROL_POINT_ALERTS 0x02
263 #define MAP27_NETWORK_MESSAGE_VOLUME_CONTROL_POINT_SPEECH 0x01
264 #define MAP27_NETWORK_MESSAGE_VOLUME_SET_UP 0x01
265 #define MAP27_NETWORK_MESSAGE_VOLUME_SET_DOWN 0x02
266 #define MAP27_NETWORK_MESSAGE_VOLUME_SET_VALUE 0x03
267 #define MAP27_NETWORK_MESSAGE_VOLUME_SET_PRESET 0x04
268 #define MAP27_NETWORK_MESSAGE_VOLUME_SET_MANUAL 0x05
269 
270 class Map27Address;
271 class Map27DataLayer;
273 
282 {
283 public:
284 
287  typedef enum
288  {
298  } NetworkState;
299 
302 
307 
311 
316 
320 
324 
327  bool is_idle();
328 
331  void power_on();
332 
335  void reset();
336 
343  void poll();
344 
348 
351  virtual void link_ready();
352 
355  virtual void link_failure();
356 
359  virtual void packet_accepted();
360 
363  virtual void packet_rejected();
364 
369  virtual void network_layer_packet(uint8_t* buf, uint16_t bufLen);
370 
373 
379  bool sendStatus(const Map27Address& address, uint8_t status);
380 
387  bool sendSST(const Map27Address& address, uint8_t* buf, uint16_t bufLen);
388 
395  bool sendMST(const Map27Address& address, uint8_t* buf, uint16_t bufLen);
396 
402  bool setupVoiceModem(const Map27Address& address, uint8_t details);
403 
409  bool setupEmergencyVoiceModem(const Map27Address& address, uint8_t details);
410 
416  bool sendModemData(uint8_t* buf, uint16_t bufLen);
417 
423  bool sendDisconnect(const Map27Address& address, uint8_t cause);
424 
430  bool sendCleared(const Map27Address& address, uint8_t cause);
431 
438  bool sendDiversionRequest(const Map27Address& address, uint8_t info, const Map27Address& diversionAddress);
439 
445  bool sendDiversionCancel(const Map27Address& address, uint8_t info);
446 
452  bool sendRadioInterrogation(uint8_t reason);
453 
459  bool sendVolumeControl(uint8_t control_port, uint8_t volume);
460 
466  bool sendDialledString(uint8_t* buf, uint16_t bufLen);
467 
473  bool sendRadioTest(uint8_t* buf, uint16_t bufLen);
474 
475 protected:
480  void decode_network_layer_packet(uint8_t* buf, uint16_t bufLen);
481 
484  void request_timeout();
485 
492 
497  virtual void receiveStatus(uint8_t* buf, uint16_t bufLen);
498 
503  virtual void receiveStatusAck(uint8_t* buf, uint16_t bufLen);
504 
509  virtual void receiveSST(uint8_t* buf, uint16_t bufLen);
510 
515  virtual void receiveSSTAck(uint8_t* buf, uint16_t bufLen);
516 
521  virtual void receiveMST(uint8_t* buf, uint16_t bufLen);
522 
527  virtual void receiveMSTAck(uint8_t* buf, uint16_t bufLen);
528 
533  virtual void receiveSetupProgress(uint8_t* buf, uint16_t bufLen);
534 
539  virtual void receiveIncomingVoiceModem(uint8_t* buf, uint16_t bufLen);
540 
545  virtual void receiveProgress(uint8_t* buf, uint16_t bufLen);
546 
551  virtual void receiveModemData(uint8_t* buf, uint16_t bufLen);
552 
557  virtual void receiveCleared(uint8_t* buf, uint16_t bufLen);
558 
563  virtual void receiveRadioPersonality(uint8_t* buf, uint16_t bufLen);
564 
569  virtual void receiveProtocolInfo(uint8_t* buf, uint16_t bufLen);
570 
575  virtual void receiveNumberingInfo(uint8_t* buf, uint16_t bufLen);
576 
581  virtual void receiveRadioSettings(uint8_t* buf, uint16_t bufLen);
582 
587  virtual void receiveOperatingCondition(uint8_t* buf, uint16_t bufLen);
588 
593  virtual void receiveNetworkInformation(uint8_t* buf, uint16_t bufLen);
594 
599  virtual void receiveRadioTestResult(uint8_t* buf, uint16_t bufLen);
600 
604 
608  virtual void output_application_error(uint8_t type);
609 
610  // Callback glue
611  static void request_timer_callback_glue(void* target);
612 
613 private:
614  // Definitions of various on-the-wire message formats
615  // All these network layer message structs must be packed to 1 byte
616 #pragma pack(1)
617  typedef struct
618  {
619  uint8_t type;
620  uint8_t data[0];
621  } GenericHeader;
622 
623  typedef struct
624  {
625  uint8_t type;
626  uint8_t pfix;
627  uint8_t ident_a;
628  uint8_t ident_b;
629  uint8_t data[0];
630  } IdentHeader;
631  typedef struct
632  {
633  uint8_t type;
634  uint8_t pfix;
635  uint8_t ident_a;
636  uint8_t ident_b;
637  uint8_t adesc;
638  uint8_t address[0]; // length indicated by previous octet
639  } AddressHeader;
640 
641  // 5.2.2.1.1, 5.2.2.1.2
642  typedef struct
643  {
644  AddressHeader header;
645  uint8_t status;
646  } MsgStatus;
647 
648  // 5.2.2.1.3
649  typedef struct
650  {
651  AddressHeader header;
652  uint8_t cause;
653  } MsgStatusAck;
654 
655  // 5.2.2.6.2
656  typedef struct
657  {
658  IdentHeader header;
659  uint8_t cause;
660  } MsgCleared;
661 
662  // 5.2.2.8.9
663  typedef struct
664  {
665  uint8_t type;
666  uint8_t reason;
667  } MsgProtocolInfo;
668 
669  // 5.2.2.8.1
670  typedef struct
671  {
672  uint8_t type;
673  uint8_t reason;
674  } MsgRadioInterrogation;
675 
676  // 5.2.2.8.2
677  typedef struct
678  {
679  uint8_t type;
680  uint8_t pfix;
681  uint8_t ident_a;
682  uint8_t ident_b;
683  uint8_t manufacturers_code;
684  uint8_t serial_a;
685  uint8_t serial_b;
686  uint8_t serial_c;
687  uint8_t facilities_a;
688  uint8_t facilities_b;
689  uint8_t facilities_c;
690  uint8_t codings;
691  } RadioPersonality;
692 
693  // 5.2.2.8.3
694  typedef struct
695  {
696  uint8_t pfix;
697  uint8_t ident_a;
698  uint8_t ident_b;
699  } GroupAddress;
700  typedef struct
701  {
702  uint8_t type;
703  uint8_t pfix;
704  uint8_t ident_a;
705  uint8_t ident_b;
706  uint8_t individual_base_a;
707  uint8_t individual_base_b;
708  uint8_t highest_ident_a;
709  uint8_t highest_ident_b;
710  uint8_t group_base_a;
711  uint8_t group_base_b;
712  uint8_t highest_group_a;
713  uint8_t highest_group_b;
714  // Followed by 0 or more GroupAddress
715  GroupAddress group[0];
716  } MsgNumberingInfo;
717 
718  // 5.2.2.8.7
719  typedef struct
720  {
721  uint8_t type;
722  uint8_t controls_a;
723  uint8_t controls_b;
724  uint8_t controls_c;
725  uint8_t codings;
726  } MsgRadioSettings;
727 
728  // 5.2.2.8.5
729  typedef struct
730  {
731  uint8_t type;
732  uint8_t conditions;
733  uint8_t field_strength;
734  uint8_t max_call_duration;
735  } MsgOperatingCondition;
736 
737  // 5.2.2.8.7
738  typedef struct
739  {
740  uint8_t type;
741  uint8_t channel_a;
742  uint8_t channel_b;
743  uint8_t sys_ident_a;
744  uint8_t sys_ident_b;
745  } MsgNetworkInformation;
746 
747 #pragma pack()
748 
749 
750  Map27DataLayer* _dataLayer;
751  Map27ApplicationLayer* _applicationLayer;
752  NetworkState _network_state;
753  Map27Timer _request_timer;
754 };
755 
756 #endif
virtual void receiveRadioTestResult(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:908
virtual void packet_accepted()
Definition: NetworkLayer.cpp:95
virtual void receiveIncomingVoiceModem(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:730
Waiting for an outgoing voice/data call to be set up.
Definition: NetworkLayer.h:290
bool is_idle()
Definition: NetworkLayer.cpp:56
bool sendRadioInterrogation(uint8_t reason)
Definition: NetworkLayer.cpp:259
Map27ApplicationLayer * applicationLayer()
Definition: NetworkLayer.cpp:46
bool sendDiversionRequest(const Map27Address &address, uint8_t info, const Map27Address &diversionAddress)
Definition: NetworkLayer.cpp:461
virtual void receiveRadioPersonality(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:785
bool setupVoiceModem(const Map27Address &address, uint8_t details)
Definition: NetworkLayer.cpp:336
virtual void receiveProtocolInfo(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:805
Superclass for a generic Map27 application.
Definition: ApplicationLayer.h:29
virtual void receiveMSTAck(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:686
bool sendVolumeControl(uint8_t control_port, uint8_t volume)
Definition: NetworkLayer.cpp:520
virtual void receiveProgress(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:749
virtual void receiveOperatingCondition(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:876
void poll()
Definition: NetworkLayer.cpp:73
Waiting for an MST data send to complete.
Definition: NetworkLayer.h:296
Manage the Data Layer of the Map27 protocol stack.
Definition: DataLayer.h:26
bool sendDialledString(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:533
Waiting for status send to complete.
Definition: NetworkLayer.h:294
virtual void receiveSSTAck(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:649
virtual void receiveStatusAck(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:593
Waiting for an additional outgoing voice/data call to be set up.
Definition: NetworkLayer.h:291
virtual void link_ready()
Definition: NetworkLayer.cpp:80
Manage the Network Layer of the Map27 protocol stack.
Definition: NetworkLayer.h:281
bool sendCleared(const Map27Address &address, uint8_t cause)
Definition: NetworkLayer.cpp:441
Waiting for an SST data send to complete.
Definition: NetworkLayer.h:295
Class for handling Map27 Prefix/Ident/Address.
Definition: Address.h:57
virtual void receiveSetupProgress(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:705
virtual void output_application_error(uint8_t type)
Definition: NetworkLayer.cpp:919
bool setupEmergencyVoiceModem(const Map27Address &address, uint8_t details)
Definition: NetworkLayer.cpp:368
Idle, ready to start a new transaction.
Definition: NetworkLayer.h:289
bool sendModemData(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:400
Waiting for a diversion request to complete.
Definition: NetworkLayer.h:297
virtual void receiveStatus(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:573
virtual void receiveSST(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:631
virtual void link_failure()
Definition: NetworkLayer.cpp:87
void power_on()
Definition: NetworkLayer.cpp:61
virtual void receiveMST(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:668
virtual void receiveModemData(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:774
Waiting for an incoming voice/data call to be set up.
Definition: NetworkLayer.h:293
NetworkState state()
Definition: NetworkLayer.cpp:51
Voice/data call is active.
Definition: NetworkLayer.h:292
virtual void receiveNumberingInfo(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:824
virtual void receiveRadioSettings(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:858
void setDataLayer(Map27DataLayer *dataLayer)
Definition: NetworkLayer.cpp:31
Map27DataLayer * dataLayer()
Definition: NetworkLayer.cpp:36
virtual void packet_rejected()
Definition: NetworkLayer.cpp:102
void reset()
Definition: NetworkLayer.cpp:67
virtual void network_layer_packet(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:109
bool sendDiversionCancel(const Map27Address &address, uint8_t info)
Definition: NetworkLayer.cpp:491
void request_timeout()
Definition: NetworkLayer.cpp:122
bool sendSST(const Map27Address &address, uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:275
Class for one-shot millisecond timers.
Definition: Timer.h:37
virtual void receiveCleared(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:612
virtual void receiveNetworkInformation(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:891
bool sendDisconnect(const Map27Address &address, uint8_t cause)
Definition: NetworkLayer.cpp:421
bool sendMST(const Map27Address &address, uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:305
void decode_network_layer_packet(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:129
NetworkState
Definition: NetworkLayer.h:287
bool sendStatus(const Map27Address &address, uint8_t status)
Definition: NetworkLayer.cpp:231
void setApplicationLayer(Map27ApplicationLayer *applicationLayer)
Definition: NetworkLayer.cpp:41
bool sendRadioTest(uint8_t *buf, uint16_t bufLen)
Definition: NetworkLayer.cpp:552
Map27NetworkLayer()
Constructor.
Definition: NetworkLayer.cpp:22