USB Modem as a phone caller ID filter...

All kinds of 'OS' scripts

Moderator: leecollings

Post Reply
lost
Posts: 616
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

USB Modem as a phone caller ID filter...

Post by lost »

Hello,

I have re-used an old POTS 56K (hardware) analog modem as a caller ID filtering device: Far too many unsolicited calls (publicity, sellers...)!

The idea is to configure the modem (basic config, no auto-answer etc, using modems "AT" command set) connected on my internet modem that also acts as an IP phone gateway (those all-in-one french "internet boxes"), using it's phone line RJ11 (unused, the modem also does DECT, so phones are wirelessly connected) connector.

When the phone rings, before the 2nd ring, provided CID (caller ID) reporting is setup ("AT+VCID=1"), I get lines of data on the serial ttyUSB of the modem:

DATE = 0625
TIME = 1133
NMBR = 06XXXXXXXX
NAME = ...

Good point: The name info is only given for my phone registered numbers, so filtering family and friends is an easy job!

For callers with no NAME info, I call a www.shouldianswer.com page (french version: http://www.doisjerepondre.fr/numero-de-telephone/NMBR) to get a phone number classification score that can be unknown/neutral/negative.

No public API for this service, had to parse the page using python beautfifulsoup module for the interesting part of the response that can be:
[<div class="scoreContainer">\n<div class="score unknown"></div>\n</div>]
[<div class="scoreContainer">\n<div class="score neutral"></div>\n</div>]
[<div class="scoreContainer">\n<div class="score negative"></div>\n</div>]

If negative, modem answers ('ATA' in data mode, 'ATS1' in voice mode) then hangs up after 1s ('ATH'/'ATS0' respectively): Phone only rings once and I'm quiet again!

I can say this mostly works... Had to cope with a few modem bugs (to set the modem in voice mode, to avoid a nice old analog modem sound while trying to sync with remote!!!), by the way, but there is one remaining problem I could not solve for now:

Sometimes, modem shows rings ('RING' string in data mode, '<DLE>R' in voice mode) but no CID info. This may probably happen (private calls?), but problem is my phone did retrieve the information, so the modem really misses some CIDs!

In the infinite loop that receive/process modem data, I had some ring nb checks (to be able to separate call attempts, answered by my phones or not) using 'ATS1?' command: This looks to disturb CID read if the command is sent before all the CID lines are received. So I count rings in the loop and used a timeout mechanism instead. Now, no more possible writes before full CID is read to avoid killing it for current call attempt!

Less misses... But still have some! Maybe 20/30%...

=> The question is: Do someone on the forum have experience with raw modem use tips and tricks?

As this may be modem/hardware dependent, mine is branded as Longshine LCS-8151C1 and its Conexant based with this FW version (can be read using 'ATI3' command):
"CX93001-EIS_V0.2013-V92"

As said here-upper, this modem looks a bit buggy: For instance, it supports voice mode but it's not configurable (nor advertised, with 8 in the response to 'AT+FCLASS=?' command) until a 1st call is answered in data mode!

Tried different setup (on top of windows driver extracted .inf file that shows the init strings used by the supposed-to-work driver!), no solution to this. So this is done the way it proved to work (after 1st answered/filtered call).

An AT command set reference can be found here:
https://arcelect.com/IML56_modem_AT_commands.pdf

Thanks!
lost
Posts: 616
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: USB Modem as a phone caller ID filter...

Post by lost »

Small update on this remaining issue:

-Modem is in autobaud mode by default and may need a few reads for syncing again if sleeping... Enforcing a fixed baud rate does not solve still missed CIDs issue even if I 1st believed this was the case
-Using raw CID mode (AT+VCID=2) and decoding the hex frame (MDMF format) on the host does not solve issue as well: I believed that if the checksum was bad, decode may not be done&sent by modem but there is no raw frame at all.

Still a mystery to me and tips still welcome!
lost
Posts: 616
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: USB Modem as a phone caller ID filter...

Post by lost »

If everyone is someday using conexant buggy USB voice modems for caller ID filtering on fixed phone lines, here are a few (final) tips:
-To avoid as much as possible CID miss issues, no commands must make their way if a call is in progress (rings) except answer/hang (ATA/ATH in data mode or AT+VLS=1 or 0 in voice mode).
-Default timeouts should be tuned.
-Setting voice mode after soft reset (ATZ) may need a small ATA/ATH hack, with carrier detect TMO tuned, before whole init (useful strings may be found in windows driver INF file) with voice mode (AT+FCLASS=8).

If I set logging to debug, here is the full log of reset then init commands (all that is AT prefixed) for CID use case in voice mode for this modem that self identifies as CX93001-EIS_V0.2013-V92:

Code: Select all

10:17:52,679 - DEBUG - AT
10:17:52,680 - DEBUG - OK
10:17:52,680 - DEBUG - Response OK
10:17:52,680 - INFO - Modem OK on /dev/ttyModem
10:17:52,733 - DEBUG - ATZ
10:17:52,734 - DEBUG - OK
10:17:52,734 - DEBUG - Response OK
10:17:52,737 - DEBUG - ATS7=2                                              <- Here starts post ATZ hack to allow voice mode set later
10:17:52,738 - DEBUG - OK
10:17:52,738 - DEBUG - Response OK
10:17:53,741 - DEBUG - ATA
10:17:54,743 - DEBUG -
10:17:55,745 - DEBUG -
10:17:56,747 - DEBUG -
10:17:57,749 - DEBUG -
10:17:58,515 - DEBUG -
10:17:58,517 - DEBUG - NO CARRIER
10:17:58,517 - DEBUG - Response OK
10:17:58,520 - DEBUG - ATH
10:17:58,521 - DEBUG - OK
10:17:58,522 - DEBUG - Response OK                                      <- Here ends post ATZ hack to allow voice mode set later
10:17:58,527 - DEBUG - AT+IPR=115200
10:17:58,529 - DEBUG - OK
10:17:58,529 - DEBUG - Response OK
10:17:58,530 - INFO - Modem set to (0=autobaud) baudrate=115200
10:17:58,533 - DEBUG - ATI3
10:17:58,536 - DEBUG - CX93001-EIS_V0.2013-V92
10:17:58,537 - DEBUG -
10:17:58,538 - DEBUG - OK
10:17:58,539 - DEBUG - Response OK
10:17:58,552 - DEBUG - AT&F+IBC=0,0,0,,,,,0;+PCW=2;+PMH=1
10:17:58,554 - DEBUG - OK
10:17:58,554 - DEBUG - Response OK
10:17:58,566 - DEBUG - ATE1V1S0=0&C1&D2+MR=2;+DR=1;+ER=1;W2
10:17:58,568 - DEBUG - OK
10:17:58,568 - DEBUG - Response OK
10:17:58,572 - DEBUG - ATS202=1
10:17:58,574 - DEBUG - OK
10:17:58,574 - DEBUG - Response OK
10:17:58,579 - DEBUG - AT-TTE=,,,150
10:17:58,580 - DEBUG - OK
10:17:58,581 - DEBUG - Response OK
10:17:58,585 - DEBUG - ATS7=8
10:17:58,586 - DEBUG - OK
10:17:58,587 - DEBUG - Response OK
10:17:58,590 - DEBUG - ATS9=4
10:17:58,591 - DEBUG - OK
10:17:58,592 - DEBUG - Response OK
10:17:58,595 - DEBUG - ATS10=6
10:17:58,597 - DEBUG - OK
10:17:58,597 - DEBUG - Response OK
10:17:58,602 - DEBUG - ATS24=0
10:17:58,603 - DEBUG - OK
10:17:58,603 - DEBUG - Response OK
10:17:58,608 - DEBUG - AT+FCLASS=8
10:17:58,610 - DEBUG - OK
10:17:58,610 - DEBUG - Response OK
10:17:58,615 - DEBUG - AT+VCID=2
10:17:58,616 - DEBUG - OK
10:17:58,616 - DEBUG - Response OK
10:17:58,621 - DEBUG - AT+FCLASS?
10:17:58,622 - DEBUG - 8
10:17:58,624 - DEBUG - OK
10:17:58,624 - DEBUG - Response OK
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests