Go Down

Topic: how to control gsm only by one phone number? (Read 2170 times) previous topic - next topic

soulhealer

Hello,
i'm trying to control the gsm tc35 only via my phone number.. (all other calls want to be rejected).
But the code below does not work.. Retrieve calling number example doesnot work either
Here is my code

#include <SoftwareSerial.h>
#include <String.h>
char inchar; // Will hold the incoming character from the Serial Port.
char data[20]="6938219287";
SoftwareSerial cell(2,3); //Create a 'fake' serial port. Pin 2 is the Rx pin, pin 3 is the Tx pin.
int numring=0;
int comring=2;
int onoff=0; // 0 = off, 1 = on

void setup()
{
  pinMode(5, OUTPUT);// starts a fan
  pinMode(13, OUTPUT); // LEDs - off = red, on = green
  digitalWrite(5, LOW);
  digitalWrite(13, LOW);
  //Initialize serial port for communication.
  cell.begin(9600);
  delay(10);
  Serial.begin(9600);
  delay(10);
  cell.println("AT+CLIP=1");
  cell.println("\x1A");
  //cell.println("ATE=0");
  //delay(1000);
  Serial.println("Ready to excecute your commands");
  delay(100);
}

void doSomething()
{
  if (onoff==0)
  {
    onoff=1;
    digitalWrite(13, LOW);
    digitalWrite(5, LOW);
   
  }
  else
    if (onoff==1)
    {
      onoff=0;
      digitalWrite(13, HIGH);
      digitalWrite(5, HIGH);
     
    }
}

void loop()
{
  //If a character comes in from the cellular module...
  while(cell.available() >0)
  {
   
    inchar=cell.read();
    delay(10);
    Serial.print(inchar);
   
    if(strstr(data, "6938219287"))
    numring++;
            if (numring==comring)
            {
              numring=0; // reset ring counter
     doSomething;
     }break;
   }     
}

Any ideas??

gershwinv

According to what I make out is in my case the number has to be store on my simcard with a national format not international with +27 etc according country code. with AT Command you will write it as AT+CPBW=1,0418068210,161 the 1 is possition and 161 is the national format. Then you can try this in your sketch. I hope this help. :)



Quote

void loop()
{
    //Chekcs status of call
  stat=call.CallStatusWithAuth(number,1,3);
  //If the incoming call is from an authorized number
  //saved on SIM in the positions range from 1 to 3.
  if(stat==CALL_INCOM_VOICE_AUTH){
    //Hang up the call.
    //delay(1000);
     call.HangUp();
    delay(2000);
          Serial.print("Number ");
          Serial.print(number);
          Serial.println(" authorized !");

ghennet

Code: [Select]

if (sms.available())  {
   
   
    // Get remote number
    sms.remoteNumber(senderNumber, 14);
   
    if (memcmp(senderNumber, "+393939954123",13) == 0 ) {
      // do something
   } else {
     // nothing to do
  }

Go Up