I have an algorithm regarding the sim808 module and want to convert that code in pure c or c++ code.
- send “AT” command to module.
- wait until valid “OK” response from the module.
- If a response is valid then execute code otherwise do nothing.
My purpose of c or c++ code is when I switch to another controller I have to change only serial (usart ) setting and the rest of the code will remain same.
As a beginnner i need suggestion on it. I tried it on Arduino UNO but not able to write proper code.
SoftwareSerial sim(6,7);//rx tx
char received_data; //variable to store read data
if(sim.available()>0) //check for any data received
received_data = sim.read(); //read received data
Serial.print("received data is: ");
Serial.println(received_data); //display received data
I tried this code to write in c but not successful in it. Above code working but output response is not proper I dont know why reponse goes to another line each time?
I was thinking like this function to write,
void send_command_response(“AT”, “OK”);
Whenever I want to send command I just need to change command and response from function void send_command_response(“AT”, “OK”); and the rest of the work will be done by a controller according to condition.
Your help would be appreciated.