7

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!

C0D3
  • 6,440
  • 8
  • 43
  • 67

2 Answers2

12

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:16476804556@sipserverdomain.com"

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

C0D3
  • 6,440
  • 8
  • 43
  • 67
  • 2
    +1 for both the question and the answer. if pjsip will have some simple tutorials on how to do basic things the life will be to easy. – alinoz Sep 20 '12 at 08:16
  • 1
    Thank you! Now I'm trying to solve this: http://stackoverflow.com/questions/12497350/pjsip-receive-sms Yeah, definitely need tutorials on basic things with pjsip. Library is great and can be compiled and used in almost any language since it's C. – C0D3 Sep 20 '12 at 14:40
4

A SMS is essentially an email delivered to phonenumber@serviceprovider.com. 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.

Blue Wizard
  • 161
  • 5
  • Thanks alot for this info however, I have to use pjsip. I don't have other options :/ – C0D3 Sep 15 '12 at 05:48