Hello,
I send SMS from nRF9160 to my number using following method.
1. Open LTE Socket
2. Send AT Commands:
a. AT+ CFUN?
b. AT + CFUN = 1
c. AT+ CFUN?
d. AT + CEREG?
e. AT + CNMI = 3, 2, 0, 1
f. AT + CMGS command
3. Close the LTE Socket.
Then I use mqtt_simple sample to send the data from nRF9160 to server.
Both SMS and MQTT work individually.
Now I want to add SMS and MQTT in one program. As soon as the board starts, LTE link should be connected and the data should be sent to mqtt server like mqtt_simple sample. Now if there is any interrupt like button press the SMS should be sent. So how can I add AT commands to send SMS in mqtt_simple sample. In MQTT sample, already lte link is connected, so while sending SMS there is no need to connect again to lte link? What are the AT commands used for MQTT simple sample?
Is it like this: on button press I just have to send AT + CEREG?, AT + CNMI = 3, 2, 0, 1 and AT + CMGS command. So SMS will be sent and the data is also sent to the mqtt server?
But I don't know what are the AT commands used in MQTT sample. So I have not tried this yet.
Edit: I studied mqtt_simple sample. In at_cmd.c file, lte socket is opened and at_cmd_write function is defined which is used to write the at commands. So I tried to use this at_cmd_write function in main application, but shows error (undeclared function). So how can I use it in my main application to send the AT commands on LTE socket which is already opened?