Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending USSD does not work #29

Open
marcogaio opened this issue Apr 18, 2017 · 13 comments
Open

Sending USSD does not work #29

marcogaio opened this issue Apr 18, 2017 · 13 comments

Comments

@marcogaio
Copy link

My operator (Wind, Italy) use extensively USSD, and worked in chan dongle original version, with asterisk 1.6/1.8.

Now (asterisk 11) does not work anymore. Example:
eraldo*CLI> dongle ussd dongle0 *123# [dongle0] USSD queued for send with id 0x7f659401b790 [Apr 18 00:07:43] ERROR[3452]: at_response.c:517 at_response_error: [dongle0] Error sending USSD 0x7f659401b790

@wdoekes
Copy link
Owner

wdoekes commented Apr 23, 2017

That particular error message gives hardly any info.

Could you get verbose+debug level (>=10) output? Perhaps it provides more clues.

@marcogaio
Copy link
Author

marcogaio commented Apr 23, 2017

I was just on verbose mode:

eraldo*CLI> core set debug 999
Core debug was OFF and is now 999.

eraldo*CLI> core set verbose 999
Console verbose was OFF and is now 999.

eraldo*CLI> dongle ussd dongle0 *123#
[dongle0] USSD queued for send with id 0x7fdcb401b790
    -- [dongle0] Error sending USSD 0x7fdcb401b790
[Apr 23 22:29:52] ERROR[3664]: at_response.c:517 at_response_error: [dongle0] Error sending USSD 0x7fdcb401b790

@wdoekes
Copy link
Owner

wdoekes commented Apr 26, 2017

Are you sure you're the getting debug log in your console? I see the verbose logs, but I think there might be debug logs as well.

Check logger.conf please; perhaps the debug log is routed to a file instead.

@marcogaio
Copy link
Author

marcogaio commented Apr 26, 2017

Ahem, sorry... effectively i've disabled debug output. ;-(

[dongle0] USSD queued for send with id 0x7f75100157d0
[Apr 26 10:51:53] DEBUG[8352]: at_queue.c:126 at_queue_add: [dongle0] insert task with 1 commands begin with 'AT+CUSD' expected response 'OK' at tail of queue
[Apr 26 10:51:53] DEBUG[8352]: at_queue.c:246 at_queue_run: [dongle0] write command 'AT+CUSD' expected response 'OK' length 26
]Apr 26 10:51:53] DEBUG[8352]: at_queue.c:191 at_write: [dongle0] [AT+CUSD=1,"AA986C3602",15
[Apr 26 10:51:53] DEBUG[8340]: at_read.c:80 at_read: [dongle0] receive 9 byte, used 9, free 2039, read 0, write 9
[Apr 26 10:51:53] DEBUG[8340]: at_read.c:95 at_read: [dongle0] [
ERROR
]
    -- [dongle0] Error sending USSD 0x7f75100157d0
[Apr 26 10:51:53] ERROR[8340]: at_response.c:517 at_response_error: [dongle0] Error sending USSD 0x7f75100157d0
[Apr 26 10:51:53] DEBUG[8340]: at_queue.c:221 at_queue_remove_cmd: [dongle0] remove command 'AT+CUSD' expected response 'OK' real 'ERROR' cmd 1/1 flags 0x00 from queue
[Apr 26 10:51:53] DEBUG[8340]: at_queue.c:69 at_queue_remove: [dongle0] remove task with 1 command(s) begin with 'AT+CUSD' expected response 'OK' from queue

Thanks.

@marcogaio
Copy link
Author

marcogaio commented Jul 23, 2017

Some news on that?
Still i cannot send USSD...

eraldo*CLI> dongle ussd dongle0 *123#
[dongle0] USSD queued for send with id 0x7ff084068400
[Jul 23 14:46:14] DEBUG[25977]: at_queue.c:126 at_queue_add:
    [dongle0] insert task with 1 commands begin with 'AT+CUSD' expected response
    'OK' at tail of queue
[Jul 23 14:46:14] DEBUG[25977]: at_queue.c:246 at_queue_run:
    [dongle0] write command 'AT+CUSD' expected response 'OK' length 26
]Jul 23 14:46:14] DEBUG[25977]: at_queue.c:191 at_write:
    [dongle0] [AT+CUSD=1,"AA986C3602",15
[Jul 23 14:46:14] DEBUG[4505]: at_read.c:80 at_read:
    [dongle0] receive 9 byte, used 9, free 2039, read 0, write 9
[Jul 23 14:46:14] DEBUG[4505]: at_read.c:95 at_read: [dongle0] [
ERROR
]
    -- [dongle0] Error sending USSD 0x7ff084068400
[Jul 23 14:46:14] ERROR[4505]: at_response.c:517 at_response_error:
    [dongle0] Error sending USSD 0x7ff084068400
[Jul 23 14:46:14] DEBUG[4505]: at_queue.c:221 at_queue_remove_cmd:
    [dongle0] remove command 'AT+CUSD' expected response 'OK' real 'ERROR' cmd 1/1 flags 0x00 from queue
[Jul 23 14:46:14] DEBUG[4505]: at_queue.c:69 at_queue_remove:
    [dongle0] remove task with 1 command(s) begin with 'AT+CUSD' expected response
    'OK' from queue

Thanks.

@wdoekes
Copy link
Owner

wdoekes commented Jul 24, 2017

Well. I don't see anything wrong with the command there.

Like you may know, I don't own any GSM devices, so I cannot test any of this. But you can.

See this thread:
https://stackoverflow.com/questions/30125721/how-to-write-a-atcusd-ussd-command-to-support-maximum-handsets

If AT+CUSD=1,"AA986C3602",15 doesn't work, then perhaps:

AT+CUSD=1,"*123#",15
AT+CUSD=1,"*123#",0
AT+CUSD=1,"*123#"
AT+CUSD=0,"*123#"

Or one of the other possibilities featured in the SO post. Possibly in combination with:
https://stackoverflow.com/questions/29730142/error-on-checking-balance-via-ussd/29731461#29731461

Step one would be to find something that does work. When you do, we can look into whether it's feasible to implement.

@wdoekes
Copy link
Owner

wdoekes commented Jul 24, 2017

I suspect that the problematic code is around here:

if (pvt->cusd_use_7bit_encoding)

@marcogaio
Copy link
Author

No, i was not aware that you don't own a GSM dongle. ;-)

It is a bit strange. 'dongle cmd' seems to work:

eraldo*CLI> dongle cmd dongle0 ATI
[dongle0] 'ATI' Command queued for execute
 [dongle0] Got Response for user's command:'Manufacturer: huawei'
[Jul 24 22:28:37] NOTICE[4505]: at_response.c:1737 at_response: [dongle0] Got Response for user's command:'Manufacturer: huawei'
 [dongle0] Got Response for user's command:'OK'
[Jul 24 22:28:37] NOTICE[4505]: at_response.c:1737 at_response: [dongle0] Got Response for user's command:'OK'

But the command (every command in link you suggest) return strange things:

eraldo*CLI> dongle cmd dongle0 AT+CUSD=1,"*123#"
[dongle0] 'AT+CUSD=1,*123#' Command queued for execute
 [dongle0] Got Response for user's command:'ERROR'
[Jul 24 22:28:39] NOTICE[4505]: at_response.c:1737 at_response: [dongle0] Got Response for user's command:'ERROR'
[Jul 24 22:28:39] ERROR[4505]: at_response.c:521 at_response_error: [dongle0] Received 'ERROR' for unhandled command 'USER'S'

So, i've fired up minicom (a serial terminal emulation program) and tried to send command by hand, discovering that:

AT+CSCS="GSM"
AT+CUSD=1,"*123#",15

works as expected.

But still if i try to send command in dongle:

eraldo*CLI> dongle cmd dongle0 AT+CSCS=GSM
[dongle0] 'AT+CSCS=GSM' Command queued for execute
 [dongle0] Got Response for user's command:'ERROR'
[Jul 24 22:41:32] NOTICE[13743]: at_response.c:1737 at_response: [dongle0] Got Response for user's command:'ERROR'
[Jul 24 22:41:32] ERROR[13743]: at_response.c:521 at_response_error: [dongle0] Received 'ERROR' for unhandled command 'USER'S'

I hope i was useful...

@marcogaio
Copy link
Author

Ahem, wrong cut&paste. Clearly, also with quotes:

eraldo*CLI> dongle cmd dongle0 AT+CSCS="GSM"
[dongle0] 'AT+CSCS=GSM' Command queued for execute
 [dongle0] Got Response for user's command:'ERROR'
[Jul 24 22:41:12] NOTICE[13743]: at_response.c:1737 at_response: [dongle0] Got Response for user's command:'ERROR'
[Jul 24 22:41:12] ERROR[13743]: at_response.c:521 at_response_error: [dongle0] Received 'ERROR' for unhandled command 'USER'S'

@wdoekes
Copy link
Owner

wdoekes commented Jul 25, 2017

And what about:

AT+CUSD=1,"*123#",15

without first the AT+CSCS="GSM".

And what make is your dongle? Perhaps it needs to get dropped from list of devices where 7bit is selected:

                                                case CMD_AT_CGMM:
                                                        ast_debug (1, "[%s] Got AT_CGMM data (model info)\n", PVT_ID(pvt));
                                                        return at_response_cgmm (pvt, str);

Does it pass this?

And then here?

        static const char * const seven_bit_modems[] = {
                "E1550",
                "E1750",
                "E160X",
                "E150",
                "E173",
                "E1552",
                "E171",
                "E153",
                "E156B",
                "E1752",
                "E261"
        };

        ast_copy_string (pvt->model, str, sizeof (pvt->model));

        pvt->cusd_use_7bit_encoding = 0;
        pvt->cusd_use_ucs2_decoding = 1;
        for(i = 0; i < ITEMS_OF(seven_bit_modems); ++i)
        {
                if(!strcmp (pvt->model, seven_bit_modems[i]))
                {
                        pvt->cusd_use_7bit_encoding = 1;
                        pvt->cusd_use_ucs2_decoding = 0;

By default 7bit_encoding = 0 (and ucs2_decoding=1), but according to your encoded message it is set to 1.

So, unless it's one of those in the list, the encoding should be set to 7bit (no-hex).

        if (pvt->cusd_use_7bit_encoding)
                cusd_encoding = STR_ENCODING_7BIT_HEX_PAD_0;
        else if (pvt->use_ucs2_encoding)
                cusd_encoding = STR_ENCODING_UCS2_HEX;
        else
                cusd_encoding = STR_ENCODING_7BIT;

Please confirm by providing the relevant debug logs of the dongle initialization.

@marcogaio
Copy link
Author

marcogaio commented Jul 26, 2017

Yes, i've tried
AT+CUSD=1,"*123#",15
without
AT+CSCS="GSM"
and does not work.

But you address me in the right way... i've had in the past trouble with SMS encodings, and someone (still you? i don't remember...) suggest to add my modem (a K3765) to seven_bit_modems[], and was still here.

I've removed my modem from 7bit ones, and now USSD works as expected!

Thanks and sorry!!!

@magcks
Copy link

magcks commented Feb 19, 2020

According to 3GPP 27.007 and 3GPP 23.038, the DCS (always "15", "00001111" in binary in our case) means:
bit 7..4 = 0000: "Language using the GSM 7 bit default alphabet"
bit 3..0 = 1111: "Language unspecified"

(also see https://stackoverflow.com/a/30134921)

Thus, if I understood correctly, every Modem is a "USSD 7 bit modem" (if we set DCS to 15...). UCS-2 takes value 01001000 = 72. This should also fix #38 and bg111#231.

I assumed this in my not yet published upcoming PR, as I had to rewrite the CUSD parts because the character encoding code changed. Can somebody confirm this assumption?

@standardgbg
Copy link

standardgbg commented Oct 1, 2020

Hi,

Are there any solution to this?
I've tried a lot of USSD commands but still get
"at_response.c:1386 at_response_cusd: [dongle0] Error decode CUSD: "
followed bu the correct that I can decode with a online PDU decoder.
My next move is to remove the E1750 from seven_bit_modems[]. The modem is reporting support for 7 bit encoding:
USSD use 7 bit encoding : Yes
USSD use UCS-2 decoding : No

I cant find the modem list in "at_command.c".
Has it been moved to some other file?

shalzz pushed a commit to shalzz/asterisk-chan-dongle that referenced this issue Apr 23, 2022
# This is the 1st commit message:

Create DONATIONS.txt
# This is the commit message wdoekes#2:

Update README.md
# This is the commit message wdoekes#3:

Update DONATIONS.txt
# This is the commit message wdoekes#4:

Update DONATIONS.txt
# This is the commit message wdoekes#5:

Update DONATIONS.txt
# This is the commit message wdoekes#6:

Update chan_quectel.h
# This is the commit message wdoekes#7:

Update README.md
# This is the commit message wdoekes#8:

Update cpvt.h
# This is the commit message wdoekes#9:

Add files via upload
# This is the commit message wdoekes#10:

Delete DONATIONS.txt
# This is the commit message wdoekes#11:

Update README.md
# This is the commit message wdoekes#12:

Update README.md
# This is the commit message wdoekes#13:

Update README.md
# This is the commit message wdoekes#14:

Add files via upload
# This is the commit message wdoekes#15:

Update README.md
# This is the commit message wdoekes#16:

Update README.md
# This is the commit message wdoekes#17:

Update README.md
# This is the commit message wdoekes#18:

Update README.md
# This is the commit message wdoekes#19:

Update README.md
# This is the commit message wdoekes#20:

Update README.md
# This is the commit message wdoekes#21:

Update README.md
# This is the commit message wdoekes#22:

Update README.md
# This is the commit message wdoekes#23:

Add files via upload

Added Simcom support
# This is the commit message wdoekes#24:

Update README.md
# This is the commit message wdoekes#25:

Update README.md
# This is the commit message wdoekes#26:

Added support for Quectel UAC configuration
# This is the commit message wdoekes#27:

Conf file when using UAC
# This is the commit message wdoekes#28:

Update README.md
# This is the commit message wdoekes#29:

Update README.md
# This is the commit message wdoekes#30:

Quectel CREG correction

chan_dongle code assumes 4 parameters in response to command and 3 for URC. However quectel provides 5 and 4 respectively. This fix helps pass on correct status of registration.
# This is the commit message wdoekes#31:

No force registration status

Due to CREG parse issues, earlier registration status was always kept on, now will show unregistered if not connected to network
# This is the commit message wdoekes#32:

Create readme.md
# This is the commit message wdoekes#33:

For compilation with openwrt sdk
# This is the commit message wdoekes#34:

Support for openwrt sdk compilation
# This is the commit message wdoekes#35:

Fix for lac and cell id

Ref IchthysMaranatha#6
Post fix values may have a trailing double quote for quectel devices
# This is the commit message wdoekes#36:

Updated call ids for simcom

Add call termination for call ids 1 and 2
# This is the commit message wdoekes#37:

comment for simcom audio

Added default audio port for simcom in comment
# This is the commit message wdoekes#38:

Integrated ALSA support for UAC

Integrated driver for ALSA added, no need for bridging additional Asterisk ALSA channel when using UAC mode. Please use non-ALSA integrated branch if there is no need for UAC and you wish to avoid alsa dependency when compiling and running
# This is the commit message wdoekes#39:

Update COPYRIGHT.txt

Attribute copyright for alsa code copied from chan_alsa.c https://github.com/asterisk/asterisk/blob/master/channels/chan_alsa.c
# This is the commit message wdoekes#40:

Update README.md
# This is the commit message wdoekes#41:

Conf file with UAC device support
# This is the commit message wdoekes#42:

UAC mode conf file
# This is the commit message wdoekes#43:

Added alsa-lib for compilation
# This is the commit message wdoekes#44:

Delete Makefile.in
# This is the commit message wdoekes#45:

alsa-lib dependency addition
# This is the commit message wdoekes#46:

Fix for simcom audio issues with immediate answer in dialplan
# This is the commit message wdoekes#47:

Note for Quectel serial audio

Added remark to disable gps messages
# This is the commit message wdoekes#48:

Added note for Pi users
# This is the commit message wdoekes#49:

Quectel creg formatting fix

Removed trailing double quotes in reporting lac/cid
# This is the commit message wdoekes#50:

add gitattributes
# This is the commit message wdoekes#51:

Send DTMF using AT command

Corrected at command for dtmf generation
# This is the commit message wdoekes#52:

Fix for busy on call rejection for simcom

For those who receive 'busy' additionally on call rejection when dialling out. Author only receives 'no carrier' on rejection. Reported and solved by @mpmc here IchthysMaranatha#22
# This is the commit message wdoekes#53:

Removal of redundant closetty
# This is the commit message wdoekes#54:

Update busy fix for call rejection

Updated fix as submitted by @mpmc here IchthysMaranatha#22
Author does not receive busy response on call rejection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants