2015年11月2日 星期一

Microsoft fax implementation


要怎樣呼叫The Microsoft fax client COM implementation interfaces
或者有人可以告訴我FAX程式 或是有Component 或是..... 

用 TurboPower 套件 , 內有 Fax 相關元件
網址: http://sourceforge.net/projects/tpapro/  

 tpapro_4_06.zip 解壓後有個 examples 目錄
http://sourceforge.net/projects/tpapro/
TurboPower Async Professional ~~~~ Brought to you by: tpsfadmin

examples 目錄下的 delphi 目錄有個 FaxServer.dpr


Microsoft send fax PowerShell Windows Fax server

http://www.codeproject.com/Articles/120638/G-Modem-Internet-



Windows 2000/XP offers two possibilities to send faxes programmatically, either by a COM-Object (faxcom.dll) or by an API (winfax.dll). The COM object also can be used in script languages like JScript, however, it isn't so flexible as the API. Through the API on the other hand you receive control over the sending process during sending. To be able to send faxes by a web page, I have written an ISAPI extension using the Fax-API.

To use the fax API you must use the corresponding header files and libraries from the Microsoft Platform SDK. You can download the Platform SDK under http://msdn.microsoft.com/download free of charge.

After it, you copy the ISAPI-Extension (FaxISAPI.DLL) and the necessary ASP files (default.asp, progress.asp and ready.asp) into the web folder. Now start the browser and enter the address to the web folder (e.g. "http://localhost/fax") and send a fax through the web page. 
The code of the FaxISAPI.DLL consists of three .cpp files. The file extension.cpp contains the functions for the ISAPI-Extension, upload.cpp contains the C++ class for the Upload, fax.cpp contains the C++ class for initializing the fax server and for sending faxes.
To inform the client about status information of the Upload and fax process, the ISAPI-DLL writes into a status file (this status file will be created in "c:\ winnt\temp" and the name of it corresponds to the Session ID + ".log"). 
The ASP file progress.asp is refreshed by the browser every second and the progress.asp reads the Status on the server from the status file.

The default.asp contains the HTML form to get the fax number from the user. The fax number then is passed to choosefile.asp. The file choosefile.asp contains the HTML form for the choice of the faxing file and calls the FaxISAPI.DLL at a "Submit" and opens simultaneously a new browser window by Javascript with the progress.asp. 

The CUpload class contains the methods for the Upload of exactly one file to a web server. The class writes the number of bytes written to the status file and also the length of the file. This status information is used by progress.asp to show a progress bar. The uploaded file is stored intermediately in the folder "c:\winnt\temp".
Faxing the uploaded file

CFax contains the methods for the Initializing/Deinitialising (Init, DeInit) of the fax service and the method for sending Fax documents (send). The method Init of the ISAPI.DLL is called when loading the DLL the first time, DeInit when unloading the DLL. The real sending process of the fax document is implemented in CFax::Send. The ISAPI-DLL finish its work and sends a Redirect to ready.asp to the browser after the fax was sent. Ready.asp then gives the user information about whether the fax could be successfully sent.
Conclusion
Through the fax API you can access all essential events of the fax service.


3G Modem Internet Dialer

Code Design
I have tried to keep everything as object oriented as possible so the code can be reusable and easy to maintain, because not all manufacturers use the same set of commands. I used factory design pattern to select the correct class to load dynamically depending on the installed modem. An instance of CDummyModem is first created, then the modem model is identified and the appropriate class is constructed for that modem.

Dialing
For dialing, there are two ways: either opening the "Huawei Connect - 3G Modem" port and issue a dial command, or letting RAS do the job for you. I took the easy way and used RAS to handle the dialing.

There are a lot of articles that talk about RAS functions in details, so I will not go deep in this. Also there are a lot of ready made classes that make using RAS functions easier but I thought of making my own.

To use CMyRas class, you will need to create an instance of CMyRas:

Hide   Copy Code
CMyRAS m_RAS;
Then you have to call the Initialize function passing a pointer to CWnd that will be receiving the events from the RAS callback function.

Hide   Copy Code
if(!m_RAS.Initialize(m_pEventWnd))
{
    //Error
    return FALSE;
}
Calling the Initialize function also retrieves a list of address book entries and their count. You can use GetEntriesCount to know the number of Address book entries and you can get entries by index by using GetEntry function.

Now you are ready to Dial using the function Dial, by passing the entry name that you want to dial, the user name, and the password.

To hang up a connection, just call HangUp.

Note: You need the modem to have the correct APN set or else the server will disconnect you.

Communicating with the Modem
Sending and reserving messages from the modem is straight forward, all you have to do is open the port for "HUAWEI Mobile Connect - 3G PC UI" and send your commands. If you open the modem port, you won't be able to use RAS for dialing.

I have added my own serial port class CSerial. All I needed is simply read/writing to the serial port. The CSerial Class has two threads; one for reading and one for writing. To use the class, make an instance of the class and call Initialize, which takes a pointer of CModem class to forward the received data from the port. Now you will need to open the port by calling Open function, Open function will also start reading and writing threads.

When you're done, call ShutDown to close the port and to end the threads.

Modem Events
Modem Traffic Status

Usually HUAWEI 3G modems, send their status to the "HUAWEI Mobile Connect - 3G PC UI". The DSFLOWRPT message informs us about connection status every two seconds. The received text on the serial port looks something like this:

Hide   Copy Code
^DSFLOWRPT:0000240E,00000000,00000000,00000000000AD023,00000000002FA192,0003E800,0003E800 
This is an explanation for what the numbers represent:

Hide   Copy Code
^DSFLOWRPT: N1, N2, N3, N4, N5, N6, N7 
        N1: Connection duration in seconds 
        N2: measured upload speed 
        N3: measured download speed 
        N4: number of sent data 
        N5: number of received data  
        N6: connection, supported by the maximum upload speed
        N7: connection, supported by a maximum download speed 
Using the information that is supplied from the DSFLOWRPT event, you can draw a graph showing your connection status (upload/download over time).

Note: This event is only sent when you are connected.

Signal Quality

Once there has been a signal level change, your modem will send a RSSI event. The RSSI event shows the current signal quality level. Usually it is between 0 to 31.

This table maps the RSSI value with the signal Quality:

Wording Blocks Percentages RSSI Decibels
Excellent [][][][][] 100 31 >-51
97 30 -53
94 29 -55
90 28 -57
87 27 -59
84 26 -61
Good [][][][] 81 25 -63
77 24 -65
74 23 -67
71 22 -69
68 21 -71
65 20 -73
Fair [][][] 61 19 -75
58 18 -77
55 17 -79
52 16 -81
48 15 -83
45 14 -85
Poor [][] 42 13 -87
39 12 -89
35 11 -91
32 10 -93
29 9 -95
26 8 -97
Very Poor [] 23 7 -99
19 6 -101
16 5 -103
13 4 -105
10 3 -107
6 2 -109
No Signal 3 1 -111
0 0 <-113 p="">
Some modems don’t send status events or signal quality events, the workaround would be creating a thread that would periodically query the modem for its status.

List of Common 3G Commands
Some commands can be used for querying or setting. To Query, you will need to append a “?”. To set, you will need to append a “=”. For example, to query for a modem for current APN, use the following command:

Hide   Copy Code
AT+CGDCONT?
To set the APN:

Hide   Copy Code
AT+CGDCONT=1,”IP”,”apn name”
AT Command Description
AT Get the modem's attention
ATI Get manufacturer information
AT+CGMI Get manufacturer information
AT+CIMI Get SIM IMSI number
AT+CGSN Get modem IMEI
AT^HWVER Get hardware version
AT^SYSINFO Get System information
AT+CSQ Get signal strength
AT+CGMR Print firmware version of the modem
ATZ Reset the modem back to default factory settings
AT+CFUN Get/Set operating mode
AT+CPIN Get/Set PIN
AT+CGDCONT Get/Set APN
AT^SYSCFG Get/Set System configuration
AT+CUSD Sending USSD Commands

Serial Programming/Modems and AT Commands
< Serial Programming
Serial Programming: Introduction and OSI Network Model -- RS-232 Wiring and Connections -- Typical RS232 Hardware Configuration -- 8250 UART -- DOS -- MAX232 Driver/Receiver Family -- TAPI Communications In Windows -- Linux and Unix -- Java -- Hayes-compatible Modems and AT Commands -- Universal Serial Bus (USB) -- Forming Data Packets -- Error Correction Methods -- Two Way Communication -- Packet Recovery Methods -- Serial Data Networks -- Practical Application Development -- IP Over Serial Connections


沒有留言: