[datacard-incoming]
exten => sms,1,Verbose(Incoming SMS from ${SMSSRC} ${SMSTXT})
exten => sms,n,System(echo '${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)} - ${CHANNEL} - ${SMSSRC}: ${SMSTXT}' >> /var/log/asterisk/sms.txt)
exten => sms,n,Hangup()
OpenWrt*CLI> core show applications
-= Registered Asterisk Applications =-
DatacardSendSMS: DatacardSendSMS(Device,Dest,Message)
DatacardStatus: DatacardStatus(Device,Variable)
*CLI> datacard show devices
ID Group Connected State Voice SMS RSSI Mode Submode Provider Name Manufacturer Model Firmware IMEI
callmobile 1 Yes Free Yes Yes 11 3 3 Swisscom huawei K3520 11.314.21.31.00 xxx
alexander@debian:/usr/src/chan_datacard$ svn log http://www.makhutov.org/svn/chan_datacard/trunk/ -r 38
------------------------------------------------------------------------
r38 | artem | 2010-01-28 00:28:42 +0100 (Do, 28. Jan 2010) | 2 lines
Add UCS-2 support [#10]. Messaged are now exchanged with UCS-2 encoding with the datacard (CUSD and SMS) if the datacard supports UCS-2.
------------------------------------------------------------------------
alexander@debian:/usr/src/chan_datacard$
ERROR[21207]: chan_datacard.c:3649 handle_response_cmgr: [callmobile] error parsing SMS (convert UCS-2 to UTF-8): ...
$ diff chan_datacard.c.old chan_datacard.c.new
291c291
< static int dc_send_cops_init(struct dc_pvt *pvt,int mode, int format);
---
> static int dc_send_cops_init(struct dc_pvt *pvt,int mode, int format, char* oper);
2850c2850
< static int dc_send_cops_init(struct dc_pvt *pvt,int mode, int format)
---
> static int dc_send_cops_init(struct dc_pvt *pvt,int mode, int format, char* oper)
2852,2853c2852,2853
< char cmd[16];
< snprintf(cmd, sizeof(cmd), "AT+COPS=%d,%d\r", mode, format);
---
> char cmd[32];
> snprintf(cmd, sizeof(cmd), "AT+COPS=%d,%d,%s\r", mode, format, oper);
3075c3075
< if (dc_send_cops_init(pvt,0,0) || msg_queue_push(pvt, AT_OK, AT_COPS_INIT)) {
---
> if (dc_send_cops_init(pvt,1,0,"T-Mobile D") || msg_queue_push(pvt, AT_OK, AT_COPS_INIT)) {
3964c3964
< pvt->timeout = 10000;
---
> pvt->timeout = 80000;
--- trunk/chan_datacard.c 2010-01-30 18:41:18.000000000 +0100
+++ chan_datacard.c 2010-01-30 18:24:53.000000000 +0100
@@ -2350,7 +2350,7 @@
*/
static int dc_parse_cmgr(struct dc_pvt *pvt, char *buf, char **from_number, char **text)
{
- int i, state;
+ int i, state, nstart;
size_t s;
/* parse cmgr info in the following format:
@@ -2370,16 +2370,20 @@
if (buf[i] == '"') {
state++;
}
+ break;
case 2: /* mark the start of the number */
+ nstart=i;
if (from_number) {
- *from_number = &buf[i];
state++;
}
- /* fall through */
+ break;
case 3: /* search for the end of the number (") */
if (buf[i] == '"') {
buf[i] = '\0';
state++;
+ if (from_number) {
+ *from_number = &buf[nstart];
+ }
}
break;
case 4: /* search for the start of the message text (\n) */
svn co http://www.makhutov.org/svn/chan_datacard/trunk/@37
alix*CLI> datacard show devices
ID Group Connected State Voice SMS RSSI Mode Submode Provider Name Manufacturer Model Firmware IMEI
genion 1 Yes Free No Yes 0 0 0 o2 - de huawei E17X 11.306.07.01.55 364483022532692
AT+FCLASS=8 oder AT^U2DIAG=255
AT^U2DIAG=256
AT^DDSETEX=2
--- trunk/chan_datacard.c 2010-01-31 16:46:47.000000000 +0100
+++ own/chan_datacard.c 2010-01-31 16:43:28.000000000 +0100
@@ -2357,7 +2357,7 @@
*/
static int dc_parse_cmgr(struct dc_pvt *pvt, char *buf, char **from_number, char **text)
{
- int i, state;
+ int i, state, nstart;
size_t s;
/* parse cmgr info in the following format:
@@ -2377,32 +2377,45 @@
if (buf[i] == '"') {
state++;
}
+ break;
case 2: /* mark the start of the number */
+ nstart=i;
if (from_number) {
- *from_number = &buf[i];
state++;
}
- /* fall through */
+ break;
case 3: /* search for the end of the number (") */
if (buf[i] == '"') {
buf[i] = '\0';
state++;
+ if (from_number) {
+ *from_number = &buf[nstart];
+ }
}
break;
case 4: /* search for the start of the message text (\n) */
if (buf[i] == '\n') {
state++;
+ nstart=i+1;
}
break;
case 5: /* mark the start of the message text */
- if (text) {
- *text = &buf[i];
- state++;
+ if (buf[i] == '\n') {
+ buf[i] = '\0';
+ if (text) {
+ *text = &buf[nstart];
+ state++;
+ }
}
break;
}
}
-
+ if (state == 5) {
+ if (text) {
+ *text = &buf[nstart];
+ state++;
+ }
+ }
if (state != 6) {
return -1;
}
@@ -3616,7 +3629,7 @@
static int handle_response_cmgr(struct dc_pvt *pvt, char *buf)
{
int res;
- char sms_utf8_buf[4096];
+ char sms_utf8_buf[4096], num_utf8_buf[4096];
char *from_number, *text;
struct ast_channel *chan;
struct msg_queue_entry *msg;
@@ -3642,11 +3655,17 @@
}
if (pvt->use_ucs2_encoding) {
- res = hexstr_ucs2_to_utf8(text,strlen(text),sms_utf8_buf,sizeof(sms_utf8_buf));
+ res = hexstr_ucs2_to_utf8(from_number,strlen(from_number),num_utf8_buf,sizeof(num_utf8_buf));
if (res>0) {
- text = sms_utf8_buf;
+ from_number = num_utf8_buf;
+ res = hexstr_ucs2_to_utf8(text,strlen(text),sms_utf8_buf,sizeof(sms_utf8_buf));
+ if (res>0) {
+ text = sms_utf8_buf;
+ } else {
+ ast_log(LOG_ERROR, "[%s] error parsing SMS (convert UCS-2 to UTF-8): %s - Returncode: %d\n", pvt->id, text,res);
+ }
} else {
- ast_log(LOG_ERROR, "[%s] error parsing SMS (convert UCS-2 to UTF-8): %s\n", pvt->id, text);
+ ast_log(LOG_ERROR, "[%s] error parsing SMS (convert UCS-2 to UTF-8): %s - Returncode: %d\n", pvt->id, from_number,res);
}
}
Muss ich dazu chan_datacard.c abändern oder an welcher Stelle schiebe ich den AT-cmd raus?
Bus 005 Device 006: ID 12d1:1001 Huawei Technologies Co., Ltd. E620 USB Modem
Bus 005 Device 005: ID 12d1:1001 Huawei Technologies Co., Ltd. E620 USB Modem
Bus 005 Device 004: ID 12d1:1001 Huawei Technologies Co., Ltd. E620 USB Modem
Bus 005 Device 002: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 046d:c03e Logitech, Inc. Premium Optical Wheel Mouse
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
SUBSYSTEMS=="usb", ATTRS{idProduct}=="1001", ATTRS{idVendor}=="12d1", SYMLINK+="ttyUSB_%b", KERNEL=="ttyUSB[0-9*]", MODE="0666", OWNER="asterisk",GROUP="uucp"
crw-rw-rw- 1 asterisk uucp 188, 0 2. Feb 15:40 /dev/ttyUSB0
crw-rw-rw- 1 asterisk uucp 188, 1 2. Feb 15:40 /dev/ttyUSB1
crw-rw-rw- 1 asterisk uucp 188, 2 2. Feb 15:41 /dev/ttyUSB2
crw-rw-rw- 1 asterisk uucp 188, 3 2. Feb 15:40 /dev/ttyUSB3
crw-rw-rw- 1 asterisk uucp 188, 4 2. Feb 15:40 /dev/ttyUSB4
crw-rw-rw- 1 asterisk uucp 188, 5 2. Feb 15:41 /dev/ttyUSB5
lrwxrwxrwx 1 root root 7 2. Feb 15:40 /dev/ttyUSB_5-1.1 -> ttyUSB2
lrwxrwxrwx 1 root root 7 2. Feb 15:40 /dev/ttyUSB_5-1.2 -> ttyUSB5
lrwxrwxrwx 1 root root 7 2. Feb 15:40 /dev/ttyUSB_5-1.4 -> ttyUSB8
crw-rw-rw- 1 asterisk uucp 188, 6 2. Feb 15:40 /dev/ttyUSB6
crw-rw-rw- 1 asterisk uucp 188, 7 2. Feb 15:40 /dev/ttyUSB7
crw-rw-rw- 1 asterisk uucp 188, 8 2. Feb 15:41 /dev/ttyUSB8
SUBSYSTEMS=="usb", SYMLINK+="ttyUSB_%b", KERNEL=="ttyUSB[0-9*]", MODE="0666", OWNER="asterisk",GROUP="uucp"
crw-rw-rw- 1 asterisk dialout 188, 0 2. Feb 16:14 /dev/ttyUSB0
crw-rw-rw- 1 asterisk dialout 188, 1 2. Feb 16:14 /dev/ttyUSB1
crw-rw-rw- 1 asterisk dialout 188, 2 2. Feb 16:14 /dev/ttyUSB2
crw-rw-rw- 1 asterisk dialout 188, 3 2. Feb 16:14 /dev/ttyUSB3
crw-rw-rw- 1 asterisk dialout 188, 4 2. Feb 16:14 /dev/ttyUSB4
crw-rw-rw- 1 asterisk dialout 188, 5 2. Feb 16:14 /dev/ttyUSB5
lrwxrwxrwx 1 root root 7 2. Feb 16:14 /dev/ttyUSB_5-1.1:1.0 -> ttyUSB0
lrwxrwxrwx 1 root root 7 2. Feb 16:14 /dev/ttyUSB_5-1.1:1.1 -> ttyUSB1
lrwxrwxrwx 1 root root 7 2. Feb 16:14 /dev/ttyUSB_5-1.1:1.2 -> ttyUSB2
lrwxrwxrwx 1 root root 7 2. Feb 16:14 /dev/ttyUSB_5-1.2:1.0 -> ttyUSB3
lrwxrwxrwx 1 root root 7 2. Feb 16:14 /dev/ttyUSB_5-1.2:1.1 -> ttyUSB4
lrwxrwxrwx 1 root root 7 2. Feb 16:14 /dev/ttyUSB_5-1.2:1.2 -> ttyUSB5
lrwxrwxrwx 1 root root 7 2. Feb 16:14 /dev/ttyUSB_5-1.4:1.0 -> ttyUSB6
lrwxrwxrwx 1 root root 7 2. Feb 16:14 /dev/ttyUSB_5-1.4:1.1 -> ttyUSB7
lrwxrwxrwx 1 root root 7 2. Feb 16:14 /dev/ttyUSB_5-1.4:1.2 -> ttyUSB8
crw-rw-rw- 1 asterisk dialout 188, 6 2. Feb 16:14 /dev/ttyUSB6
crw-rw-rw- 1 asterisk dialout 188, 7 2. Feb 16:14 /dev/ttyUSB7
crw-rw-rw- 1 asterisk dialout 188, 8 2. Feb 16:14 /dev/ttyUSB8
[22313.260661] usb-storage: device found at 9
[22313.260664] usb-storage: waiting for device to settle before scanning
[22313.960018] usb 4-2: new full speed USB device using uhci_hcd and address 10
[22314.124642] usb 4-2: New USB device found, idVendor=12d1, idProduct=1001
[22314.124662] usb 4-2: New USB device strings: Mfr=1, Product=2, SerialNumber=1
[22314.124671] usb 4-2: Product: HUAWEI Mobile
[22314.124679] usb 4-2: Manufacturer: ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
[22314.124687] usb 4-2: SerialNumber: ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
[22314.124865] usb 4-2: configuration #1 chosen from 1 choice
[22314.171548] usbcore: registered new interface driver usbserial
[22314.171588] USB Serial support registered for generic
[22314.210690] scsi23 : SCSI emulation for USB Mass Storage devices
[22314.226766] usbcore: registered new interface driver usbserial_generic
[22314.226788] usbserial: USB Serial Driver core
[22314.229964] USB Serial support registered for GSM modem (1-port)
[22314.230023] option 4-2:1.0: GSM modem (1-port) converter detected
[22314.230189] usb 4-2: GSM modem (1-port) converter now attached to ttyUSB0
[22314.230211] option 4-2:1.1: GSM modem (1-port) converter detected
[22314.230300] usb 4-2: GSM modem (1-port) converter now attached to ttyUSB1
[22314.230320] option 4-2:1.2: GSM modem (1-port) converter detected
[22314.230402] usb 4-2: GSM modem (1-port) converter now attached to ttyUSB2
[22314.230432] usbcore: registered new interface driver option
[22314.230440] option: v0.7.2:USB Driver for GSM modems
[22314.239713] usb-storage: device found at 10
[22314.239719] usb-storage: waiting for device to settle before scanning
[22315.240356] scsi 23:0:0:0: CD-ROM HUAWEI Mass Storage 2.31 PQ: 0 ANSI: 2
[22315.265359] sr1: scsi-1 drive
[22315.265590] sr 23:0:0:0: Attached scsi CD-ROM sr1
[22315.265716] sr 23:0:0:0: Attached scsi generic sg2 type 5
[22315.266167] usb-storage: device scan complete
datacard show devices
ID Group Connected State Voice SMS RSSI Mode Submode Provider Name Manufacturer Model Firmware IMEI
datacard0 1 Yes Free Yes Yes 21 5 4 A1 huawei E169G 11.314.21.31.00 35305..........
<------------>
-- Executing [013xxxx641@default:1] Dial("SIP/opfbqc15-00000000", "Datacard/datacard0/013xxxx641") in new stack
-- Called datacard0/013xxxx641
-- Datacard/datacard0-08d0 is circuit-busy
== Everyone is busy/congested at this time (1:0/1/0)
-- Auto fallthrough, channel 'SIP/opfbqc15-00000000' status is 'CONGESTION'