hi
i want to manipulate a sim800l without api,when i excute AT commands directly every thing is fine but when using the code below its not working,whats the wrong with the code
#include <SoftwareSerial.h>
#include <String.h>
//SIM800 TX is connected to Arduino D8
#define SIM800_TX_PIN 7
//SIM800 RX is connected to Arduino D7
#define SIM800_RX_PIN 8
boolean demander_solde;
char reponce[200];
//Create software serial object to communicate with SIM800
SoftwareSerial sim800l(SIM800_TX_PIN, SIM800_RX_PIN);
void setup() {
// put your setup code here, to run once:
Serial.begin(4800);
while (!Serial);
sim800l.begin(9600);
while (!sim800l);
delay(2000);
demander_solde = true;
}
void demanderSolde(){
char ch;
int i=0;
Serial.write("exec:sim800l.println(\"AT+CUSD=2\");");
delay(2000);
sim800l.println("AT+CUSD=2");
while (!sim800l.available()>0);
while ((int)ch!=43)
{if(ch=sim800l.read());reponce[i]==ch;i++;Serial.write((int)ch);}
Serial.write(reponce);
delay(2000);
/* while (!sim800l.available()>0);
while (ch!=43) {ch=sim800l.read();reponce[i]==ch;i++;}
Serial.write(reponce); */
delay(2000);
clearReponce(i);
i=0;
Serial.write("exec:sim800l.println(\"AT+CUSD=1\");");
delay(2000);
sim800l.println("AT+CUSD=1");
while (!sim800l.available()>0);
while ((int)ch!=43){
if(ch=sim800l.read());reponce[i]==ch;i++;
Serial.write((int)ch);
}
Serial.write(reponce);
delay(2000);
/*while (!sim800l.available()>0);
while (ch!=43){ch=sim800l.read();reponce[i]==ch;i++;}
Serial.write(reponce);*/
delay(2000);
clearReponce(i);
i=0;
Serial.write("exec:sim800l.println(\"AT+CUSD=1,\"*222#\"\");");
delay(2000);
sim800l.println("AT+CUSD=1,\"*222#\"");
while (!sim800l.available()>0);
while ((int)ch!=43){
if(ch=sim800l.read());reponce[i]==ch;Serial.write(reponce);i++;
Serial.write((int)ch);
}
Serial.write(reponce);
delay(2000);
/*while (!sim800l.available()>0)
while (ch!=43){
{ch=sim800l.read();reponce[i]==ch;i++;}
Serial.write(reponce);
} */
delay(2000);
clearReponce(i);
demander_solde=false;
}
void clearReponce(int _i){
for(int i=0;i==_i;i++){reponce[i]==0;}
Serial.println("reponce:");
Serial.write(reponce);
delay(2000);
}
void loop() {
if(demander_solde){
demanderSolde();
}
}