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.
Dependencies: Pubnub_mbed2_sync WNCInterface mbed-rtos mbed
Fork of WNCInterface_M2XMQTTdemo by
Revision 10:f05fb235b75b, committed 2016-11-11
- Comitter:
- sveljko
- Date:
- Fri Nov 11 22:49:05 2016 +0000
- Parent:
- 9:dcb02cfdc63c
- Commit message:
- Added generating the UUID, using the rand() and setting srand() from pubnub_time()
Changed in this revision
| Pubnub_mbed2_sync.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Pubnub_mbed2_sync.lib Thu Nov 10 22:48:18 2016 +0000 +++ b/Pubnub_mbed2_sync.lib Fri Nov 11 22:49:05 2016 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/sveljko/code/Pubnub_mbed2_sync/#9fbec3606b08 +https://developer.mbed.org/users/sveljko/code/Pubnub_mbed2_sync/#4d49720c7200
--- a/main.cpp Thu Nov 10 22:48:18 2016 +0000
+++ b/main.cpp Fri Nov 11 22:49:05 2016 +0000
@@ -2,13 +2,31 @@
#include "WNCInterface.h"
#include "pubnub_sync.h"
+#include "srand_from_pubnub_time.h"
+
#define CRLF "\r\n"
WNCInterface eth;
MODSERIAL pc(USBTX,USBRX,256,256);
-extern "C" int myprintf(char *, ...) { return 0; }
+
+static void generate_uuid(pubnub_t *pbp)
+{
+ char const *uuid_default = "zeka-peka-iz-jendeka";
+ struct Pubnub_UUID uuid;
+ static struct Pubnub_UUID_String str_uuid;
+
+ if (0 != pubnub_generate_uuid_v4_random(&uuid)) {
+ pubnub_set_uuid(pbp, uuid_default);
+ }
+ else {
+ str_uuid = pubnub_uuid_to_string(&uuid);
+ pubnub_set_uuid(pbp, str_uuid.uuid);
+ pc.printf("Generated UUID: %s\n", str_uuid.uuid);
+ }
+}
+
int main()
{
@@ -20,8 +38,12 @@
pc.printf("IP Address: %s" CRLF, eth.getIPAddress());
eth.doDebug(1);
+
pubnub_t *pbp = pubnub_alloc();
pubnub_init(pbp, "demo", "demo");
+
+ srand_from_pubnub_time(pbp);
+ generate_uuid(pbp);
while (true) {
pubnub_res rslt = pubnub_publish(pbp, "hello_world", "\"Hello world from MBed WNC!\"");
