Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / All-Topics

Capture telephone numbers from connected modems using .NET (C#)

4.00/5 (1 vote)
3 Aug 2011Apache 19.6K  
CodeProjectSome applications may require you to capture the telephone numbers of incoming calls.

Some applications may require you to capture the telephone numbers of incoming calls. This can be achieved by some external (maybe native) libraries, i prefer to do it in a fully managed way (as far as possible). I have implemented incoming call detection in C# for analog modem devices, connected through a (virtual) serial port and for CAPI devices (currently only for windows).

Features

  • Supported devices: Analog modem devices with serial connection (modem needs dedicated CallerID support), CAPI devices (more may come)
  • Simple interface
  • Operating systems: Analog modem device are supported on Linux and Windows (maybe more), CAPI devices are supported on Windows only
  • External libraries: CAPI support requires the CAPI.NET library from Mommosoft

Usage

This example shows how to setup an analog modem, a capi device setup is shown in the samples project.
  • First setup the serial communication interface. For more information on using the reflective factory mechanism take a look at the Reflective Factory blog entry

    Code:

    ICommunication serialComm = 
        GenericClassIdentifierFactory.CreateFromClassIdentifierOrType<ICommunication>(
        "simplecomm/general/rs232");
    IDictionary config = new Hashtable();
    config.Add("port_name", "COM8");
    config.Add("baud_rate", 57600);
    serialComm.SetupCommunication(config);
  • The next step is to setup the telecom interface.

    Code:

    ITelecom t = 
        GenericClassIdentifierFactory.CreateFromClassIdentifierOrType<ITelecom>(
        "telecom/general/atz");
    t.IncomingCall += new TelecomIncomingCallDelegate(_IncomingCall);
    
    //Initialize the incoming-call provider with its default parameters
    IDictionary modemConfig = new Hashtable();
    modemConfig.Add("TransmitCommandTimeout", 5000);
    t.Initialize(serialComm, modemConfig);

Source Code

Check out the code at

Code:

git clone git://github.com/deveck/Deveck.Utils.git
Run the samples to see how it works, the telecom devices are located at

Code:

Deveck.Utils/Devices/Telecom

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0