SMS

SMS

Sending SMS

to use SMS function it is not required to initialize it. Just use write_buf(); functions and read_buf(); functions as is Done in example part 1:

example part 1
main() { write_buf(SMS, 17, "+3706xxxxxxx", "Device started..."); // Send SMS while (1) { fuel_level = get_val(Sensor_FuelLevel1); // Read fuel level if(fuel_level<low_fuel_level && Send_Fuel_report == 1) // If fuel level is lower than limit and SMS report is activated { write_buf(SMStext, 17,"+3706xxxxxxx", "Fuel level is low"); // Send indication message Delay(3000); } Delay(1000); // Check every 1 second } }

Reading SMS using callback

to read any received SMS it is needed to use callback. Use read_buf(); to get information from SMS as is done in example part 2:

example part 2
public callback (sk) { switch(sk) { case SMS: // If SMS callback event { read_buf(SMStext, 99, sms_text); // Copy SMS to string read_buf(PhoneNumber, 14, number); // Read phone number to string if(strequal("+3706xxxxxxx",number,true,12) == 1) { // Check number if(strequal(sms_text,"OFF",false,3)) // Check message content { Send_Fuel_report = 0; // To turn off reports } else if(strequal(sms_text,"ON",false,2)) // Check message content { Send_Fuel_report = 1; // To turn on reports } low_fuel_level = strval(sms_text,3); // Changes low fuel level } } } return 0; }