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.
Fork of MilkcocoaOsSample_Eth by
Revision 8:7d2252cf70e1, committed 2018-02-15
- Comitter:
- jksoft
- Date:
- Thu Feb 15 20:51:54 2018 +0000
- Parent:
- 7:a0ba4c04a63c
- Child:
- 9:9bcdb7b2cd1b
- Commit message:
- ???????Milkcocoa?push??
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Sep 06 06:00:12 2017 +0000
+++ b/main.cpp Thu Feb 15 20:51:54 2018 +0000
@@ -4,10 +4,12 @@
EthernetInterface eth;
RawSerial pc(USBTX,USBRX);
+DigitalIn input(D7);
+//AnalogIn input(A0);
/************************* Your Milkcocoa Setup *********************************/
-#define MILKCOCOA_APP_ID "...YOUR_MILKCOCOA_APP_ID..."
+#define MILKCOCOA_APP_ID "postite082h1"
#define MILKCOCOA_DATASTORE "mbed_lan"
/************* Milkcocoa Setup (you don't need to change this!) ******************/
@@ -18,7 +20,7 @@
const char MQTT_SERVER[] = MILKCOCOA_APP_ID ".mlkcca.com";
const char MQTT_CLIENTID[] = __TIME__ MILKCOCOA_APP_ID;
-extern void onpush(MQTT::MessageData& md);
+//extern void onpush(MQTT::MessageData& md);
int main() {
@@ -36,30 +38,26 @@
milkcocoa->connect();
- pc.printf("%d\n\r",milkcocoa->on(MILKCOCOA_DATASTORE, "push", onpush));
+ //pc.printf("%d\n\r",milkcocoa->on(MILKCOCOA_DATASTORE, "push", onpush));
-#ifdef __MILKCOCOA_THREAD
- milkcocoa->setLoopCycle(5000);
- milkcocoa->start();
-#endif
while(1) {
DataElement elem = DataElement();
- elem.setValue("v", 1);
+ elem.setValue("input", input);
milkcocoa->push(MILKCOCOA_DATASTORE, elem);
-#ifndef __MILKCOCOA_THREAD
milkcocoa->loop();
-#endif
Thread::wait(7000);
}
}
+#if 0
void onpush(MQTT::MessageData& md)
{
MQTT::Message &message = md.message;
DataElement de = DataElement((char*)message.payload);
pc.printf("onpush\n\r");
pc.printf("%d\n\r",de.getInt("v"));
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
