https://sites.google.com/site/doubleoops/mini-blog/amarinowithsoftwareserial/MeetAndroid.cpp?attredirects=0&d=1I wanted to use Amarino such that the Bluetooth module was communicating with an Arduino via SoftwareSerial. I have nefarious plans for later that require the regular hardware-based Serial for something other than Bluetooth (hint: XBee!).This diff, applied to Amarino's MeetAndroid library v.4, adds SoftwareSerial capability (compiled against Arduino version 1.0). [Update: Added the actual MeetAndroid.cpp and MeetAndroid.h files as attachments to this page.] UsageSince this is based on SoftwareSerial, some caveats apply (scroll down to the "Limitations" section). Otherwise:
Other than the new constructor, MeetAndroid's API is unchanged. All other public methods work exactly as before.TestingMy test setup was an Arduino UNO with a Bluesmirf Gold Bluetooth modem running the sketch below and a Motorola XOOM, running Amarino, logging Bluetooth events. I discovered no conflicts (blocking, etc.) using both streams interspersed. #include <MeetAndroid.h>#include <Wire.h>#include <SoftwareSerial.h>// inits a SoftwareSerial BT connection on rxPin=4, txPin=3, with baud=115200MeetAndroid meetAndroid(4,3, 115200);void setup(){ Serial.begin(115200);}void loop(){ if(Serial.available() > 0) { char incomingByte = Serial.read(); meetAndroid.send(incomingByte); meetAndroid.send('\0'); Serial.println(incomingByte, HEX); }} |
