PC Phone Integration

Asked

Viewed 532 times

1

We make:

StringConexao ="ATDT"+numeroTelefone+ #13#10;

And we do

  WriteFile(
              hCommFile,
              PChar(StringConexao)[0],
              Length(s),
              NumberWritten,
              nil);

And the magic is done! And the modem calls a number.

Now I need to do the opposite:

Upon receiving a call, YES, my modem is receiving calls when someone calls my phone, what the command, and in what situation call the command to know the phone number that is calling me?

If

  WriteFile()

You are responsible for making/receiving the calls, so what parameter do I take the call number from?

So,

At the address:

http://support.usr.com/support/3cxm756/3cxm756-portuguese-ug/atcoms.htm

On the last line, you have the last 2 commands that are:

AT&Zn=s             Armazenar número telefônico

AT&Zn?              Exibir número telefônico

How to capture the phone number in the structure of my application?

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, spBina;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Memo1: TMemo;
    RadioButton1: TRadioButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;


var
 Form1: TForm1;
 hCommFile: THandle;
 Status: LongBool;


NumberWritten: DWORD;
Buf : array[0..1023] of Byte;
s :string;

implementation

uses ConvUtils;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
//Testa os valores necessários
    begin

     //Abre a porta de comunicação
     s:='COM3';
     hCommFile := CreateFile (
                             PChar(s),
                             GENERIC_WRITE,
                             0, // não compartilhado
                             nil, // sem segurança
                             OPEN_EXISTING,
                             FILE_ATTRIBUTE_NORMAL,
                             0);

     // Verifica a abertura da porta
    if hCommFile = INVALID_HANDLE_VALUE then

        begin
         memo1.lines.clear;
         memo1.lines.add('Não foi possível abrir a porta selecionada.');
         memo1.lines.add('Discagem não efetuada');
         CloseHandle(hCommFile);
        end

    else

        begin

         memo1.lines.clear;memo1.lines.add('Discando...');

         //Cria a string de comando
        if radiobutton1.checked then
         s:='ATDT'
        else
         s:='ATDP';

         s := s + Edit1.Text + #13#10;

         memo1.lines.add(s);

         //Envia a String de Comando
         NumberWritten:=0;

          WriteFile(
                        hCommFile,
                        PChar(s)[0],
                        Length(s),
                        NumberWritten,
                        nil);

         memo1.lines.add('Aguardando Atendimento ...');      
         MessageDlg('Retire o telefone do gancho e clique OK para desligar o modem',mtInformation,[mbok], 0);

         //Desconecta a ligação
         WriteFile(hCommFile,'ATH',5,NumberWritten, nil);

         //Fecha a porta de comunicação
         CloseHandle(hCommFile);memo1.lines.add('Modem Desconectado.'#13#10);
        end;
end;
end;
end.

I found out that by doing:

s := 'ATA+ #13#10;

You get the call: But along comes the modem noise And I still can’t get the phone number

  • You want to do an IVR or something?

  • So the goal is that when you get a call, the system might be able to identify the number that’s coming in. Then, take this number and search the database to know if there is this number registered and return the registration data with that number!

  • Making an app that receives phone calls is something quite complex. If you’ve already managed to get the call, figuring out the number should be the easy part. If that’s the case, then edit the question to explain what specific difficulty you had.

  • What I need is to pick up the number on the phone line! At least one north to search. The system is quiet to do! Already the capture of the number........

  • 1

    This is a hardware problem, not a programming problem (outside the scope of the site). If you are in Brazil, you need a DTMF converter to convert to your pc. Abroad, fax-modems even work in some cases, because there the "BINA" is FSK. Here in Brazil is DTMF

  • 1

    Yes, is this DTMF converter a device that sits between the PC and the middle of the line? If it is, after this connection, any Delphi components can already identify? Which component?

  • @Carlosrocha add these FSK and DTMF details to the question and it can be reopened.

  • @Renan 1, sorry, I didn’t quite understand what you said!

  • Ready! I edited!

Show 4 more comments

1 answer

0

There’s a lot going on together, let’s sort things out:

1 - AT commands

What you’re doing is sending commands AT to the serial port modem. You’re not actually doing anything, you’re giving commands for your hardware to do something for you.

The AT commands are amazing, there is a huge list of commands available, but a very annoying part is that the hardware doesn’t usually implement all of the available command set commands.

This is not to say that your hardware is good or bad by implementing more commands or less commands, in fact there are commands for all kinds of things, from the basic that is to dial a number (is what you are using), until checking battery level of the device, check the current state of some internal hardware logger, create a GPRS connection, list available networks, establish a GPRS connection, send and receive SMS, etc. It makes no sense to implement the set of commands that are specific to SMS on a Dial Up modem from a PC, just as it makes no sense to implement commands referring to phone connection on a 3G USB modem.

Even on similar devices such as 3G USB modems (I’ll talk more about 3G USB modem because I studied them more when I implemented my class and sending and receiving SMS by Delphi using AT commands), you don’t have the same set of commands implemented on all equipment, This is because it depends on hardware support and manufacturer implementation (simpler hardware - that is, cheap hardware - has more limited resources than more complete hardware. This is quite understandable). To overcome this you need to implement a routine that checks the availability of the commands on the hardware you are using and treat the type of support you will give, or whether your software will work with the hardware in question. In my case with SMS by 3G modem I had a lot of problem in the beginning because at home I used a device, but customers used different other and the application broke directly.

See, you will need to study the set of AT commands and go testing the commands with your hardware. But I’ll tell you, if it’s a "win modem" modem board, you’ll have a very, very limited feature set. Back in the early days of the Internet ('90s, I lived it) the modems were full connection devices, but over time the Chinese were removing the less used resources to cheapen the hardware until it left only and exclusively what was needed for a dial-up internet connection (actually the winmodem is not even a modem, but nor will I go into this subject here).

If you don’t have a winmodem it’s a big plus, but as I said before, the features have been taken out of the hardware slowly until there’s nothing left, then the features your devices have will depend on which point it’s in this scrapping process that there was.

Here are some links about AT commands:

https://www.espressif.com/sites/default/files/documentation/4a-esp8266_at_instruction_set_en.pdf

http://michaelgellis.tripod.com/modem.html

http://www.mt-system.ru/sites/default/files/simcom_sim5320_atc_en_v1.23.pdf

2-Call Identification and Answering Calls

I don’t know if you’ve ever studied this part of caller identification, but the number information that’s calling you comes on a DTMF train before the first ring of the phone. The identification of the call crucially two-factor:

To - There must be an active caller identification service on your phone line, that is, if the carrier does not send you the DTMF train before the first ring, you have no way of knowing who is calling you. In the past this was a service charged separately, but nowadays it is much more common and many operators do not even charge more for it, but it is good to check if you have this service available, if it is active and especially if it is working properly. Do the test by connecting on the line a phone that has the call identification feature (and you’re sure it’s working kkk) and call from your mobile phone to the line in question.

B - Your modem needs to decode the DTMF train that the operator sends. I personally find this part very difficult, not that I am rooting against it, but it is that the modem have been losing resources (remember I mentioned it above?) and this was one of the first resources to be removed, because it does not interfere in anything in the dial connection. Right now if you’re lucky enough to have a modem that hasn’t been capped in this feature, there’s another problem that’s pretty complicated: the Brazilian call identification pattern. The modems are not manufactured in Brazil, are usually manufactured in China and follow the standards of the north american telecommunications market. There is not only one type of call identification, normally we use here in Brazil the DTMF standard, but there are other different standards and the most common in the North American market is the FSK. If you have a modem that has the call identification feature, but does not accept the same pattern as your phone line, you will not succeed in using the feature. But as things have changed in recent years, nowadays we have operators in Brazil that use the FSK, so it might work. See, if you’re going to analyze this part is almost a Russian roulette, it has several variables on the way.

If your modem can decode the call ID signal from your line, then you’ll need to use the specific AT command to ask the modem for the number it received (You remember that whoever does the dirty work is the modem, you use the AT commands to interface with it). I don’t know what the command is, but consulting the documentation you think this.

To answer the call you will need to monitor the status of the modem time in time (every 2 seconds, for example) sending an AT command that will return if the line is ringing and if the answer is yes, you will have to send an AT command to answer the call. After answering you will need to put an audio on the line, right? How will you do it? I honestly don’t know, I never got that far. kkk

With my experience in electronics and telecom (I worked almost 10 years on this), I know you could inject an audio in the line using a capacitor coupling, through a 1 microfarad capacitor, the modem guarantees the connection of the line until you give the AT command to disconnect the connection. But this already goes into hardware and depending on how you do it there is a great chance to make noise on the phone call. I won’t extend myself to that aspect.

3 - Caller identifier separately

I don’t know exactly how you intend to treat the call after identifying it and answering it, but if I consider that you have a good plan for that part, an option to deviate from the modem’s call identification problem is to have a call identification device attached to the part on the line and read from it the number of who is calling you and, depending on the features it offers, know for it if there is a call ringing (It may be that your modem does not support knowing if the phone line is ringing).

There are market options ready, but I find them very expensive. Anyway you can give a check:

https://lista.mercadolivre.com.br/identificador-de-chamadas-para-pc-usb

If you are not willing to pay all that money, one option is to venture out with the Arduino and build your own caller identifier, you will see that the circuit is very simple, basically it is a CI that does everything and you just need to read it. Here are some links that talk about the theme:

http://labdegaragem.com/forum/topics/bina-com-dtmf

http://labdegaragem.com/forum/topics/dtmf-com-arduino

I have more things I could talk about, but I’m running out of time now (I wrote a text, huh? It’s just that I get carried away with this theme kkk), but if there’s anything else you need from me just comment that I come back and we continue.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.