home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: OtherApp / OtherApp.zip / am4pmsrc.zip / amc / user.amc < prev   
Text File  |  1994-07-18  |  3KB  |  99 lines

  1. /*********************************************************************/
  2. /* USER.AMC - Handle user events while idle                          */
  3. /*                                                                   */
  4. /* This program is called by AM4PM.EXE.                              */
  5. /*                                                                   */
  6. /* Input:  arg(1) Name of the external event                         */
  7. /*                                                                   */
  8. /* Output: 0  Normal. Only AT+VLS=0 is done before waiting           */
  9. /*         1  Full init. Reinit COM-port and everything.             */
  10. /*         2  Terminate AM4PM.                                       */
  11. /*                                                                   */
  12. /*********************************************************************/
  13.  
  14. CALL AMDPrint 'USER.AMC('arg(1)') started'
  15. CALL AMSetLastEventText 'USER' arg(1)
  16.  
  17. select
  18. when arg(1)='hookoff' then
  19.    do
  20.       CALL AMOutp 770, 5
  21.       /* Just answer */
  22.       CALL AMSendAT('AT+VLS=2{VCON}')
  23.       CALL AMSetStateText 'Local talk'
  24.       CALL AMSetLastEventText 'Hook off'
  25.       CALL AMSendAT('AT+VTS=[1800,0,2]{OK}')
  26.       res = CheckDLECode(AMWaitDLECode(3000))
  27.       CALL AMOutp 770, 7
  28.       return res
  29.    end
  30. otherwise
  31.    do
  32.       CALL AMDPrint 'Unknown user action'
  33.    end
  34. end
  35.  
  36.  
  37. Exit 0
  38.  
  39.  
  40. CheckDLECode: arg DLEEvent
  41.  
  42.    select
  43.    when DLEEvent='*' then
  44.       return ReadCmd()
  45.    when DLEEvent='hookon' then
  46.       return 0
  47.    otherwise
  48.       return Local2Ext()
  49.    end
  50. return 0
  51.  
  52.  
  53. Local2ExtTest:
  54.    CALL AMSendAT('AT+VLS=0{OK}')
  55.    CALL AMOutp 770, 4 
  56.    CALL AMSetLastEventText 'Call out'
  57.    CALL AMSetStateText 'Call out'
  58.    /* Wait for hook on */
  59.    do while 1
  60.       DLEEvent = AMWaitDLECode(60000)
  61.       if DLEEvent='hookon' then
  62.       do
  63.          CALL AMDPrint 'The hook is on again'
  64.          return 0
  65.       end
  66.    end
  67. return 0
  68.  
  69.  
  70. Local2Ext:
  71.    CALL AMSendAT('AT+VLS=0{OK}')
  72.    CALL AMOutp 770, 4 
  73.    CALL AMSetLastEventText 'Call out'
  74.    CALL AMSetStateText 'Call out'
  75.    /* Wait for hook on */
  76.    do while 0
  77.       CALL SysSleep(1)
  78.       port = AMInp(770)
  79.       crntoh = (port % 16) // 2
  80.       crntlc1 = (port % 32) // 2
  81.       crntlc2 = (port % 64) // 2
  82.       if (crntlc1 | crntlc2) then
  83.          leave
  84.    end
  85.    do while 1
  86.       CALL SysSleep(1)
  87.       port = AMInp(770)
  88.       crntlc1 = (port % 32) // 2
  89.       crntlc2 = (port % 64) // 2
  90.       if (\ (crntlc1 | crntlc2)) then
  91.       do
  92.          CALL AMDPrint 'The hook is on again'
  93.          return 0
  94.       end
  95.    end
  96. return 0
  97.  
  98.  
  99.