Jeen Camilo
Jeen Camilo

Reputation: 1

error: no 'void sim::sendSMS(char*)' member function declared in class 'sim'

Hey guys I'm getting this error when compiling in Arduino IDE

error: no 'void sim::sendSMS(char*)' member function declared in class 'sim'

void sim::sendSMS(char msg[160])

My Header file is:

#ifndef sim_h
#define sim_h

#include "Arduino.h"

class sim
{
public:
sim();
void smstextmode();
void testSIM900();
void sendSMS(char _msg[160]);
private:
char _msg[160];
};

#endif

My CPP file:

#include "Arduino.h"
#include "sim.h"

sim::sim()
{
 _msg= msg;
}

void sim::smstextmode()
{
  Serial1.write("AT+CMGF=1\r\n");
  delay(2000); 
}

void sim::testSIM900()
{
  Serial1.write("AT\r\n");
  delay(1000);
  Serial1.write("AT+CSCS?\r\n");
  delay(1000);
}

void sim::sendSMS(char msg[160])
{
  Serial1.write("AT+CMGS=\"+8295724554\"\r\n");
  delay(1500);
  Serial1.write(msg);
  delay(1000);
  Serial1.write((char) 26)

}

Upvotes: 0

Views: 85

Answers (1)

KIIV
KIIV

Reputation: 3739

So many mistakes. For example:

sim::sim()
{
   _msg= msg;  // where it should get this msg?
               // Also it's not possible to do a copy of array like this.
}

Why do you need _msg, if you are sending msg passed as a parameter?

void sim::sendSMS(char msg[160])

If you want to call it, you have to use exactly the same data type:

char something[160] = "some text to send";
instance.sendSMS(something);

But you can't just pass string directly:

instance.sendSMS("some text to send");

as it's type of const char * and it can't be handled by type char[160].

Also you don't count with termination characte at the end of the string.

Upvotes: 0

Related Questions