This is the Pubnub library for MBed2 ("classic") with the "sync" interface. It is based on the Pubnub C-core library.

Dependencies:   Pubnub_c_core_mbed2_pal

Dependents:   Pubnub_ATT_IoT_SK_WNC_sync Pubnub_ATT_IOT_SK_WNC_AnalogIn_Issue Pubnub_ATT_IoT_SK_WNC_sync_3_27_Fork pubnub_sync

Committer:
sveljko
Date:
Thu Nov 10 22:25:17 2016 +0000
Revision:
0:243e0d70a1d5
Initial commit of the Pubnub library for MBed2 with the "sync" interface.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sveljko 0:243e0d70a1d5 1 /* -*- c-file-style:"stroustrup"; indent-tabs-mode: nil -*- */
sveljko 0:243e0d70a1d5 2 #include "pubnub_ntf_sync.h"
sveljko 0:243e0d70a1d5 3
sveljko 0:243e0d70a1d5 4 #include "pbpal.h"
sveljko 0:243e0d70a1d5 5 #include "pubnub_internal.h"
sveljko 0:243e0d70a1d5 6 #include "pubnub_assert.h"
sveljko 0:243e0d70a1d5 7 #include "pubnub_log.h"
sveljko 0:243e0d70a1d5 8
sveljko 0:243e0d70a1d5 9 #include "pbntf_trans_outcome_common.h"
sveljko 0:243e0d70a1d5 10
sveljko 0:243e0d70a1d5 11
sveljko 0:243e0d70a1d5 12 int pbntf_init(void)
sveljko 0:243e0d70a1d5 13 {
sveljko 0:243e0d70a1d5 14 return 0;
sveljko 0:243e0d70a1d5 15 }
sveljko 0:243e0d70a1d5 16
sveljko 0:243e0d70a1d5 17
sveljko 0:243e0d70a1d5 18 int pbntf_got_socket(pubnub_t *pb, pb_socket_t socket)
sveljko 0:243e0d70a1d5 19 {
sveljko 0:243e0d70a1d5 20 PUBNUB_UNUSED(socket);
sveljko 0:243e0d70a1d5 21 if (PUBNUB_BLOCKING_IO_SETTABLE) {
sveljko 0:243e0d70a1d5 22 pbpal_set_blocking_io(pb);
sveljko 0:243e0d70a1d5 23 }
sveljko 0:243e0d70a1d5 24 return +1;
sveljko 0:243e0d70a1d5 25 }
sveljko 0:243e0d70a1d5 26
sveljko 0:243e0d70a1d5 27
sveljko 0:243e0d70a1d5 28 void pbntf_update_socket(pubnub_t *pb, pb_socket_t socket)
sveljko 0:243e0d70a1d5 29 {
sveljko 0:243e0d70a1d5 30 PUBNUB_UNUSED(socket);
sveljko 0:243e0d70a1d5 31 PUBNUB_UNUSED(pb);
sveljko 0:243e0d70a1d5 32 }
sveljko 0:243e0d70a1d5 33
sveljko 0:243e0d70a1d5 34
sveljko 0:243e0d70a1d5 35 void pbntf_lost_socket(pubnub_t *pb, pb_socket_t socket)
sveljko 0:243e0d70a1d5 36 {
sveljko 0:243e0d70a1d5 37 PUBNUB_UNUSED(socket);
sveljko 0:243e0d70a1d5 38 PUBNUB_UNUSED(pb);
sveljko 0:243e0d70a1d5 39 }
sveljko 0:243e0d70a1d5 40
sveljko 0:243e0d70a1d5 41
sveljko 0:243e0d70a1d5 42 void pbntf_trans_outcome(pubnub_t *pb)
sveljko 0:243e0d70a1d5 43 {
sveljko 0:243e0d70a1d5 44 PBNTF_TRANS_OUTCOME_COMMON(pb);
sveljko 0:243e0d70a1d5 45 }
sveljko 0:243e0d70a1d5 46
sveljko 0:243e0d70a1d5 47
sveljko 0:243e0d70a1d5 48 int pbntf_enqueue_for_processing(pubnub_t *pb)
sveljko 0:243e0d70a1d5 49 {
sveljko 0:243e0d70a1d5 50 PUBNUB_UNUSED(pb);
sveljko 0:243e0d70a1d5 51 return 0;
sveljko 0:243e0d70a1d5 52 }
sveljko 0:243e0d70a1d5 53
sveljko 0:243e0d70a1d5 54
sveljko 0:243e0d70a1d5 55 int pbntf_requeue_for_processing(pubnub_t *pb)
sveljko 0:243e0d70a1d5 56 {
sveljko 0:243e0d70a1d5 57 PUBNUB_UNUSED(pb);
sveljko 0:243e0d70a1d5 58
sveljko 0:243e0d70a1d5 59 return 0;
sveljko 0:243e0d70a1d5 60 }
sveljko 0:243e0d70a1d5 61
sveljko 0:243e0d70a1d5 62
sveljko 0:243e0d70a1d5 63 int pbntf_watch_in_events(pubnub_t *pbp)
sveljko 0:243e0d70a1d5 64 {
sveljko 0:243e0d70a1d5 65 PUBNUB_UNUSED(pbp);
sveljko 0:243e0d70a1d5 66 return 0;
sveljko 0:243e0d70a1d5 67 }
sveljko 0:243e0d70a1d5 68
sveljko 0:243e0d70a1d5 69
sveljko 0:243e0d70a1d5 70 int pbntf_watch_out_events(pubnub_t *pbp)
sveljko 0:243e0d70a1d5 71 {
sveljko 0:243e0d70a1d5 72 PUBNUB_UNUSED(pbp);
sveljko 0:243e0d70a1d5 73 return 0;
sveljko 0:243e0d70a1d5 74 }
sveljko 0:243e0d70a1d5 75
sveljko 0:243e0d70a1d5 76
sveljko 0:243e0d70a1d5 77 enum pubnub_res pubnub_last_result(pubnub_t *pb)
sveljko 0:243e0d70a1d5 78 {
sveljko 0:243e0d70a1d5 79 enum pubnub_res result;
sveljko 0:243e0d70a1d5 80 PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
sveljko 0:243e0d70a1d5 81
sveljko 0:243e0d70a1d5 82 pubnub_mutex_lock(pb->monitor);
sveljko 0:243e0d70a1d5 83 if (pb->state != PBS_IDLE) {
sveljko 0:243e0d70a1d5 84 pbnc_fsm((pubnub_t*)pb);
sveljko 0:243e0d70a1d5 85 }
sveljko 0:243e0d70a1d5 86 result = pb->core.last_result;
sveljko 0:243e0d70a1d5 87 pubnub_mutex_unlock(pb->monitor);
sveljko 0:243e0d70a1d5 88
sveljko 0:243e0d70a1d5 89 return result;
sveljko 0:243e0d70a1d5 90 }
sveljko 0:243e0d70a1d5 91
sveljko 0:243e0d70a1d5 92
sveljko 0:243e0d70a1d5 93 enum pubnub_res pubnub_await(pubnub_t *pb)
sveljko 0:243e0d70a1d5 94 {
sveljko 0:243e0d70a1d5 95 enum pubnub_res result;
sveljko 0:243e0d70a1d5 96 PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
sveljko 0:243e0d70a1d5 97
sveljko 0:243e0d70a1d5 98 pubnub_mutex_lock(pb->monitor);
sveljko 0:243e0d70a1d5 99 while (pb->state != PBS_IDLE) {
sveljko 0:243e0d70a1d5 100 pbnc_fsm(pb);
sveljko 0:243e0d70a1d5 101 }
sveljko 0:243e0d70a1d5 102 result = pb->core.last_result;
sveljko 0:243e0d70a1d5 103 pubnub_mutex_unlock(pb->monitor);
sveljko 0:243e0d70a1d5 104
sveljko 0:243e0d70a1d5 105 return result;
sveljko 0:243e0d70a1d5 106 }