Receiving an SMS message

To receive notification of incoming SMS messages, you must first write the register_message_filter_listener command (with the port parameter defined) to the SMS control object. Because this is a server object, to observe the response, you must force the shell to keep the file descriptor open. In the following example, we use the exec command to do this, then direct the response messages to stderr:

# (exec 3<> /pps/services/cellular/sms/control_private?wait && cat >&3
 && sleep 1 && cat <&3)<<END
> msg::register_message_filter_listener
> id::1111
> dat:json:{"port":-559038737}
> END

If the message registration command is successful, the response is:

@control_private
res::register_message_filter_listener
id::1111
dat:json:{"messageFilterId":0}
success:b:true

When an SMS message is received, the SMS service publishes the message details to this same PPS object:

@control_private
msg::receive_message
dat:json:{"messageId":1,"senderAddress":"+nnnnnnnnnnn",
 "payload":"Hello from QNX","encoding":"utf-8","class":4,
 "serviceCenterTimeStamp":"1427464858000","totalSegments":1,
 "receivedSegments":1}

Here, nnnnnnnnnnn is an actual phone number, including the country code and area code.

The logging information shows the following:

Mar 27 09:59:19.859  qwf_cellular_services.2515004            high_rate   3110  
 process_register_message_filter_listener: SMS_Service: processing SMS Client Registration
 register_message_filter_listener [ PPS ID=1111 ] to SMS Client with name=@control_private.
1821068828734
Mar 27 09:59:19.859  qwf_cellular_services.2515004            high_rate   3110  
 process_register_message_filter_listener: SMS_Service: Sender Address=[0]
Mar 27 09:59:19.859  qwf_cellular_services.2515004            high_rate   3110  
 process_register_message_filter_listener: SMS_Service: Payload Regex=[0]
Mar 27 09:59:19.860  qwf_cellular_services.2515004            high_rate   3110  
 process_register_message_filter_listener: SMS_Service: port=-559038737
Mar 27 09:59:19.860  qwf_cellular_services.2515004            high_rate   3110  
 process_register_message_filter_listener: SMS_Service: Substring - None

Mar 27 10:01:01.546          qwf_crm_telit.2543682            high_rate   1011         
      SmsDecodeUserData: message payload: 48 65 6C 6C 6F 20 66 72 6F 6D 20 51 4E 58  
 <14 bytes>

Mar 27 10:01:01.546          qwf_crm_telit.2543682             low_rate   1011  QWF_TR 
 LP_SMS_RCVD

Mar 27 10:01:01.546  qwf_cellular_services.2515004            high_rate   3110  QWF_TR 
           process_downlink_sm: SMS_Service: Processing downlink SMS message

Mar 27 10:01:01.546  qwf_cellular_services.2515004            high_rate   3110  QWF_TR 
          send_receive_message: SMS_Service: Delivering MT SM to client [1821068828734]