maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   SMS DBUS sending Fail (https://talk.maemo.org/showthread.php?t=58473)

waelfarouk0 2010-07-14 19:20

SMS DBUS sending Fail
 
Dear All,
I am trying send SMS using Dbus using C
i studied paython vert SMS
http://gitorious.org/vertsms/vertsms...vertsms/sms.py

i tested this code: (i set the pdu fixed array to make it easier
i compared pdu array to vertsms pdustring and they are the same

but dbus_g_proxy_call always return false
need help urgent
#define MYTYPE (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_UCHAR_ARRAY))


static void sendsms(SMS* sm)
{


DBusGConnection* dbus_conn;
DBusGProxy* dbus_proxy;


dbus_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
dbus_proxy = dbus_g_proxy_new_for_name(dbus_conn, "com.nokia.phone.SMS", "/com/nokia/phone/SMS/ba212ae1","com.nokia.csd.SMS.Outgoing");

createsmspdu(sm);


GPtrArray* ptrarray;
GArray* array;

guchar values[] =
{33, 10, 12, 129, 2, 1, 145, 18, 85, 21, 0, 0, 10, 232, 50, 155, 253, 70, 151, 217, 236, 183};

ptrarray = g_ptr_array_new();
array = g_array_new(FALSE, FALSE, sizeof(guchar));

g_array_append_vals(array, values, sizeof(values)/sizeof(guchar));
g_ptr_array_add(ptrarray, (gpointer)array);







gboolean b = dbus_g_proxy_call(dbus_proxy,"Send",NULL,MYTYPE,pt rarray, G_TYPE_STRING,"",G_TYPE_INVALID);


if(!b)
{


logv( "Error sending");

}
else
logv( "Success sending");

g_ptr_array_free(ptrarray,TRUE);
g_object_unref(dbus_proxy);
dbus_g_connection_unref(dbus_conn);

}



thank you for taking time read this

qwerty12 2010-07-14 19:46

Re: SMS DBUS sending Fail
 
Looking at the original it's ripped from (http://talk.maemo.org/showpost.php?p...7&postcount=14), it's using dbus_g_proxy_call_no_reply, whilst you're using dbus_g_proxy_call. Because the latter also allows you to specify pointers for storing the values returned by the call, you must add another G_TYPE_INVALID (like when you're finished speciying the "in" arguments) to specify when you're done.

P.S. dbus_g_proxy_call supports GError. Use it ;)

waelfarouk0 2010-07-14 19:52

Re: SMS DBUS sending Fail
 
Quote:

Originally Posted by qwerty12 (Post 751963)
Looking at the original it's ripped from (http://talk.maemo.org/showpost.php?p...7&postcount=14), it's using dbus_g_proxy_call_no_reply, whilst you're using dbus_g_proxy_call. Because the latter also allows you to specify pointers for storing the values returned by the call, you must add another G_TYPE_INVALID (like when you're finished speciying the "in" arguments) to specify when you're done.

P.S. dbus_g_proxy_call supports GError. Use it ;)

i already used but application is panic on device if i use GError
GError* error = NULL;
dbus_g_proxy_call(dbus_proxy,"Send",&error,MYTYPE, pt rarray, G_TYPE_STRING,"",G_TYPE_INVALID);

thank you for fast reply

waelfarouk0 2010-07-14 19:56

Re: SMS DBUS sending Fail
 
i added G_TYPE_INVALID no luck also fail
i also used original no luck

waelfarouk0 2010-07-14 20:23

Re: SMS DBUS sending Fail
 
Quote:

Originally Posted by qwerty12 (Post 751963)
Looking at the original it's ripped from (http://talk.maemo.org/showpost.php?p...7&postcount=14), it's using dbus_g_proxy_call_no_reply, whilst you're using dbus_g_proxy_call. Because the latter also allows you to specify pointers for storing the values returned by the call, you must add another G_TYPE_INVALID (like when you're finished speciying the "in" arguments) to specify when you're done.

P.S. dbus_g_proxy_call supports GError. Use it ;)



I tried this
and i got this error from log on device
too many arguments in reply; expected 0 , got 2

what type of paramters i should specify

gboolean b = dbus_g_proxy_call(dbus_proxy,"Send",&error,myt,ptr array, G_TYPE_STRING,"",G_TYPE_INVALID,G_TYPE_INVALID);


if(!b)
{


logv( "Error sending:");
logv( error->message);

}
else
logv( "Success sending");

jflatt 2010-07-14 20:41

Re: SMS DBUS sending Fail
 
Quote:

Originally Posted by waelfarouk0 (Post 751975)
i already used but application is panic on device if i use GError
GError* error = NULL;
dbus_g_proxy_call(dbus_proxy,"Send",&error,MYTYPE, pt rarray, G_TYPE_STRING,"",G_TYPE_INVALID);

thank you for fast reply

Looks to me like you're trying to send in a null pointer reference. Kaboom

jflatt 2010-07-14 20:42

Re: SMS DBUS sending Fail
 
Quote:

Originally Posted by waelfarouk0 (Post 752033)
I tried this
and i got this error from log on device
too many arguments in reply; expected 0 , got 2

what type of paramters i should specify

gboolean b = dbus_g_proxy_call(dbus_proxy,"Send",&error,myt,ptr array, G_TYPE_STRING,"",G_TYPE_INVALID,G_TYPE_INVALID);


if(!b)
{


logv( "Error sending:");
logv( error->message);

}
else
logv( "Success sending");

Did you change the function call to dbus_g_proxy_call_no_reply as was suggested?

waelfarouk0 2010-07-14 20:46

Re: SMS DBUS sending Fail
 
Quote:

Originally Posted by jflatt (Post 752052)
Did you change the function call to dbus_g_proxy_call_no_reply as was suggested?

YES no Luck, any advice pls?

Where can i find D-BUs interface XML defination?


Regards
Wael

waelfarouk0 2010-07-15 16:09

Re: SMS DBUS sending Fail
 
hello,
any suggestions?

waelfarouk0 2010-07-15 22:30

Re: SMS DBUS sending Fail
 
Dear All,
Fixed and Works now,
problem was in Mobile number encoding
fixed

dear qwerty12 thanks

i will post working functions to commuinty so everyone can use,
i have a question what if i want send unicode message
how can i set Data Coding Schema


Thanks
Wael

SevEd 2010-07-19 14:56

Re: SMS DBUS sending Fail
 
Could you show us your fixed code? I'm trying to send messages but I haven't been lucky

Thanks

waelfarouk0 2010-07-19 17:29

Re: SMS DBUS sending Fail
 
Quote:

Originally Posted by SevEd (Post 756852)
Could you show us your fixed code? I'm trying to send messages but I haven't been lucky

Thanks

Sure
i will post it tomorrow please patient
thanks

waelfarouk0 2010-07-21 09:11

Re: SMS DBUS sending Fail
 
Quote:

Originally Posted by SevEd (Post 756852)
Could you show us your fixed code? I'm trying to send messages but I haven't been lucky

Thanks

The source code can found here:

http://www.extenddev.com/maemo/phonelib.h.txt
http://www.extenddev.com/maemo/gsm.h.txt


Using like this :
struct _SMS* sm;
sm = malloc(sizeof(SMS) );

memset(sm,0,sizeof(SMS));

strcpy(sm->mobile,"+20xxxxxxxxx");
strcpy(sm->message,"hellohello");

sendsms(sm);
free(sm);

Hope is useful
and helpful

Thanks

SevEd 2010-07-21 14:49

Re: SMS DBUS sending Fail
 
thanks so much waelfarouk0

SevEd 2010-07-21 16:54

Re: SMS DBUS sending Fail
 
I'm trying to compile this code with using gsm.h and phonelib.h :

Quote:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "gsm.h"
#include "phonelib.h"


main(){

struct _SMS *sm;
sm = malloc(sizeof(SMS) );
memset(sm,0,sizeof(SMS));

char mobile[10];
char message[140];

printf("Mobile Phone: ");
scanf("%s",mobile);
printf("Message: ");
scanf("%s",message);

strcpy(sm->mobile,mobile);
strcpy(sm->message,message);

sendsms(sm);
free(sm);

}
I used this to compile

Quote:

gcc -Wall `pkg-config --cflags dbus-1 glib-2.0 dbus-glib-1` `pkg-config --libs dbus-1 glib-2.0 dbus-glib-1` test_sms.c -o test_sms
but I received the following errors and warnings

Quote:

In file included from sms.c:4:
gsm.h:41:1: warning: "/*" within comment
In file included from sms.c:5:
phonelib.h:41:1: warning: "/*" within comment
In file included from sms.c:5:
phonelib.h: In function 'sendsms':
phonelib.h:256: warning: unused variable 'error'
sms.c: At top level:
phonelib.h:84: warning: 'logv' defined but not used
/var/tmp/ccscQAUM.o: In function `encode7bituncompressed':
sms.c:(.text+0xec): undefined reference to `ceil'
collect2: ld returned 1 exit status
Does someone knows how can fix it?

Thanks

Patola 2010-07-21 17:00

Re: SMS DBUS sending Fail
 
What about 7-bit encodings vs. 16-bit encodings and such? Does you app deal with these matters?

waelfarouk0 2010-07-21 17:15

Re: SMS DBUS sending Fail
 
Quote:

Originally Posted by SevEd (Post 759504)
I'm trying to compile this code with using gsm.h and phonelib.h :



I used this to compile



but I received the following errors and warnings



Does someone knows how can fix it?

Thanks

ceil is math function you should find out which library you should add to libs i am not sure what is the library name

i will check
and back to you

waelfarouk0 2010-07-21 17:16

Re: SMS DBUS sending Fail
 
Quote:

Originally Posted by Patola (Post 759524)
What about 7-bit encodings vs. 16-bit encodings and such? Does you app deal with these matters?

kindly, are you talking about unicode?
if i just need to know where is data coding scehma is set and then i will let you know how to send unicode



Thanks
Wael

waelfarouk0 2010-07-21 17:44

Re: SMS DBUS sending Fail
 
Quote:

Originally Posted by SevEd (Post 759504)
I'm trying to compile this code with using gsm.h and phonelib.h :



I used this to compile



but I received the following errors and warnings



Does someone knows how can fix it?

Thanks

please try add lib -lm and let us know


Regards
Wael

SevEd 2010-07-21 17:45

Re: SMS DBUS sending Fail
 
Jejeje I forget to use the parameter -lm for the math.h lib

It works

sergulo 2010-11-16 12:01

Re: SMS DBUS sending Fail
 
Quote:

Originally Posted by waelfarouk0 (Post 759570)
kindly, are you talking about unicode?
if i just need to know where is data coding scehma is set and then i will let you know how to send unicode



Thanks
Wael

Hi all

Dear waelfarouk0, could you please provide the way how to encode properly the sms message text to UTF8 (i.e. sm->message) in case it contains unicode data.

Regards

sergulo 2010-11-21 18:39

Re: SMS DBUS sending Fail
 
Quote:

Originally Posted by sergulo (Post 874937)
Hi all

Dear waelfarouk0, could you please provide the way how to encode properly the sms message text to UTF8 (i.e. sm->message) in case it contains unicode data.

Regards

Please any help concerning above question :confused::confused::confused:
that is MEGA urgent for me.

Thanks in advance


All times are GMT. The time now is 13:43.

vBulletin® Version 3.8.8