Skip to content

Commit

Permalink
Seperated PDU parsing (and building) into hex parsing, actual PDU dec…
Browse files Browse the repository at this point in the history
…oding and UCS-2 decoding; Implemented delivery reports; Fixed USSD generating
  • Loading branch information
maxvonbuelow committed May 5, 2020
1 parent 9968d4a commit 868bbd4
Show file tree
Hide file tree
Showing 31 changed files with 2,131 additions and 2,053 deletions.
13 changes: 7 additions & 6 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@ PROJS = chan_dongles.so

chan_donglem_so_OBJS = app.o at_command.o at_parse.o at_queue.o at_read.o at_response.o \
chan_dongle.o channel.o char_conv.o cli.o helpers.o manager.o \
memmem.o ringbuffer.o cpvt.o dc_config.o pdu.o mixbuffer.o pdiscovery.o smsdb.o
memmem.o ringbuffer.o cpvt.o dc_config.o pdu.o mixbuffer.o pdiscovery.o error.o smsdb.o

chan_dongles_so_OBJS = single.o

test1_OBJS = test/test1.o ringbuffer.o mixbuffer.o
gen_OBJS = test/gen.o char_conv.o pdu.o
parse_OBJS = test/parse.o at_parse.o char_conv.o pdu.o
test1_OBJS = test/test1.o ringbuffer.o mixbuffer.o error.o
gen_OBJS = test/gen.o char_conv.o pdu.o error.o
parse_OBJS = test/parse.o at_parse.o char_conv.o pdu.o error.o
discovery_OBJS = tools/discovery.o tools/tty.o

SOURCES = app.c at_command.c at_parse.c at_queue.c at_read.c at_response.c \
chan_dongle.c channel.c char_conv.c cli.c cpvt.c dc_config.c helpers.c \
manager.c memmem.c ringbuffer.c single.c pdu.c mixbuffer.c pdiscovery.c smsdb.c
manager.c memmem.c ringbuffer.c single.c pdu.c mixbuffer.c pdiscovery.c \
error.c smsdb.c

test_SOURCES = test/test1.c test/parse.c test/gen.c
tools_SOURCES = tools/discovery.c tools/tty.c

HEADERS = app.h at_command.h at_parse.h at_queue.h at_read.h at_response.h \
chan_dongle.h channel.h char_conv.h cli.h cpvt.h dc_config.h export.h \
helpers.h manager.h memmem.h ringbuffer.h pdu.h mixbuffer.h pdiscovery.h \
mutils.h smsdb.h
mutils.h error.h smsdb.h

tools_HEADERS = tools/tty.h

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ single quotes.*
exten => *#123#,n,Playback(vm-goodbye)
exten => *#123#,n,Hangup()

exten => _#X.,1,DongleSendSMS(dongle0,${EXTEN:1},"Please call me",1440,yes)
exten => _#X.,1,DongleSendSMS(dongle0,${EXTEN:1},"Please call me",1440,yes,"magicID")
exten => _#X.,n,Answer()
exten => _#X.,n,Wait(2)
exten => _#X.,n,Playback(vm-goodbye)
Expand Down
31 changes: 14 additions & 17 deletions app.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "app.h" /* app_register() app_unregister() */
#include "chan_dongle.h" /* struct pvt */
#include "helpers.h" /* send_sms() ITEMS_OF() */
#include "error.h"

struct ast_channel;

Expand Down Expand Up @@ -74,16 +75,14 @@ static int app_status_exec (struct ast_channel* channel, const char* data)
static int app_send_sms_exec (attribute_unused struct ast_channel* channel, const char* data)
{
char* parse;
const char* msg;
int status;
void * msgid;

AST_DECLARE_APP_ARGS (args,
AST_APP_ARG (device);
AST_APP_ARG (number);
AST_APP_ARG (message);
AST_APP_ARG (validity);
AST_APP_ARG (report);
AST_APP_ARG (payload);
);

if (ast_strlen_zero (data))
Expand All @@ -107,18 +106,16 @@ static int app_send_sms_exec (attribute_unused struct ast_channel* channel, cons
return -1;
}

msg = send_sms(args.device, args.number, args.message, args.validity, args.report, &status, &msgid);
if(!status)
ast_log (LOG_ERROR, "[%s] %s with id %p\n", args.device, msg, msgid);
return !status;
if (send_sms(args.device, args.number, args.message, args.validity, args.report, args.payload, strlen(args.payload) + 1) < 0) {
ast_log(LOG_ERROR, "[%s] %s\n", args.device, error2str(chan_dongle_err));
return -1;
}
return 0;
}

static int app_send_ussd_exec(attribute_unused struct ast_channel* channel, const char* data)
{
char* parse;
const char* msg;
int status;
void* msgid;

AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(device);
Expand Down Expand Up @@ -146,12 +143,11 @@ static int app_send_ussd_exec(attribute_unused struct ast_channel* channel, cons
return -1;
}

msg = send_ussd(args.device, args.ussd, &status, &msgid);
if(!status)
{
ast_log(LOG_ERROR, "[%s] %s with id %p\n", args.device, msg, msgid);
if (send_ussd(args.device, args.ussd) < 0) {
ast_log(LOG_ERROR, "[%s] %s\n", args.device, error2str(chan_dongle_err));
return -1;
}
return !status;
return 0;
}


Expand All @@ -176,13 +172,14 @@ static const struct dongle_application
{
"DongleSendSMS",
app_send_sms_exec,
"DongleSendSMS(Device,Dest,Message,Validity,Report)",
"DongleSendSMS(Device,Dest,Message,Validity,Report)\n"
"DongleSendSMS(Device,Dest,Message,Validity,Report,Payload)",
"DongleSendSMS(Device,Dest,Message,Validity,Report,Payload)\n"
" Device - Id of device from dongle.conf\n"
" Dest - destination\n"
" Message - text of the message\n"
" Validity - Validity period in minutes\n"
" Report - Boolean flag for report request\n"
" Payload - Unstructured data that will be included in delivery report\n"
},
{
"DongleSendUSSD",
Expand Down
Loading

0 comments on commit 868bbd4

Please sign in to comment.