FreeCalypso > hg > fc-magnetite
comparison src/ui3/mfw/mfw_BtipsMdg.c @ 420:e8ddbb0837ed
src/ui3: initial import of TCS3/LoCosto BMI & MFW code
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 21 Jan 2018 03:09:00 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
419:59143cd42ec7 | 420:e8ddbb0837ed |
---|---|
1 /* ========================================================= | |
2 * Texas Instruments OMAP(TM) Platform Software | |
3 * (c) Copyright Texas Instruments, Incorporated. All Rights Reserved. | |
4 * | |
5 * Use of this software is controlled by the terms and conditions found | |
6 * in the license agreement under which this software has been supplied. | |
7 * ========================================================== */ | |
8 /* | |
9 $Project name: Basic Bluetooth MMI | |
10 $Project code: | |
11 $Module: Bluetooth BMG MFW | |
12 $File: Mfw_Btips.c | |
13 $Revision: 1.0 | |
14 $Author: Texas Instruments | |
15 $Date: 26/06/07 | |
16 | |
17 ******************************************************************************** | |
18 | |
19 Description: | |
20 | |
21 This module provides the BTIPS BMG APPlication functionality. | |
22 | |
23 ******************************************************************************** | |
24 $History: Mfw_Btips.c | |
25 | |
26 26/06/07 Sasken original version | |
27 | |
28 $End | |
29 | |
30 *******************************************************************************/ | |
31 | |
32 | |
33 | |
34 | |
35 /******************************************************************************* | |
36 | |
37 Include files | |
38 | |
39 *******************************************************************************/ | |
40 | |
41 #define ENTITY_MFW | |
42 /* includes */ | |
43 | |
44 #include <string.h> | |
45 | |
46 #if defined (NEW_FRAME) | |
47 | |
48 #include "typedefs.h" | |
49 #include "vsi.h" | |
50 #include "pei.h" | |
51 #include "custom.h" | |
52 #include "gsm.h" | |
53 #include "prim.h" | |
54 | |
55 #else | |
56 | |
57 #include "STDDEFS.H" | |
58 #include "custom.h" | |
59 #include "gsm.h" | |
60 #include "vsi.h" | |
61 | |
62 #include "bttypes.h" | |
63 #include "sec.h" | |
64 #include "spp.h" | |
65 #include "osapi.h" | |
66 #include "debug.h" | |
67 #include "btl_mdg.h" | |
68 | |
69 #endif | |
70 | |
71 #ifdef FF_MMI_BTIPS_APP | |
72 | |
73 /* Macro for sending events to UI - meanwhile, trace message to PCO Viewer */ | |
74 extern int vsi_o_state_ttrace ( const char * const format, ... ); | |
75 #define UI_DISPLAY(s) vsi_o_state_ttrace s | |
76 | |
77 #include "bttypes.h" | |
78 #include "sec.h" | |
79 #include "spp.h" | |
80 #include "osapi.h" | |
81 #include "debug.h" | |
82 //#include "../lineparser.h" | |
83 #include "btl_mdg.h" | |
84 //#include "../app_main.h" | |
85 | |
86 | |
87 /******************************************************************************** | |
88 * | |
89 * Constants | |
90 * | |
91 *******************************************************************************/ | |
92 | |
93 /* MDG Application states */ | |
94 #define MDGA_SERVER_STATE_NONE (0) | |
95 #define MDGA_SERVER_STATE_ENABLED (1) | |
96 #define MDGA_SERVER_STATE_DISABLING (2) | |
97 #define MDGA_SERVER_STATE_DT_CONNECTED (3) | |
98 #define MDGA_SERVER_STATE_MODEM_CONNECTED (4) | |
99 #define MDGA_SERVER_STATE_CONNECTED (5) | |
100 | |
101 /* Security level of the MDG Application */ | |
102 #define MDGA_SECURITY_LEVEL (BSL_AUTHENTICATION_IN | BSL_AUTHENTICATION_OUT) | |
103 | |
104 /* Max number of Rx Sync packets - this value will be given to peer serial port | |
105 * as amount of credits for RFCOMM credit based flow control */ | |
106 #define MDGA_MAX_NUM_OF_RX_SYNC_PACKETS (5) | |
107 | |
108 | |
109 /******************************************************************************** | |
110 * | |
111 * Types | |
112 * | |
113 *******************************************************************************/ | |
114 | |
115 /* Structure to keep track of server information */ | |
116 typedef struct | |
117 { | |
118 U8 state; | |
119 const BtSecurityLevel securityLevel; | |
120 BtlMdgServerContext *serverContext; | |
121 BtlMdgServerSettings serverSettings; | |
122 SppLineStatus lineStatus; | |
123 } MdgaServer; | |
124 | |
125 | |
126 /******************************************************************************** | |
127 * | |
128 * Function prototypes | |
129 * | |
130 *******************************************************************************/ | |
131 void mfw_btips_mdgInit(void); | |
132 void MDGA_Deinit(void); | |
133 void MDGA_Enable(U8 serverIndex); | |
134 void MDGA_Disable(U8 serverIndex); | |
135 void MDGA_GetSecurityLevel(U8 serverIndex); | |
136 void MDGA_SetSecurityLevel(U8 serverIndex, BtSecurityLevel *securityLevel); | |
137 void MDGA_GetComSettings(U8 serverIndex); | |
138 void MDGA_SetComSettings(U8 serverIndex, SppComSettings *comSettings); | |
139 void MDGA_GetConnectedDevice(U8 serverIndex); | |
140 void MDGA_TerminateDataCall(void); | |
141 | |
142 void mfw_btips_mdgCallback(const BtlMdgCallbackParms *parms); | |
143 static const char *MdgaEventName(BtlMdgServerEvent mdgEvent); | |
144 static const char *MdgaStateName(int state); | |
145 | |
146 | |
147 /******************************************************************************** | |
148 * | |
149 * Globals | |
150 * | |
151 *******************************************************************************/ | |
152 | |
153 static MdgaServer mdgaServers[] = | |
154 { | |
155 { | |
156 MDGA_SERVER_STATE_NONE, MDGA_SECURITY_LEVEL, NULL, | |
157 {BTL_SPP_SERVICE_TYPE_DUN, | |
158 "BTIPS DUN", | |
159 {SPP_SERVER_PORT, | |
160 BTL_SPP_SERVICE_TYPE_DUN, | |
161 SPP_PORT_DATA_PATH_TX_SYNC | SPP_PORT_DATA_PATH_RX_ASYNC, | |
162 MDGA_MAX_NUM_OF_RX_SYNC_PACKETS, | |
163 {SPP_COM_SETTING_BAUDRATE_DEFAULT, | |
164 SPP_COM_SETTING_DATA_FORMAT_DEFAULT, | |
165 SPP_COM_SETTING_FLOW_CONTROL_DEFAULT, | |
166 SPP_COM_SETTING_XON_CHAR_DEFAULT, | |
167 SPP_COM_SETTING_XOFF_CHAR_DEFAULT, | |
168 0 | |
169 } | |
170 }, | |
171 }, | |
172 0 | |
173 } | |
174 }; | |
175 | |
176 #define MDGA_NUM_SERVERS (sizeof(mdgaServers) / sizeof(MdgaServer)) | |
177 | |
178 | |
179 /******************************************************************************** | |
180 * | |
181 * Function definitions | |
182 * | |
183 *******************************************************************************/ | |
184 | |
185 /*------------------------------------------------------------------------------- | |
186 * mfw_btips_mdgInit() | |
187 * | |
188 * Initialize application module. | |
189 * | |
190 * Type: | |
191 * Synchronous. | |
192 * | |
193 * Parameters: | |
194 * None. | |
195 * | |
196 * Returns: | |
197 * None. | |
198 */ | |
199 void mfw_btips_mdgInit() | |
200 { | |
201 BtStatus status; | |
202 U32 idx; | |
203 MdgaServer *server = &mdgaServers[0]; | |
204 | |
205 Report(("mfw_btips_mdgInit")); | |
206 | |
207 /* Create and enable all MDG servers */ | |
208 for (idx=0; idx<MDGA_NUM_SERVERS; idx++, server++) | |
209 { | |
210 /* Create MDG server */ | |
211 status = BTL_MDG_Create(0, | |
212 mfw_btips_mdgCallback, | |
213 &server->securityLevel, | |
214 &server->serverContext); | |
215 if (BT_STATUS_SUCCESS != status) | |
216 { | |
217 Report(("MDGA: BTL_MDG_Create() failed for server %s, status %s", | |
218 server->serverSettings.serviceName, | |
219 pBT_Status(status))); | |
220 } | |
221 else | |
222 { | |
223 /* Enable MDG server */ | |
224 status = BTL_MDG_Enable(server->serverContext, | |
225 &server->serverSettings); | |
226 | |
227 if (BT_STATUS_SUCCESS != status) | |
228 { | |
229 Report(("MDGA: BTL_MDG_Enable() failed for server %s, status %s", | |
230 server->serverSettings.serviceName, | |
231 pBT_Status(status))); | |
232 } | |
233 else | |
234 { | |
235 server->state = MDGA_SERVER_STATE_ENABLED; | |
236 } | |
237 } | |
238 } | |
239 } | |
240 | |
241 /*------------------------------------------------------------------------------- | |
242 * MDGA_Deinit() | |
243 * | |
244 * Deinitialize application module. | |
245 * | |
246 * Type: | |
247 * Synchronous. | |
248 * | |
249 * Parameters: | |
250 * None. | |
251 * | |
252 * Returns: | |
253 * None. | |
254 */ | |
255 void MDGA_Deinit() | |
256 { | |
257 BtStatus status; | |
258 U32 idx; | |
259 MdgaServer *server = &mdgaServers[0]; | |
260 | |
261 Report(("MDGA_Deinit")); | |
262 | |
263 /* Disable and destroy all MDG servers */ | |
264 for (idx=0; idx<MDGA_NUM_SERVERS; idx++, server++) | |
265 { | |
266 /* Check whether the server was enabled and not in DISABLING state */ | |
267 if ((server->state >= MDGA_SERVER_STATE_ENABLED) && | |
268 (MDGA_SERVER_STATE_DISABLING != server->state)) | |
269 { | |
270 /* Disable MDG server */ | |
271 status = BTL_MDG_Disable(server->serverContext); | |
272 | |
273 if (BT_STATUS_SUCCESS == status) | |
274 { | |
275 /* Destroy MDG server */ | |
276 status = BTL_MDG_Destroy(&server->serverContext); | |
277 | |
278 if (BT_STATUS_SUCCESS != status) | |
279 { | |
280 Report(("MDGA: BTL_MDG_Destroy() failed for server %s, status %s", | |
281 server->serverSettings.serviceName, | |
282 pBT_Status(status))); | |
283 } | |
284 else | |
285 { | |
286 server->state = MDGA_SERVER_STATE_NONE; | |
287 } | |
288 } | |
289 else if ((BT_STATUS_PENDING == status) || (BT_STATUS_IN_PROGRESS == status)) | |
290 { | |
291 /* Continue disabling server in mfw_btips_mdgCallback() */ | |
292 server->state = MDGA_SERVER_STATE_DISABLING; | |
293 } | |
294 else | |
295 { | |
296 Report(("MDGA: BTL_MDG_Disable() failed, status %s", pBT_Status(status))); | |
297 } | |
298 } | |
299 } | |
300 } | |
301 | |
302 /*------------------------------------------------------------------------------- | |
303 * MDGA_Enable() | |
304 * | |
305 * Processes command 'enable'. | |
306 * | |
307 * Type: | |
308 * Synchronous. | |
309 * | |
310 * Parameters: | |
311 * serverIndex - index of the server. | |
312 * | |
313 * Returns: | |
314 * None. | |
315 */ | |
316 void MDGA_Enable(U8 serverIndex) | |
317 { | |
318 BtStatus status; | |
319 MdgaServer *server; | |
320 | |
321 server = &mdgaServers[serverIndex]; | |
322 | |
323 /* Check validity of the command */ | |
324 if (server->state >= MDGA_SERVER_STATE_ENABLED) | |
325 { | |
326 Report(("MDGA: server %s is already enabled", | |
327 server->serverSettings.serviceName)); | |
328 return; | |
329 } | |
330 | |
331 /* Create MDG server */ | |
332 status = BTL_MDG_Create(0, | |
333 mfw_btips_mdgCallback, | |
334 &server->securityLevel, | |
335 &server->serverContext); | |
336 if (BT_STATUS_SUCCESS != status) | |
337 { | |
338 Report(("MDGA: BTL_MDG_Create() failed, status %s", | |
339 pBT_Status(status))); | |
340 } | |
341 else | |
342 { | |
343 /* Enable MDG server */ | |
344 status = BTL_MDG_Enable(server->serverContext, | |
345 &server->serverSettings); | |
346 | |
347 if (BT_STATUS_SUCCESS != status) | |
348 { | |
349 Report(("MDGA: BTL_MDG_Enable() failed, status %s", | |
350 pBT_Status(status))); | |
351 } | |
352 else | |
353 { | |
354 server->state = MDGA_SERVER_STATE_ENABLED; | |
355 UI_DISPLAY(("MDGA: server %s enabled", | |
356 server->serverSettings.serviceName)); | |
357 } | |
358 } | |
359 | |
360 return; | |
361 } | |
362 | |
363 /*------------------------------------------------------------------------------- | |
364 * MDGA_Disable() | |
365 * | |
366 * Processes command 'enable'. | |
367 * | |
368 * Type: | |
369 * Synchronous. | |
370 * | |
371 * Parameters: | |
372 * serverIndex - index of the server. | |
373 * | |
374 * Returns: | |
375 * None. | |
376 */ | |
377 void MDGA_Disable(U8 serverIndex) | |
378 { | |
379 BtStatus status; | |
380 MdgaServer *server = &mdgaServers[serverIndex]; | |
381 | |
382 /* Check validity of the command */ | |
383 if (server->state < MDGA_SERVER_STATE_ENABLED) | |
384 { | |
385 Report(("MDGA: server %s is not enabled", | |
386 server->serverSettings.serviceName)); | |
387 return; | |
388 } | |
389 | |
390 /* Disable MDG server */ | |
391 status = BTL_MDG_Disable(server->serverContext); | |
392 | |
393 if (BT_STATUS_SUCCESS == status) | |
394 { | |
395 /* Destroy MDG server */ | |
396 status = BTL_MDG_Destroy(&server->serverContext); | |
397 | |
398 if (BT_STATUS_SUCCESS != status) | |
399 { | |
400 Report(("MDGA: BTL_MDG_Destroy() failed, status %s", | |
401 pBT_Status(status))); | |
402 } | |
403 else | |
404 { | |
405 server->state = MDGA_SERVER_STATE_NONE; | |
406 UI_DISPLAY(("MDGA: server %s disabled", | |
407 server->serverSettings.serviceName)); | |
408 } | |
409 } | |
410 else if ((BT_STATUS_PENDING == status) || (BT_STATUS_IN_PROGRESS == status)) | |
411 { | |
412 /* Continue disabling server in mfw_btips_mdgCallback() */ | |
413 server->state = MDGA_SERVER_STATE_DISABLING; | |
414 UI_DISPLAY(("MDGA: disabling server %s", | |
415 server->serverSettings.serviceName)); | |
416 } | |
417 else | |
418 { | |
419 Report(("MDGA: BTL_MDG_Disable() failed, status %s", pBT_Status(status))); | |
420 } | |
421 | |
422 return; | |
423 } | |
424 | |
425 /*------------------------------------------------------------------------------- | |
426 * MDGA_GetSecurityLevel() | |
427 * | |
428 * Processes command 'getsec'. | |
429 * | |
430 * Type: | |
431 * Synchronous. | |
432 * | |
433 * Parameters: | |
434 * serverIndex - index of the server. | |
435 * | |
436 * Returns: | |
437 * None. | |
438 */ | |
439 void MDGA_GetSecurityLevel(U8 serverIndex) | |
440 { | |
441 BtStatus status; | |
442 BtSecurityLevel securityLevel; | |
443 MdgaServer *server = &mdgaServers[serverIndex]; | |
444 | |
445 status = BTL_MDG_GetSecurityLevel(server->serverContext, &securityLevel); | |
446 | |
447 if (BT_STATUS_SUCCESS == status) | |
448 { | |
449 UI_DISPLAY(("UI_EVENT: MDGA got security level %d for server %s", | |
450 securityLevel, | |
451 server->serverSettings.serviceName)); | |
452 } | |
453 else | |
454 { | |
455 Report(("MDGA: BTL_MDG_GetSecurityLevel() failed for server %s, status %s", | |
456 server->serverSettings.serviceName, | |
457 pBT_Status(status))); | |
458 } | |
459 | |
460 return; | |
461 } | |
462 | |
463 /*------------------------------------------------------------------------------- | |
464 * MDGA_SetSecurityLevel() | |
465 * | |
466 * Processes command 'setsec'. | |
467 * | |
468 * Type: | |
469 * Synchronous. | |
470 * | |
471 * Parameters: | |
472 * serverIndex - index of the server. | |
473 * | |
474 * Returns: | |
475 * None. | |
476 */ | |
477 void MDGA_SetSecurityLevel(U8 serverIndex, BtSecurityLevel *securityLevel) | |
478 { | |
479 BtStatus status; | |
480 MdgaServer *server = &mdgaServers[serverIndex]; | |
481 | |
482 status = BTL_MDG_SetSecurityLevel(server->serverContext, securityLevel); | |
483 | |
484 if (BT_STATUS_SUCCESS == status) | |
485 { | |
486 UI_DISPLAY(("UI_EVENT: MDGA set security level %d for server %s", | |
487 *securityLevel, | |
488 server->serverSettings.serviceName)); | |
489 } | |
490 else | |
491 { | |
492 Report(("MDGA: BTL_MDG_SetSecurityLevel() failed for server %s, status %s", | |
493 server->serverSettings.serviceName, | |
494 pBT_Status(status))); | |
495 } | |
496 | |
497 return; | |
498 } | |
499 | |
500 /*------------------------------------------------------------------------------- | |
501 * MDGA_GetComSettings() | |
502 * | |
503 * Processes command 'getcomset'. | |
504 * | |
505 * Type: | |
506 * Synchronous. | |
507 * | |
508 * Parameters: | |
509 * serverIndex - index of the server. | |
510 * | |
511 * Returns: | |
512 * None. | |
513 */ | |
514 void MDGA_GetComSettings(U8 serverIndex) | |
515 { | |
516 BtStatus status; | |
517 SppComSettings comSettings; | |
518 MdgaServer *server = &mdgaServers[serverIndex]; | |
519 | |
520 status = BTL_MDG_GetComSettings(server->serverContext, &comSettings); | |
521 | |
522 if (BT_STATUS_SUCCESS == status) | |
523 { | |
524 UI_DISPLAY(("UI_EVENT: MDGA got com settings for server %s -", server->serverSettings.serviceName)); | |
525 UI_DISPLAY(("UI_EVENT: MDGA baudrate 0x%02x, data format 0x%02x, flow control 0x%02x, XON 0x%02x, XOFF 0x%02x", | |
526 comSettings.baudRate, | |
527 comSettings.dataFormat, | |
528 comSettings.flowControl, | |
529 comSettings.xonChar, | |
530 comSettings.xoffChar)); | |
531 } | |
532 else | |
533 { | |
534 Report(("MDGA: BTL_MDG_GetComSettings() failed for server %s, status %s", | |
535 server->serverSettings.serviceName, | |
536 pBT_Status(status))); | |
537 } | |
538 | |
539 return; | |
540 } | |
541 | |
542 /*------------------------------------------------------------------------------- | |
543 * MDGA_SetComSettings() | |
544 * | |
545 * Processes command 'setcomset'. | |
546 * | |
547 * Type: | |
548 * Synchronous. | |
549 * | |
550 * Parameters: | |
551 * serverIndex - index of the server. | |
552 * | |
553 * Returns: | |
554 * None. | |
555 */ | |
556 void MDGA_SetComSettings(U8 serverIndex, SppComSettings *comSettings) | |
557 { | |
558 BtStatus status; | |
559 MdgaServer *server = &mdgaServers[serverIndex]; | |
560 | |
561 status = BTL_MDG_SetComSettings(server->serverContext, comSettings); | |
562 | |
563 if (BT_STATUS_SUCCESS == status) | |
564 { | |
565 UI_DISPLAY(("UI_EVENT: MDGA set com settings for server %s -", server->serverSettings.serviceName)); | |
566 UI_DISPLAY(("UI_EVENT: MDGA baudrate 0x%02x, data format 0x%02x, flow control 0x%02x, XON 0x%02x, XOFF 0x%02x, parm mask 0x%04x", | |
567 comSettings->baudRate, | |
568 comSettings->dataFormat, | |
569 comSettings->flowControl, | |
570 comSettings->xonChar, | |
571 comSettings->xoffChar, | |
572 comSettings->parmMask)); | |
573 } | |
574 else if ((BT_STATUS_PENDING != status) && (BT_STATUS_IN_PROGRESS != status)) | |
575 { | |
576 Report(("MDGA: BTL_MDG_GetComSettings() failed for server %s, status %s", | |
577 server->serverSettings.serviceName, | |
578 pBT_Status(status))); | |
579 } | |
580 | |
581 return; | |
582 } | |
583 | |
584 /*------------------------------------------------------------------------------- | |
585 * MDGA_GetConnectedDevice() | |
586 * | |
587 * Processes command 'getcondev'. | |
588 * | |
589 * Type: | |
590 * Synchronous. | |
591 * | |
592 * Parameters: | |
593 * serverIndex - index of the server. | |
594 * | |
595 * Returns: | |
596 * None. | |
597 */ | |
598 void MDGA_GetConnectedDevice(U8 serverIndex) | |
599 { | |
600 BtStatus status; | |
601 BD_ADDR bdAddr; | |
602 char addr[BDADDR_NTOA_SIZE]; | |
603 MdgaServer *server = &mdgaServers[serverIndex]; | |
604 | |
605 status = BTL_MDG_GetConnectedDevice(server->serverContext, &bdAddr); | |
606 | |
607 if (BT_STATUS_SUCCESS == status) | |
608 { | |
609 UI_DISPLAY(("UI_EVENT: MDGA server %s is connected to %s", | |
610 server->serverSettings.serviceName, | |
611 bdaddr_ntoa((const BD_ADDR *)&bdAddr, addr))); | |
612 } | |
613 else | |
614 { | |
615 Report(("MDGA: MdgaGetConnectedDevice() failed for server %s, status %s", | |
616 server->serverSettings.serviceName, | |
617 pBT_Status(status))); | |
618 } | |
619 | |
620 return; | |
621 } | |
622 | |
623 /*------------------------------------------------------------------------------- | |
624 * MDGA_TerminateDataCall() | |
625 * | |
626 * Processes command 'termdatacall'. | |
627 * | |
628 * Type: | |
629 * Synchronous. | |
630 * | |
631 * Parameters: | |
632 * None. | |
633 * | |
634 * Returns: | |
635 * None. | |
636 */ | |
637 void MDGA_TerminateDataCall() | |
638 { | |
639 return; | |
640 } | |
641 | |
642 /*------------------------------------------------------------------------------- | |
643 * mfw_btips_mdgCallback() | |
644 * | |
645 * Callback function for receiving BTL MDG events. | |
646 * | |
647 * Type: | |
648 * Synchronous. | |
649 * | |
650 * Parameters: | |
651 * parms - received event. | |
652 * | |
653 * Returns: | |
654 * None. | |
655 */ | |
656 | |
657 void mfw_btips_mdgCallback(const BtlMdgCallbackParms *parms) | |
658 { | |
659 BtStatus status; | |
660 MdgaServer *server; | |
661 int idx; | |
662 | |
663 TRACE_EVENT_P1("mfw_btips_mdgCallback - %d", parms->event); | |
664 /* Find a server according to given BTL MDG context */ | |
665 for (idx = 0, server=&mdgaServers[0]; idx<MDGA_NUM_SERVERS; idx++, server++) | |
666 { | |
667 if (server->serverContext == parms->serverContext) | |
668 { | |
669 break; | |
670 } | |
671 } | |
672 | |
673 /* Check whether we found a port in array of clients */ | |
674 if (MDGA_NUM_SERVERS == idx) | |
675 { | |
676 | |
677 /* Server is not found */ | |
678 Report(("MDGA: server's context is unknown")); | |
679 return; | |
680 } | |
681 | |
682 /* Display received event and server's service name */ | |
683 UI_DISPLAY(("UI_EVENT: MDGA received event %s for server %s", | |
684 MdgaEventName(parms->event), | |
685 server->serverSettings.serviceName)); | |
686 | |
687 /* Change port's state according to event */ | |
688 switch(parms->event) | |
689 { | |
690 case BTL_MDG_SERVER_EVENT_ENABLED: | |
691 server->state = MDGA_SERVER_STATE_ENABLED; | |
692 break; | |
693 | |
694 case BTL_MDG_SERVER_EVENT_DISABLED: | |
695 if (MDGA_SERVER_STATE_DISABLING == server->state) | |
696 { | |
697 /* Destroy MDG server */ | |
698 status = BTL_MDG_Destroy(&server->serverContext); | |
699 | |
700 if (BT_STATUS_SUCCESS != status) | |
701 { | |
702 Report(("MDGA: BTL_MDG_Destroy() failed, status %s", | |
703 pBT_Status(status))); | |
704 } | |
705 else | |
706 { | |
707 server->state = MDGA_SERVER_STATE_NONE; | |
708 UI_DISPLAY(("MDGA: server %s disabled", | |
709 server->serverSettings.serviceName)); | |
710 } | |
711 } | |
712 break; | |
713 | |
714 case BTL_MDG_SERVER_EVENT_DT_CONNECTED: | |
715 if (MDGA_SERVER_STATE_MODEM_CONNECTED == server->state) | |
716 { | |
717 server->state = MDGA_SERVER_STATE_CONNECTED; | |
718 } | |
719 else | |
720 { | |
721 server->state = MDGA_SERVER_STATE_DT_CONNECTED; | |
722 } | |
723 break; | |
724 | |
725 case BTL_MDG_SERVER_EVENT_DT_DISCONNECTED: | |
726 if (MDGA_SERVER_STATE_CONNECTED == server->state) | |
727 { | |
728 server->state = MDGA_SERVER_STATE_MODEM_CONNECTED; | |
729 } | |
730 else if (MDGA_SERVER_STATE_DISABLING != server->state) | |
731 { | |
732 server->state = MDGA_SERVER_STATE_ENABLED; | |
733 } | |
734 break; | |
735 | |
736 case BTL_MDG_SERVER_EVENT_MODEM_CONNECTED: | |
737 if (MDGA_SERVER_STATE_DT_CONNECTED == server->state) | |
738 { | |
739 server->state = MDGA_SERVER_STATE_CONNECTED; | |
740 } | |
741 else | |
742 { | |
743 server->state = MDGA_SERVER_STATE_DT_CONNECTED; | |
744 } | |
745 break; | |
746 | |
747 case BTL_MDG_SERVER_EVENT_MODEM_DISCONNECTED: | |
748 if (MDGA_SERVER_STATE_CONNECTED == server->state) | |
749 { | |
750 server->state = MDGA_SERVER_STATE_DT_CONNECTED; | |
751 } | |
752 else if (MDGA_SERVER_STATE_DISABLING != server->state) | |
753 { | |
754 server->state = MDGA_SERVER_STATE_ENABLED; | |
755 } | |
756 break; | |
757 | |
758 default: | |
759 break; | |
760 } | |
761 | |
762 /* Display server's new state */ | |
763 Report(("MDGA: %s server's state %s", | |
764 server->serverSettings.serviceName, | |
765 MdgaStateName(server->state))); | |
766 } | |
767 | |
768 /*------------------------------------------------------------------------------- | |
769 * MdgaEventName() | |
770 * | |
771 * Gets event's name. | |
772 * | |
773 * Type: | |
774 * Synchronous. | |
775 * | |
776 * Parameters: | |
777 * mdgEvent - event. | |
778 * | |
779 * Returns: | |
780 * String with event's name. | |
781 */ | |
782 static const char *MdgaEventName(BtlMdgServerEvent mdgEvent) | |
783 { | |
784 switch (mdgEvent) | |
785 { | |
786 case BTL_MDG_SERVER_EVENT_INITIALIZED: | |
787 return "BTL_MDG_SERVER_EVENT_INITIALIZED"; | |
788 | |
789 case BTL_MDG_SERVER_EVENT_DEINITIALIZED: | |
790 return "BTL_MDG_SERVER_EVENT_DEINITIALIZED"; | |
791 | |
792 case BTL_MDG_SERVER_EVENT_ENABLED: | |
793 return "BTL_MDG_SERVER_EVENT_ENABLED"; | |
794 | |
795 case BTL_MDG_SERVER_EVENT_DISABLED: | |
796 return "BTL_MDG_SERVER_EVENT_DISABLED"; | |
797 | |
798 case BTL_MDG_SERVER_EVENT_DT_CONNECTED: | |
799 return "BTL_MDG_SERVER_EVENT_DT_CONNECTED"; | |
800 | |
801 case BTL_MDG_SERVER_EVENT_DT_DISCONNECTED: | |
802 return "BTL_MDG_SERVER_EVENT_DT_DISCONNECTED"; | |
803 | |
804 case BTL_MDG_SERVER_EVENT_MODEM_CONNECTED: | |
805 return "BTL_MDG_SERVER_EVENT_MODEM_CONNECTED"; | |
806 | |
807 case BTL_MDG_SERVER_EVENT_MODEM_DISCONNECTED: | |
808 return "BTL_MDG_SERVER_EVENT_MODEM_DISCONNECTED"; | |
809 | |
810 default: | |
811 return "MDGA: server received unknown event"; | |
812 } | |
813 } | |
814 | |
815 /*------------------------------------------------------------------------------- | |
816 * MdgaStateName() | |
817 * | |
818 * Gets state's name. | |
819 * | |
820 * Type: | |
821 * Synchronous. | |
822 * | |
823 * Parameters: | |
824 * state - server's state. | |
825 * | |
826 * Returns: | |
827 * String with state's name. | |
828 */ | |
829 static const char *MdgaStateName(int state) | |
830 { | |
831 switch (state) | |
832 { | |
833 case MDGA_SERVER_STATE_NONE: | |
834 return "MDGA_SERVER_STATE_NONE"; | |
835 | |
836 case MDGA_SERVER_STATE_ENABLED: | |
837 return "MDGA_SERVER_STATE_ENABLED"; | |
838 | |
839 case MDGA_SERVER_STATE_DISABLING: | |
840 return "MDGA_SERVER_STATE_DISABLING"; | |
841 | |
842 case MDGA_SERVER_STATE_DT_CONNECTED: | |
843 return "MDGA_SERVER_STATE_DT_CONNECTED"; | |
844 | |
845 case MDGA_SERVER_STATE_MODEM_CONNECTED: | |
846 return "MDGA_SERVER_STATE_MODEM_CONNECTED"; | |
847 | |
848 case MDGA_SERVER_STATE_CONNECTED: | |
849 return "MDGA_SERVER_STATE_CONNECTED"; | |
850 | |
851 default: | |
852 return "MDG server unknown state"; | |
853 } | |
854 } | |
855 | |
856 #endif | |
857 |