Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Android.cpp
- Revision:
- 0:9b41a36d03d9
- Child:
- 1:6d9353593c3c
diff -r 000000000000 -r 9b41a36d03d9 Android.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Android.cpp Sun Jan 07 11:59:16 2018 +0000 @@ -0,0 +1,38 @@ + + +#include "mbed.h" +#include "Android.h" + +Android::Android(PinName txPin, PinName rxPin): serial(txPin, rxPin), myled(LED1) { + //Serial pc(USBTX, USBRX); // tx, rx + + this->serial.baud(115200); + this->serial.attach(callback(this, &Android::onData)); + + this->ticker.attach(callback(this, &Android::hearthBeat), 2.0); +} + +void Android::hearthBeat(void) +{ + this->myled = !this->myled; + printf("HEARTH BEAT SENT\n"); + this->serial.printf("ARD_HB"); + this->serial.putc(-91); + this->serial.printf("OK"); + this->serial.putc(-91); + +} + +void Android::onData(void) +{ + char command[50]; + int product; + if (this->serial.readable()) { + this->serial.scanf("%s", &command); + this->serial.scanf("%d", &product); + printf(command); + printf("%d", product); + + printf("Command Received: \r\n"); + } +}