Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pjsip send sms how to

Tags:

c

ios

sms

sip

pjsip

I'm trying to send sms messages through pjsip without luck so far.

The account gets registered on a server and I get a register success response but I can't find any good tutorials that show how to send sms.

I found this book online but it still doesn't give me any examples of how to use this library: http://www.scribd.com/doc/90092246/Pjsip-Dev-Guide#outer_page_48

I know I'm supposed to use:

pjsip_endpt_create_request(pjsip_endpoint *endpt, const pjsip_method method, const pj_str_t *target, const pj_str_t *from, const pj_str_t *to, , const pj_str_t *call_id, int cseq, const pj_str_t *text, pjsip_tx_data **p_tdata);

pjsip_endpt_acquire_transport(pjsip_endpoint *endpt, pjsip_transport_type_e type, const pj_sockaddr_t *remote, int addr_len, const pjsip_tpselector *sel, pjsip_transport **p_tp)

but apart from these, I have no idea.

Note: I don't want instant messaging, I want the texts to be delivered as SMS if possible. And it needs to be done in pjsip, no other library (no flexibility unfortunately).

Thanks in advance!

like image 906
C0D3 Avatar asked Sep 14 '12 21:09

C0D3


2 Answers

Okay, here I am answering my own question related to pjsip again. I wish this library had proper documentation where the function calls were explained a better way on what they do.

1 thing that confused me was that there in this developer's guide: http://www.pjsip.org/release/0.5.4/PJSIP-Dev-Guide.pdf

there are 2 topics. 1 is message elements and how to create a request. The other is instant messaging. I wasn't exactly sure which was required for SMS. Turns out, its the instant messaging.

The only needed function is:

pjsua_im_send(pjsua_acc_id acc_id, const pj_str_t *to, const pj_str_t *mime_type, const pj_str_t *content, const pjsua_msg_data *msg_data, void *user_data);

1st variable acc_id is what gets initialized at the beginning of the application SIP registration.

2nd variable is the number you want the message to be sent to. I initialized it as such:

"sip:[email protected]"

3rd variable is for sending MIME's. I didn't use this. so it's NULL.

4th variable is the message body itself.

For example:

pj_str_t text;
const char *msgText = [@"Hello there!" UTF8String];

text = pj_str((char*)msgText);

then I passed: &text to the function.

5th variable is the msg data. Again, didn't use it. It's NULL.

6th variable is user data. Didn't use this either. NULL.

And finally, this is what the function call looked like:

 pjsua_im_send(app._sip_acc_id, &to, NULL, &text, NULL, NULL);

Hope this helps someone out there having a similar problem! -c0d3Junk13

like image 61
C0D3 Avatar answered Nov 15 '22 16:11

C0D3


A SMS is essentially an email delivered to [email protected]. I have not used pjsip, however I was able to use the Chilkat library to deliver SMS quite easily. For example code to send an email, you can find it on their website.

like image 31
Blue Wizard Avatar answered Nov 15 '22 16:11

Blue Wizard