Skip to content

Instantly share code, notes, and snippets.

@buildcircuit
Created October 23, 2012 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buildcircuit/3939728 to your computer and use it in GitHub Desktop.
Save buildcircuit/3939728 to your computer and use it in GitHub Desktop.
Send SMS- Amarino Evaluation shield
#include <MeetAndroid.h>
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(13, 12, 10, 9, 8, 7);
MeetAndroid meetAndroid;
String string;
void setup()
{
Serial.begin(9600);
// register callback functions, which will be called when an associated event occurs.
// - the first parameter is the name of your function (see below)
// - match the second parameter ('A', 'B', 'a', etc...) with the flag on your Android application
meetAndroid.registerFunction(stringValue, 'A');
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("SMS display");
}
void loop()
{
meetAndroid.receive(); // you need to keep this in your loop() to receive events
}
/*
* Will be called as soon as you receive a phone state event.
*
* Use a switch statement to determine which kind of phone state event you got
* note: flag is in this case 'A' and numOfValues is 1
*/
void stringValue(byte flag, byte numOfValues)
{
// first we need to know how long the string was in order to prepare an array big enough to hold it.
// you should know that: (length == 'length of string sent from Android' + 1)
// due to the '\0' null char added in Arduino
int length = meetAndroid.stringLength();
// define an array with the appropriate size which will store the string
char data[length];
// tell MeetAndroid to put the string into your prepared array
meetAndroid.getString(data);
// go and do something with the string, here we simply send it back to Android
meetAndroid.send(data);
lcd.clear();
lcd.print(data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment