Raspberry Pi, JCblock and Trendnet TFM 561U. Dosen't seem to work - linux

The dev suggested to ask here to get more help.
This is what is happening, I bought a Raspberry Pi (second one, I know how to handle them, and I'm used to apt and ssh) and a Trendnet TFM561U modem, downloaded NOOBS, did the initial setup with an extra in the shape of Webmin. So far aside from Webmin, it's a vanilla Raspbian. I then downloaded JCblock ( http://sourceforge.net/projects/jcblock/ ) and following the instructions here http://weeklytechforum.com/2013/03/28/block-unwanted-calls-with-a-raspberry-pi/ I edited the files that needed editing and finally compiled. I found out what serial port the modem was using (same as the guide! cool) and finally proceeded to test it. That's where the trouble started.
The differences between me and the guide is that I'm in Italy, so the dev of JCblock made me edit the source with a few extra lines of code to talk to the modem... now it's a great time to point out that while I can edit code and recompile it, this is C and I absolutly have no clue about it, knowing just some basics from Pascal and a bit of Visual Basic, so in the end I'm editing the source blindly, just guessing where things need to go. Anyway the edits are to send the Country Code command: AT+GCI=59\r and Caller ID command: AT+VCID=1\r but we do not seem to be geting caller ID data from the modem.
What I'm expecting to see: I call with my cellphone (and that number is in the blacklist) the Raspberry doesn't make the phone ring, or in case of wrong configuration of the blacklist I get some output that will show a call not filtered.
What I get: the phone rings, the modem data light flashes, the program dosen't output anything.
Any help will be appreciated, thanks.
EDIT:
So, I went ahead and used NCID to see what would happen.
As it generates a cornucopia of data, I think it can be useful
Started: 10/27/2014 22:24:54
Server: ncidd (NCID) 1.0
API: 1.0 Feature Set 1 2 3 4
Command line: ncidd
-Dv3
Logfile: /var/log/ncidd.log
Processed config file: /etc/ncid/ncidd.conf
Verbose level: 3
Configured to send 'cidlog' to clients.
Configured to send 'cidinfo' to clients.
Helper tools:
/usr/bin/cidupdate
/usr/bin/ncidutil
Processed alias file: /etc/ncid/ncidd.alias
Alias Table:
Number of Entries: 1
Leading 1 from a call required in an alias definition
Calls in the blacklist file will be terminated
Processed blacklist file: /etc/ncid/ncidd.blacklist
Blacklist Table:
Number of Entries: 12
Calls in the whitelist file will not be terminated
Processed whitelist file: /etc/ncid/ncidd.whitelist
Whitelist Table:
Number of Entries: 0
CID logfile: /var/log/cidcall.log
CID logfile maximum size: 110000 bytes
Data logfile not present: /var/log/ciddata.log
Maximum number of clients/gateways: 25
Telephone Line Identifier: -
TTY port opened: /dev/ttyACM0
TTY port speed: 19200
TTY lock file: /var/lock/LCK..ttyACM0
TTY port control signals enabled
CallerID from AT Modem and optional gateways
Handles modem calls without Caller ID
Sent Modem 20 of 20 characters:
AT Z S0=0 E1 V1 Q0
Modem response: 26 characters in 1 read:
AT Z S0=0 E1 V1 Q0
OK
Try 1 to init modem: return = 0.
Modem initialized.
Sent Modem 6 of 6 characters:
ATI3
Modem response: 39 characters in 1 read:
ATI3
CX93001-EIS_V0.2002-V92
OK
Sent Modem 9 of 9 characters:
AT+GCI?
Modem response: 27 characters in 1 read:
AT+GCI?
+GCI: 59
OK
Sent Modem 13 of 13 characters:
AT+FCLASS=?
Modem response: 32 characters in 1 read:
AT+FCLASS=?
0,1,1.0,8
OK
Sent Modem 11 of 11 characters:
AT+VCID=1
Modem response: 17 characters in 1 read:
AT+VCID=1
OK
Modem set for CallerID.
Hangup option set to hangup on a blacklisted call
Modem used for CID and to terminate calls
Network Port: 3333
Debug Mode
Not using PID file, there was no '-P' option.
Modem is fd 4
NCID connection socket is sd 5 pos 1
RING
CIDINFO: *LINE*POTS*RING*1*TIME*22:25:21*
CIDINFO: *LINE*POTS*RING*0*TIME*22:25:33*
What I can tell from this, is that it should be properly set up to hang up for a blacklisted number (my cellphone, for testing purposes) and that no caller id gets to the software. About that, it's important to point out how we have a mess of different phones (make, model, cordless, wired...) at home, and all of them do show 1 missed call from me. So at least I can confirm that the caller id is being sent.

I looked on Trendnet TFM561U description page and Amazon for this modem and didn't see "caller ID" in the description.
Your modem looks like it has Caller ID because its response to the activate caller ID command is "OK":
AT+VCID=1
OK
But looking at
Testing Modem Caller ID Support with HyperTerminal (or Putty) page
However, if, in step 8), the modem responded with "OK", then you probably have the correct string. In this case, either your phone line does not have caller id enabled (this can be tested with a hardware caller id device), or the modem does not support caller id. The latter is possible even if, in step 8), the modem responded with "OK", since many modems use the same firmware regardless of whether the modem contains the appropriate caller id hardware. In other words, many modems don't know whether they have caller id support!
I would say return your modem and get one that has "caller ID" in the description.

Related

Receiving OTP SMS Via AT+CMGL Command (e.g. Whatsapp)

I'm new to GSM AT Commands and I'm using ZTE MF190S USB 3G USB Modem with Modem Nodejs Module also tried with MS Hyperterminal.
The problem I'm facing that when I receive SMS using AT+CMGL="ALL" from Whatsapp (as example) I got in sender number field 81084326797126204 which is an invalid phone number and should be "Whatsapp" instead although the manufacture's software is showing message from Whatsapp normally.
Note: I tried to decode it as a Hexadecimal string but not done.
> AT+CSCS="GSM"
> AT+CPMS="ME"
> AT+CMGL="ALL"
//Result
+CMGL: 0,"REC UNREAD","81084326797126204",,"20/05/30,14:53:55+08"
FEFF000000000000000000000000000000000000020
As described in this link
+CMGL: index,message_status,address,[address_text],[service_center_time_stamp][,address_type,sms_message_body_length]sms_message_body[+CMGL:
...]
The address Field
The third field of the information response of the +CMGL AT command,
address, is a string that contains the address/phone number stored in
the SMS message header. If the SMS message read is an incoming SMS
message, the address field contains the originator address. If the SMS
message read is an outgoing SMS message, the address field contains
the recipient address. Usually the address field value is a phone
number formatted using the typical ISDN / telephony numbering plan
(ITU E.164/E.163). For example, "+85291234567".
The address_text Field
The fourth field of the information response of the +CMGL AT command,
address_text, is a string that contains the text associated to address
in the phonebook. For example, if the text "Alice" is associated to
the phone number "91234567" in the phonebook, address_text will be
"Alice". The AT command +CSCS (command name in text: Select TE
Character Set) can be used to specify the character set for displaying
address_text. Note that address_text is an optional field. Some
GSM/GPRS modems and mobile phones (examples: most Nokia products,
including my Nokia 6021) leave this field empty.
How can I identify the message is from Whatsapp or any other services providers names?
You wrote
The fourth field of the information response of the +CMGL AT command, address_text, is a string that contains the text associated to address in the phonebook
If your device used to recognize that number, it probably was in one of device's phonebooks, and maybe it got deleted.
What you can try to do is to store again the number using AT+CPBW command:
AT+CPBW=[<index>][,<number>[,<type>[,<text>]]]
where
index is the record position in the phonebook. If omitted the record is stored in the first free position
number is the number to be stored in phonebook, in string format
type is the number type; 129 for national scheme, 145 for international scheme
text is the name of the entry in the phonebook
So, in your case:
AT+CPBW=,"81084326797126204",129,"WhatsApp"
And after it you should see the name appearing in +CGML list. You might need a device reboot after the PB write in order to see the change making effect.
The change is done in the current phonebook, usually the SIM card. It can be queried with command AT+CPBS? (it also allows to change it; see the guide for further explanation).
I suggest exploring the content of every phonebook, in order to discover any device (and SIM) default contents. The command to read phonebook entries is **AT+CPBR**. Providing
AT+CPBR=1,N
all index between 1 and N are shown. If you set N to the size of the phonebook, you can list all the entries in it.

How to identify identical USB dongles connected at the same time to an USBhub

I have an USBhub (D-Link DUB-H7) connected to my laptop with Windows 10. Connected to the hub are 4 identical PEAK dongles to talk to a CANbus. Now, my problem is to programmatically identify these 4 seperate dongles and knowing which one is which. The dongles are fixed in the hub.
To start I downloaded and installed USBDeview to view my devices. In the program I can see my 4 PCAN-USB dongles and I can see that their Instance ID are different. That's good, now I have my identifier. However, once I try to get the ID's with Python things aren't looking good. This is my following test program:
import win32com.client
wmi = win32com.client.GetObject("winmgmts:")
input("Connect the hub")
dongle_list = [(usb.name, usb.DeviceID) for usb in wmi.InstancesOf("Win32_USBHub")]
input("Disconnect the hub")
nod_list = [(usb.name, usb.DeviceID) for usb in wmi.InstancesOf("Win32_USBHub")]
diff = list(set(dongle_list) - set(nod_list))
for d in diff:
print(d)
Running this gives me only 2 new usb devices and the ID's point to the USBhub rather than the dongles connected to the hub. I also tried with wmi.InstancesOf("CIM_USBDevice") but the result stays the same.
('Generic USB Hub', 'USB\\VID_05E3&PID_0608\\5&4A43CD6&0&4')
('Generic USB Hub', 'USB\\VID_05E3&PID_0608\\6&9EBFB9C&0&4')
So how can I retrieve the usb information of the devices connected to the USBhub using Python or powershell/cmd invoked by Python?
Another route I was thinking I could take is by using port identifiers. If I disconnect a dongle I can see that it was connected to Port_#0001.Hub_#000x, where is x is a positive integer. So maybe I could poll the port to see if the dongle is connected and then I too know which one is which (dongles are fixed in the hub). Although I think that using the Instance ID is more foolproof.
I ended up creating a powershell command and invoke that using Python. I noticed however that the InstanceID's are hardware addresses of the the USBhub and not the dongles.
I also noticed that the dongles sometimes switch their addresses related on how they were connected. So I also needed to disable them and enable them again in the order I want.
This is what I have now:
poll_cmd = """
$ret = (Get-PnpDevice | ? {($_.description -like "*pcan*") -and ($_.status -eq "ok")} | sort instanceid).instanceid;
$ret | % {Disable-PnpDevice $_ -Confirm:$False};
$ret | % {Start-Sleep -Seconds 1; Enable-PnpDevice $_ -Confirm:$False};
$ret
"""
usbs = (
subprocess.check_output(["powershell.exe", poll_cmd])
.decode()
.strip()
.split("\r\n")
)
usbs holds the list of usb dongles I'm interested in.
However this gave me one more problem: UAC. I need admin rights to enable the usbs. And used the top answer from Request UAC elevation from within a Python script? to give my program admin rights.

How to use HM-10/HC-08 in AT command mode?

I have bought HM-10 but its name is showing HC-08. I want to know how will i use it in AT mode. I have arduino mega. I am using HC-05 in AT mode by setting 34th(key) pin high.
For HM-10 or HC-08 there are several AT commands lists (access via serial).
For example for the HC-08:
AT responds OK
AT + BAUDx responds with OKn where x is 1 - n is 1200, 2 - 2400, 3 -
4800, 4 - 9600 (default), 5 - 19200, 6 - 38400, 7 - 57600, 8 -
115200.
Note: module must be reset after power-on for the new serial port baud rate to take effect.
AT + NAME name responds OKsetname - name is the Bluetooth device name to be set and must be 13 characters or fewer. Retained across power offs.
Note: module must be reset after power-on for the new device name to take effect.
You can find complete lists if you search to "HC-08 AT commands list" in the web.

alsa: How to programmatically find if a device is busy/in use using it name and without opening it

We have a Linux device which has a speaker and MIC devices. These devices are shared among different modules - example a VOIP call can use speaker, a hazard Warning system can use speaker, a Voice prompt can use a speaker etc:
There seems to be a function in ALSA which uses pcm to provide the status.
int snd_pcm_status (snd_pcm_t * pcm, snd_pcm_status_t * status)
However the *pcm is returned by snd_pcm_open. We do not want to open the device as we would like to know the status of the device using its "name"
Alsa API is here
How can we check if a resource/device is busy without opening it and using its name?
The same information for playback stream X of device Y on card Z is available in the file /proc/asound/cardZ/pcmYp/subX/status; when the device is not open, it just says "closed".
Please note that you cannot use this information to decide if you can open the device, because some other process could have openend it just after you've read this information. The only way to check if you can open it is to actually try.
Though it requires /dev/dsp, this seems to work:
#!/bin/dash
## If the speaker is not used by any, returns 0, and prints "free"
## Otherwise, returns 1 and prints "not free"
iExit (){
trap '' 0
exit $1
}
iCatch (){
# The speaker is already in use
echo not free
iExit 1
}
trap iCatch 0
{
exec 3>&1 1>/dev/dsp
# If the execution reaches here, the speaker is not used by any
# Otherwise, it's catched by iCatch
exec 1>&3
echo free
iExit 0
} 2>/dev/null
Without PulseAudio, it seems on some PC only one output is accepted at one time; on others simultaneous playbacks are allowed. But even in the latter case, the above code works.
NB: The above code does not work with bash; for bash, simply use if/else rather than trap.
NB 2: /dev/dsp may be lacking depending on the kernel configuration.

Linux Asterisk script for test call

I need to measure the MOS and quality of the VOIP service in a network. I want to create a script that simulates calls and then measure the networks metrics.
I'm using asterisk.
Do you have any suggestion about how to script and schedulate test calls with asterisk?
I would like to make calls of different duration maybe using some avi files.
Obviously I need to automate both outgoing call and automatic answer to that outgoing calls.
I would suggest using Asterisk Call Files
Create a file name /tmp/example.call such as:
Channel: SIP/peerdevice/1234
Application: Playback
Data: silence/1&tt-weasels
And then copy that file and move it into the asterisk outgoing spool, such as:
cp /tmp/example.call /tmp/example.call.new
mv /tmp/example.call.new /var/spool/asterisk/outgoing
You'll notice at the Asterisk CLI it will originate a new call.
You can make another asterisk box answer the call automatically by saying to answer it in the dialplan, e.g. If you have another device SIP/peerdevice, and you're dialing 1234 per my example, in your dialplan:
[somecontext]
exten => 1234,1,Answer()
same => n,Noop(Example call inbound)
same => n,Playback(hello-world)
same => n,Hangup()
And you could create multiple extensions to do what you like to vary the behavior of the call.
You can also use the originate command, such as:
ast*CLI> channel originate SIP/755XXXXX#sip-outbound extension s#context_name
Which can also be issued from a shell as:
[user#host]$ asterisk -rx 'channel originate SIP/755XXXXX#sip-outbound extension s#context_name'
SIP/755XXXXX#sip-outbound = Is what device to use when dialing out so this could be IAX.,SIP,DAHDI following a slash and phone number
extension = Is required for the command. You may also use application followed by an Asterisk application, a la channel originate SIP/device/1234 application playback tt-monkeys which would playback a sound file.
s = This is what extension to send to within the context specified below
#context_name = Which context to send to in extensions.conf
More information available in this Asterisk guide
In case you will call a asterisk extension:
asterisk -rx "console dial extension#context"

Resources