Caller ID Software, MS Access
|
|
Comm Port Routine
The following portion of the source code shows how each character is processed as it is received from the serial port. This code runs when the MS Comm control fires its "comEvReceive" event. The character is assigned to the varable "strCommChar".
|
Select Case strCommChar
Case "+" 'Beginning of Identifier Event
strIdentifier = ""
Case Chr$(10) 'Ignor the Line Feed after the CR
' ignor line feed
Case Chr$(13) 'Carriage Return, End of Identifier Event String
IdentifierEvent (strIdentifier) ' The Identifier Event is passed to a processing routine
Case Else 'Append the received character to the Identifier String
strIdentifier = strIdentifier + strCommChar
End Select
|
|
Identifer Event Format
The first character after the plus sign identifies what type of Identifier event occurred. Although commas separate the data in the event string, it is actually a fixed field format. Therefore you do not have to search for the commas to extract the data. A simple substring function is all that is required because the data is always in the same place for each type of event.
The following is an annotated example of the real time data from the Identifier with all events enabled. The example is two calls, one to another line with Caller ID and one to a line with Distinctive Ring but no Caller ID. This example has all realtime events enabled. Each type of event may selectively turn on or off. All data is output in a fixed field format.
|
+2,4,002 OFF HOOK OUTGOING LINE 2
+5,3,002 DTMF DIGIT 3 PRESSED LINE 2
+5,4,002 " 4 "
+5,4,002 " 4 "
+5,7,002 " 7 "
+5,6,002 " 6 "
+5,6,002 " 6 "
+5,5,002 " 5 "
+2,1,001 RING START LINE 1
+2,2,001 RING STOP LINE 1
+1,9543447665,Y E S TELECOM ,001 CALLER ID INFO INCOMING LINE 1
+2,1,001 RING START LINE 1
+2,2,001 RING STOP LINE 1
+2,3,001 OFF HOOK INCOMING LINE 1
+2,0,002 ON HOOK LINE 2 IDLE
+2,0,003 ON HOOK LINE 1 IDLE
|
|
Event Processing Example
The following source code takes the Identifier Event string passed by the above Comm routine and extracts the information. The Identifier Event string is passed without the preceding plus sign. The first character indicates the type of Identifier Event. The types are:
- 1 Caller ID, Number and Name
- 2 Line Status
- 3 Watchdog or Serial Number
- 4 Caller ID, Out of Area or Private
- 5 Touch Tone (DTMF)
- 8 Caller ID Signal Error
Event Processing Source Code
|
strEventType = Mid$(strEvent, 1, 1) 'The first character indicates the type of event
Select Case strEventType
Case "1" 'Caller ID Event
intLineNumber = CByte(Mid$(strEvent, 30, 3)) 'Get line number
strCallerIdNumber = Mid$(strEvent, 3, 10) 'Get Caller's phone number
strCallerIdName = Mid$(strEvent, 14, 15) 'Get Caller ID Name
Case "2" 'Line status event
intLineNumber = CByte(Mid$(strEvent, 5, 3)) 'Get Line Number
Select Case Mid$(strEvent, 3, 1) 'Get type of line status event
Case "0" 'On hook/Idle event
strDialed(intLineNumber) = "" ' Clear all data
strCallerIdName = ""
strCallerIdNumber = ""
strStatus = "Idle"
Case "1" 'Ring Start Event
strStatus = "Ringing"
Case "3" 'Off Hook incoming call
strStatus = "Answered"
Case "4"
strStatus = "Outgoing Call" 'Off Hook originating call
End Select
Case "3" 'Serial Number or Watchdog Event
Exit Sub ' Do not process
Case "4" 'Caller ID Event - Out of Area or Private
intLineNumber = CByte(Mid$(strEvent, 5, 3))
strCallerIdNumber = ""
If Mid$(strEvent, 3, 1) = "P" Then 'Private Caller ID, blocked by caller
strCallerIdName = "Private"
Else
strCallerIdName = "Out of Area" 'Caller ID data not available to telco
End If
Case "5" 'DTMF event
intLineNumber = CByte(Mid$(strEvent, 5, 3)) 'Get line number and Save this digit
' with any previous digits received
' on this line
strDialed(intLineNumber) = strDialed(intLineNumber) + Mid$(strEvent, 3, 1)
'Third char. of event is the Digit
Case "8" ' Caller ID Signal Error Event
intLineNumber = CByte(Mid$(strEvent, 5, 3))
strCallerIdName = "Unknown"
End Select