Click here to Skip to main content
15,886,080 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i am currently doing project in which i want to reply to sender without coding any phone number into code and i cant understand how to use emmiting no. while holding number in remoteNumber do work but while sending sms back requires number as "remotenumber" not as remotenumber

What I have tried:

  Serial.println("Message received from:");

  // Get remote number
  sms.remoteNumber(remoteNumber, 20);
  Serial.println(remoteNumber);

sms.beginSMS(remoteNumber);
sms.print("this is too hard");
sms.endSMS();
Serial.println("\nCOMPLETE!\n");
Posted
Updated 16-Feb-20 20:46pm
Comments
Richard MacCutchan 16-Feb-20 7:28am    
What?
kick_start 17-Feb-20 0:53am    
SIR I WANT TO USE STORED NUMBER IN CHAR FROM RECIVED SMS. BUT I AM NOT GETTING SUCCEED IN IT CAUSE IT NEEDS NUMBER IN DOUBLE INVERTED COMMAS BUT HOW TO DO IT
??????????????????????
phil.o 17-Feb-20 3:12am    
No need to shout at us.

If I understand you correctly, you want to reproduce a string (the remote number) within a new string, and enclose it in double quotes (what you called inverted double comma). You can do it like this:
C++
#include <iostream>
#include <strstream>
int main()
{
    auto remotenumber = "0123456";
    std::strstream message;
    message << "The number is \"" << remotenumber << "\"." << std::endl;
    cout << message.str();

    return 0;
}

The output is:
The number is "0123456".

The leading '\' is called an escape character. You can use it for lots of special stuff. In this case to prevent the compiler from interpreting the double quote as 'end of string'. A full list of escape sequences can be found here: Escape sequences in C - Wikipedia[^]
 
Share this answer
 
v4
Comments
CPallini 17-Feb-20 4:20am    
5.
Stefan_Lang 17-Feb-20 4:48am    
Thank you.
kick_start 20-Feb-20 5:58am    
#include <gsm.h>
#define PINNUMBER ""
GSM gsmAccess; // include a 'true' parameter for debug enabled
GSM_SMS sms;

char remoteNumber[20]; // Holds the emitting number

void setup()
{
Serial.begin(9600);
Serial.println("SMS Messages Receiver");
boolean notConnected = true;
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized");
Serial.println("Waiting for messages");
}

void loop()
{
char c;

// If there are any SMSs available()
if (sms.available())
{
Serial.println("Message received from:");

// Get remote number
sms.remoteNumber(remoteNumber, 20);

Serial.println(remoteNumber);

sms.beginSMS(remoteNumber);
sms.print("all working good");
sms.endSMS();

Serial.println("\nCOMPLETE!\n");
Serial.println("\nEND OF MESSAGE");
sms.flush();
Serial.println("MESSAGE DELETED");
}
}
kick_start 20-Feb-20 6:02am    
not working for me can you please cross check no processes after showing message recieved from
Stefan_Lang 20-Feb-20 7:14am    
'not working' is not sufficient information. Also I don't see that you even used my suggestion to fix your problem. Why do you expect it's suddenly 'working' now?
Is this what you need? Arduino - GSMExamplesSendSMS[^]
 
Share this answer
 
Comments
kick_start 17-Feb-20 0:51am    
NO SIR I KNOW HOW TO SEND SMS. BUT IN MY CODE I AM USING CHAR TO STORE REMOTE NUMBER EMITTED FROM GSM BUT I CANT DIRECTLY USE IT. IT NEEDS TO BE PUT IN DOUBLE INVERTED COMMAS. AND I DONT KNOW HOW TO DO IT.
phil.o 17-Feb-20 3:13am    
Please don't shout.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900