Junichi Katsu / Milkcocoa-os

Dependents:   mbed-os-example-wifi-milkcocoa MilkcocoaOsSample_Eth MilkcocoaOsSample_ESP8266 MilkcocoaOsSample_Eth_DigitalIn

Committer:
jksoft
Date:
Wed Jun 14 07:48:45 2017 +0000
Revision:
8:e2f15b1b4f70
Parent:
7:f1e123331cad
Child:
9:5c195c1036da
?????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:0a2f634d3324 1 #include "Milkcocoa.h"
jksoft 0:0a2f634d3324 2
jksoft 6:1b5ec3a15d67 3 #if 0
jksoft 0:0a2f634d3324 4 extern RawSerial pc;
jksoft 0:0a2f634d3324 5
jksoft 0:0a2f634d3324 6 #define DBG(x) x
jksoft 0:0a2f634d3324 7 #else
jksoft 0:0a2f634d3324 8 #define DBG(x)
jksoft 0:0a2f634d3324 9 #endif
jksoft 0:0a2f634d3324 10
jksoft 0:0a2f634d3324 11 DataElement::DataElement() {
jksoft 0:0a2f634d3324 12 json_msg[0] = '\0';
jksoft 0:0a2f634d3324 13 strcpy(json_msg,"{\"params\":{");
jksoft 0:0a2f634d3324 14 }
jksoft 0:0a2f634d3324 15
jksoft 0:0a2f634d3324 16 DataElement::DataElement(char *json_string) {
jksoft 0:0a2f634d3324 17 json_msg[0] = '\0';
jksoft 0:0a2f634d3324 18 strcpy(json_msg,json_string);
jksoft 0:0a2f634d3324 19 }
jksoft 0:0a2f634d3324 20
jksoft 0:0a2f634d3324 21 void DataElement::setValue(const char *key, const char *v) {
jksoft 0:0a2f634d3324 22 char json_string[64];
jksoft 0:0a2f634d3324 23 if( json_msg[strlen(json_msg)-1] != '{' )
jksoft 0:0a2f634d3324 24 {
jksoft 0:0a2f634d3324 25 strcat(json_msg,",");
jksoft 0:0a2f634d3324 26 }
jksoft 0:0a2f634d3324 27 sprintf(json_string,"\"%s\":\"%s\"",key,v);
jksoft 0:0a2f634d3324 28 strcat(json_msg,json_string);
jksoft 0:0a2f634d3324 29 }
jksoft 0:0a2f634d3324 30
jksoft 0:0a2f634d3324 31 void DataElement::setValue(const char *key, int v) {
jksoft 0:0a2f634d3324 32 char json_string[64];
jksoft 0:0a2f634d3324 33 if( json_msg[strlen(json_msg)-1] != '{' )
jksoft 0:0a2f634d3324 34 {
jksoft 0:0a2f634d3324 35 strcat(json_msg,",");
jksoft 0:0a2f634d3324 36 }
jksoft 0:0a2f634d3324 37 sprintf(json_string,"\"%s\":\"%d\"",key,v);
jksoft 0:0a2f634d3324 38 strcat(json_msg,json_string);
jksoft 0:0a2f634d3324 39 }
jksoft 0:0a2f634d3324 40
jksoft 0:0a2f634d3324 41 void DataElement::setValue(const char *key, double v) {
jksoft 0:0a2f634d3324 42 char json_string[64];
jksoft 0:0a2f634d3324 43 if( json_msg[strlen(json_msg)-1] != '{' )
jksoft 0:0a2f634d3324 44 {
jksoft 0:0a2f634d3324 45 strcat(json_msg,",");
jksoft 0:0a2f634d3324 46 }
jksoft 0:0a2f634d3324 47 sprintf(json_string,"\"%s\":\"%f\"",key,v);
jksoft 0:0a2f634d3324 48 strcat(json_msg,json_string);
jksoft 0:0a2f634d3324 49 }
jksoft 0:0a2f634d3324 50
jksoft 0:0a2f634d3324 51 char *DataElement::getString(const char *key) {
jksoft 0:0a2f634d3324 52 static char _word[64];
jksoft 0:0a2f634d3324 53 char *p;
jksoft 0:0a2f634d3324 54 int i=0;
jksoft 0:0a2f634d3324 55
jksoft 0:0a2f634d3324 56 strcpy(_word , "\"\0");
jksoft 0:0a2f634d3324 57 strcat(_word , key );
jksoft 0:0a2f634d3324 58 strcat(_word , "\"" );
jksoft 0:0a2f634d3324 59
jksoft 0:0a2f634d3324 60 p = strstr( (char*)json_msg , _word ) + 2 + strlen(_word);
jksoft 0:0a2f634d3324 61
jksoft 0:0a2f634d3324 62 while( (p[i] != ',')&&(p[i] != '\n')&&(p[i] != '\"') )
jksoft 0:0a2f634d3324 63 {
jksoft 0:0a2f634d3324 64 _word[i] = p[i];
jksoft 0:0a2f634d3324 65 i++;
jksoft 0:0a2f634d3324 66 }
jksoft 0:0a2f634d3324 67 _word[i] = '\0';
jksoft 0:0a2f634d3324 68
jksoft 0:0a2f634d3324 69 return _word;
jksoft 0:0a2f634d3324 70 }
jksoft 0:0a2f634d3324 71
jksoft 0:0a2f634d3324 72 int DataElement::getInt(const char *key) {
jksoft 0:0a2f634d3324 73 return atoi(getString(key));
jksoft 0:0a2f634d3324 74 }
jksoft 0:0a2f634d3324 75
jksoft 0:0a2f634d3324 76 float DataElement::getFloat(const char *key) {
jksoft 0:0a2f634d3324 77 return atof(getString(key));
jksoft 0:0a2f634d3324 78 }
jksoft 0:0a2f634d3324 79
jksoft 0:0a2f634d3324 80 char *DataElement::toCharArray() {
jksoft 0:0a2f634d3324 81 if( json_msg[strlen(json_msg)-1] != '{' )
jksoft 0:0a2f634d3324 82 {
jksoft 0:0a2f634d3324 83 strcat(json_msg,"}");
jksoft 0:0a2f634d3324 84 }
jksoft 0:0a2f634d3324 85 strcat(json_msg,"}");
jksoft 0:0a2f634d3324 86
jksoft 0:0a2f634d3324 87 return(json_msg);
jksoft 0:0a2f634d3324 88 }
jksoft 0:0a2f634d3324 89
jksoft 0:0a2f634d3324 90 Milkcocoa::Milkcocoa(NetworkInterface* nif, const char *host, uint16_t port, const char *_app_id, const char *client_id){
jksoft 0:0a2f634d3324 91 ipstack = new MQTTInterface(nif);
jksoft 0:0a2f634d3324 92 client = new MClient(ipstack);
jksoft 0:0a2f634d3324 93 strcpy(servername,host);
jksoft 0:0a2f634d3324 94 portnum = port;
jksoft 5:dd68fa651637 95 strcpy(app_id,_app_id);
jksoft 0:0a2f634d3324 96 strcpy(_clientid,client_id);
jksoft 0:0a2f634d3324 97 strcpy(username,"sdammy");
jksoft 0:0a2f634d3324 98 strcpy(password,app_id);
jksoft 6:1b5ec3a15d67 99
jksoft 7:f1e123331cad 100 for (int i=0; i<MILKCOCOA_SUBSCRIBERS; i++) {
jksoft 7:f1e123331cad 101 milkcocoaSubscribers[i] = NULL;
jksoft 7:f1e123331cad 102 }
jksoft 8:e2f15b1b4f70 103 connectting = false;
jksoft 8:e2f15b1b4f70 104 mqtt_connectting = false;
jksoft 7:f1e123331cad 105
jksoft 6:1b5ec3a15d67 106 #ifdef __MILKCOCOA_THREAD
jksoft 0:0a2f634d3324 107 setLoopCycle(5000);
jksoft 0:0a2f634d3324 108
jksoft 1:8e4149b53a8a 109 cycleThread1.start(Milkcocoa::threadStarter1,this);
jksoft 1:8e4149b53a8a 110 cycleThread2.start(Milkcocoa::threadStarter2,this);
jksoft 6:1b5ec3a15d67 111 #endif
jksoft 0:0a2f634d3324 112 }
jksoft 0:0a2f634d3324 113
jksoft 0:0a2f634d3324 114 Milkcocoa::Milkcocoa(NetworkInterface* nif, const char *host, uint16_t port, const char *_app_id, const char *client_id, char *_session){
jksoft 0:0a2f634d3324 115 ipstack = new MQTTInterface(nif);
jksoft 0:0a2f634d3324 116 client = new MClient(ipstack);
jksoft 0:0a2f634d3324 117 strcpy(servername,host);
jksoft 0:0a2f634d3324 118 portnum = port;
jksoft 5:dd68fa651637 119 strcpy(app_id,_app_id);
jksoft 0:0a2f634d3324 120 strcpy(_clientid,client_id);
jksoft 0:0a2f634d3324 121 strcpy(username,_session);
jksoft 0:0a2f634d3324 122 strcpy(password,app_id);
jksoft 6:1b5ec3a15d67 123
jksoft 7:f1e123331cad 124 for (int i=0; i<MILKCOCOA_SUBSCRIBERS; i++) {
jksoft 7:f1e123331cad 125 milkcocoaSubscribers[i] = NULL;
jksoft 7:f1e123331cad 126 }
jksoft 8:e2f15b1b4f70 127 connectting = false;
jksoft 8:e2f15b1b4f70 128 mqtt_connectting = false;
jksoft 7:f1e123331cad 129
jksoft 6:1b5ec3a15d67 130 #ifdef __MILKCOCOA_THREAD
jksoft 0:0a2f634d3324 131 setLoopCycle(5000);
jksoft 0:0a2f634d3324 132
jksoft 1:8e4149b53a8a 133 cycleThread1.start(Milkcocoa::threadStarter1,this);
jksoft 1:8e4149b53a8a 134 cycleThread2.start(Milkcocoa::threadStarter2,this);
jksoft 6:1b5ec3a15d67 135 #endif
jksoft 0:0a2f634d3324 136 }
jksoft 0:0a2f634d3324 137
jksoft 0:0a2f634d3324 138 Milkcocoa* Milkcocoa::createWithApiKey(NetworkInterface* nif, const char *host, uint16_t port, const char *_app_id, const char *client_id, char *key, char *secret) {
jksoft 0:0a2f634d3324 139 char session[60];
jksoft 0:0a2f634d3324 140 sprintf(session, "k%s:%s", key, secret);
jksoft 0:0a2f634d3324 141 return new Milkcocoa(nif, host, port, _app_id, client_id, session);
jksoft 0:0a2f634d3324 142 }
jksoft 0:0a2f634d3324 143
jksoft 0:0a2f634d3324 144 void Milkcocoa::connect() {
jksoft 0:0a2f634d3324 145
jksoft 0:0a2f634d3324 146 if(client->isConnected())
jksoft 0:0a2f634d3324 147 return;
jksoft 0:0a2f634d3324 148
jksoft 8:e2f15b1b4f70 149 connectting = true;
jksoft 0:0a2f634d3324 150 if(client->connect(servername, portnum)!=0) {
jksoft 0:0a2f634d3324 151 DBG(pc.printf("Network connect err\r\n");)
jksoft 8:e2f15b1b4f70 152 connectting = false;
jksoft 0:0a2f634d3324 153 return;
jksoft 0:0a2f634d3324 154 }
jksoft 8:e2f15b1b4f70 155 connectting = false;
jksoft 8:e2f15b1b4f70 156 mqtt_connectting = true;
jksoft 0:0a2f634d3324 157 MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
jksoft 0:0a2f634d3324 158 data.keepAliveInterval = 20;
jksoft 0:0a2f634d3324 159 data.cleansession = 1;
jksoft 0:0a2f634d3324 160 data.MQTTVersion = 4;
jksoft 0:0a2f634d3324 161 data.clientID.cstring = _clientid;
jksoft 0:0a2f634d3324 162 data.username.cstring = username;
jksoft 0:0a2f634d3324 163 data.password.cstring = password;
jksoft 0:0a2f634d3324 164
jksoft 0:0a2f634d3324 165 if (client->connect(data) != 0) {
jksoft 0:0a2f634d3324 166 DBG(pc.printf("Milkcocoa connect err\r\n");)
jksoft 8:e2f15b1b4f70 167 mqtt_connectting = false;
jksoft 0:0a2f634d3324 168 return;
jksoft 0:0a2f634d3324 169 }
jksoft 8:e2f15b1b4f70 170 mqtt_connectting = false;
jksoft 8:e2f15b1b4f70 171 }
jksoft 0:0a2f634d3324 172
jksoft 8:e2f15b1b4f70 173 void Milkcocoa::close()
jksoft 8:e2f15b1b4f70 174 {
jksoft 8:e2f15b1b4f70 175 client->disconnect();
jksoft 0:0a2f634d3324 176 }
jksoft 0:0a2f634d3324 177
jksoft 0:0a2f634d3324 178 bool Milkcocoa::push(const char *path, DataElement dataelement) {
jksoft 0:0a2f634d3324 179 milkcocoa_message_t *message = message_box.alloc();
jksoft 0:0a2f634d3324 180 char *buf;
jksoft 0:0a2f634d3324 181
jksoft 0:0a2f634d3324 182 if(message == NULL) return false;
jksoft 0:0a2f634d3324 183
jksoft 0:0a2f634d3324 184 sprintf(message->topic, "%s/%s/push", app_id, path);
jksoft 0:0a2f634d3324 185 buf = dataelement.toCharArray();
jksoft 0:0a2f634d3324 186 strcpy(message->message , buf);
jksoft 0:0a2f634d3324 187
jksoft 0:0a2f634d3324 188 osStatus stat = message_box.put(message);
jksoft 0:0a2f634d3324 189
jksoft 0:0a2f634d3324 190 if( stat != osOK ) return false;
jksoft 0:0a2f634d3324 191
jksoft 0:0a2f634d3324 192 return true;
jksoft 0:0a2f634d3324 193 }
jksoft 0:0a2f634d3324 194
jksoft 3:cddf81a87de3 195 bool Milkcocoa::push(const char *path, char *data) {
jksoft 6:1b5ec3a15d67 196
jksoft 3:cddf81a87de3 197 milkcocoa_message_t *message = message_box.alloc();
jksoft 3:cddf81a87de3 198 char *buf;
jksoft 3:cddf81a87de3 199
jksoft 3:cddf81a87de3 200 if(message == NULL) return false;
jksoft 3:cddf81a87de3 201
jksoft 3:cddf81a87de3 202 sprintf(message->topic, "%s/%s/push", app_id, path);
jksoft 3:cddf81a87de3 203
jksoft 4:9cfd43d8de16 204 strcpy(message->message , "{\"params\":");
jksoft 3:cddf81a87de3 205 strcat(message->message , data);
jksoft 3:cddf81a87de3 206 strcat(message->message , "}");
jksoft 3:cddf81a87de3 207
jksoft 3:cddf81a87de3 208 osStatus stat = message_box.put(message);
jksoft 3:cddf81a87de3 209
jksoft 3:cddf81a87de3 210 if( stat != osOK ) return false;
jksoft 3:cddf81a87de3 211
jksoft 3:cddf81a87de3 212 return true;
jksoft 3:cddf81a87de3 213 }
jksoft 3:cddf81a87de3 214
jksoft 0:0a2f634d3324 215 bool Milkcocoa::send(const char *path, DataElement dataelement) {
jksoft 0:0a2f634d3324 216 milkcocoa_message_t *message = message_box.alloc();
jksoft 0:0a2f634d3324 217 char *buf;
jksoft 0:0a2f634d3324 218
jksoft 0:0a2f634d3324 219 if(message == NULL) return false;
jksoft 0:0a2f634d3324 220
jksoft 0:0a2f634d3324 221 sprintf(message->topic, "%s/%s/send", app_id, path);
jksoft 0:0a2f634d3324 222 buf = dataelement.toCharArray();
jksoft 0:0a2f634d3324 223 strcpy(message->message , buf);
jksoft 0:0a2f634d3324 224
jksoft 0:0a2f634d3324 225 osStatus stat = message_box.put(message);
jksoft 0:0a2f634d3324 226
jksoft 0:0a2f634d3324 227 if( stat != osOK ) return false;
jksoft 6:1b5ec3a15d67 228
jksoft 0:0a2f634d3324 229 return true;
jksoft 0:0a2f634d3324 230 }
jksoft 0:0a2f634d3324 231
jksoft 3:cddf81a87de3 232 bool Milkcocoa::send(const char *path, char *data) {
jksoft 3:cddf81a87de3 233 milkcocoa_message_t *message = message_box.alloc();
jksoft 3:cddf81a87de3 234 char *buf;
jksoft 3:cddf81a87de3 235
jksoft 3:cddf81a87de3 236 if(message == NULL) return false;
jksoft 3:cddf81a87de3 237
jksoft 3:cddf81a87de3 238 sprintf(message->topic, "%s/%s/send", app_id, path);
jksoft 3:cddf81a87de3 239
jksoft 4:9cfd43d8de16 240 strcpy(message->message , "{\"params\":");
jksoft 3:cddf81a87de3 241 strcat(message->message , data);
jksoft 3:cddf81a87de3 242 strcat(message->message , "}");
jksoft 3:cddf81a87de3 243
jksoft 3:cddf81a87de3 244 osStatus stat = message_box.put(message);
jksoft 3:cddf81a87de3 245
jksoft 3:cddf81a87de3 246 if( stat != osOK ) return false;
jksoft 6:1b5ec3a15d67 247
jksoft 3:cddf81a87de3 248 return true;
jksoft 3:cddf81a87de3 249 }
jksoft 3:cddf81a87de3 250
jksoft 0:0a2f634d3324 251 void Milkcocoa::loop() {
jksoft 8:e2f15b1b4f70 252 if((connectting == true)||(mqtt_connectting == true)) return;
jksoft 0:0a2f634d3324 253 connect();
jksoft 6:1b5ec3a15d67 254 client->yield(1);
jksoft 6:1b5ec3a15d67 255
jksoft 6:1b5ec3a15d67 256 #ifndef __MILKCOCOA_THREAD
jksoft 6:1b5ec3a15d67 257 osEvent evt = message_box.get(0);
jksoft 6:1b5ec3a15d67 258 if (evt.status == osEventMail) {
jksoft 6:1b5ec3a15d67 259 milkcocoa_message_t *message = (milkcocoa_message_t*)evt.value.p;
jksoft 6:1b5ec3a15d67 260 MQTT::Message mq_message;
jksoft 6:1b5ec3a15d67 261 if(message != NULL) {
jksoft 6:1b5ec3a15d67 262 mq_message.qos = MQTT::QOS0;
jksoft 6:1b5ec3a15d67 263 mq_message.retained = 0;
jksoft 6:1b5ec3a15d67 264 mq_message.dup = false;
jksoft 6:1b5ec3a15d67 265 mq_message.payload = (void*)message->message;
jksoft 6:1b5ec3a15d67 266 mq_message.payloadlen = strlen(message->message);
jksoft 6:1b5ec3a15d67 267
jksoft 6:1b5ec3a15d67 268 client->publish(message->topic, mq_message);
jksoft 6:1b5ec3a15d67 269
jksoft 6:1b5ec3a15d67 270 message_box.free(message);
jksoft 6:1b5ec3a15d67 271 }
jksoft 6:1b5ec3a15d67 272 }
jksoft 6:1b5ec3a15d67 273 #endif
jksoft 0:0a2f634d3324 274 }
jksoft 0:0a2f634d3324 275
jksoft 0:0a2f634d3324 276 bool Milkcocoa::on(const char *path, const char *event, GeneralFunction cb) {
jksoft 0:0a2f634d3324 277 MilkcocoaSubscriber *sub = new MilkcocoaSubscriber(cb);
jksoft 0:0a2f634d3324 278 sprintf(sub->topic, "%s/%s/%s", app_id, path, event);
jksoft 0:0a2f634d3324 279
jksoft 0:0a2f634d3324 280 if (client->subscribe(sub->topic, MQTT::QOS0, cb) != 0) {
jksoft 0:0a2f634d3324 281 DBG(pc.printf("Milkcocoa subscribe err\r\n");)
jksoft 0:0a2f634d3324 282 return false;
jksoft 0:0a2f634d3324 283 }
jksoft 0:0a2f634d3324 284 for (int i=0; i<MILKCOCOA_SUBSCRIBERS; i++) {
jksoft 0:0a2f634d3324 285 if (milkcocoaSubscribers[i] == sub) {
jksoft 0:0a2f634d3324 286 return false;
jksoft 0:0a2f634d3324 287 }
jksoft 0:0a2f634d3324 288 }
jksoft 0:0a2f634d3324 289 for (int i=0; i<MILKCOCOA_SUBSCRIBERS; i++) {
jksoft 0:0a2f634d3324 290 if (milkcocoaSubscribers[i] == 0) {
jksoft 0:0a2f634d3324 291 milkcocoaSubscribers[i] = sub;
jksoft 0:0a2f634d3324 292 return true;
jksoft 0:0a2f634d3324 293 }
jksoft 0:0a2f634d3324 294 }
jksoft 0:0a2f634d3324 295 return true;
jksoft 0:0a2f634d3324 296 }
jksoft 0:0a2f634d3324 297
jksoft 6:1b5ec3a15d67 298 #ifdef __MILKCOCOA_THREAD
jksoft 0:0a2f634d3324 299 void Milkcocoa::setLoopCycle(int cycle) {
jksoft 0:0a2f634d3324 300 loop_cycle = cycle;
jksoft 0:0a2f634d3324 301 }
jksoft 0:0a2f634d3324 302 void Milkcocoa::start() {
jksoft 1:8e4149b53a8a 303 cycleThread1.signal_set(START_THREAD);
jksoft 1:8e4149b53a8a 304 cycleThread2.signal_set(START_THREAD);
jksoft 0:0a2f634d3324 305 }
jksoft 0:0a2f634d3324 306
jksoft 1:8e4149b53a8a 307 void Milkcocoa::cycle_Thread1(void) {
jksoft 1:8e4149b53a8a 308 cycleThread1.signal_wait(START_THREAD);
jksoft 0:0a2f634d3324 309 while(1) {
jksoft 0:0a2f634d3324 310 Timer timer;
jksoft 0:0a2f634d3324 311 timer.start();
jksoft 0:0a2f634d3324 312 connect();
jksoft 1:8e4149b53a8a 313
jksoft 1:8e4149b53a8a 314 client->yield(RECV_TIMEOUT);
jksoft 0:0a2f634d3324 315
jksoft 1:8e4149b53a8a 316 int sub_time = loop_cycle - timer.read();
jksoft 1:8e4149b53a8a 317 if( sub_time > 0 ){
jksoft 1:8e4149b53a8a 318 Thread::wait(sub_time);
jksoft 1:8e4149b53a8a 319 }
jksoft 1:8e4149b53a8a 320 timer.stop();
jksoft 1:8e4149b53a8a 321 }
jksoft 1:8e4149b53a8a 322 }
jksoft 1:8e4149b53a8a 323 void Milkcocoa::cycle_Thread2(void) {
jksoft 1:8e4149b53a8a 324 cycleThread2.signal_wait(START_THREAD);
jksoft 1:8e4149b53a8a 325 while(1) {
jksoft 1:8e4149b53a8a 326
jksoft 0:0a2f634d3324 327 osEvent evt = message_box.get();
jksoft 0:0a2f634d3324 328 if (evt.status == osEventMail) {
jksoft 0:0a2f634d3324 329 milkcocoa_message_t *message = (milkcocoa_message_t*)evt.value.p;
jksoft 0:0a2f634d3324 330 MQTT::Message mq_message;
jksoft 0:0a2f634d3324 331
jksoft 0:0a2f634d3324 332 if(message == NULL) break;
jksoft 0:0a2f634d3324 333
jksoft 0:0a2f634d3324 334 mq_message.qos = MQTT::QOS0;
jksoft 0:0a2f634d3324 335 mq_message.retained = 0;
jksoft 0:0a2f634d3324 336 mq_message.dup = false;
jksoft 0:0a2f634d3324 337 mq_message.payload = (void*)message->message;
jksoft 0:0a2f634d3324 338 mq_message.payloadlen = strlen(message->message);
jksoft 0:0a2f634d3324 339
jksoft 0:0a2f634d3324 340 client->publish(message->topic, mq_message);
jksoft 0:0a2f634d3324 341
jksoft 0:0a2f634d3324 342 message_box.free(message);
jksoft 1:8e4149b53a8a 343 }
jksoft 1:8e4149b53a8a 344 Thread::wait(1000);
jksoft 0:0a2f634d3324 345 }
jksoft 0:0a2f634d3324 346 }
jksoft 0:0a2f634d3324 347
jksoft 1:8e4149b53a8a 348 void Milkcocoa::threadStarter1(void const *p) {
jksoft 0:0a2f634d3324 349 Milkcocoa *instance = (Milkcocoa*)p;
jksoft 1:8e4149b53a8a 350 instance->cycle_Thread1();
jksoft 1:8e4149b53a8a 351 }
jksoft 1:8e4149b53a8a 352 void Milkcocoa::threadStarter2(void const *p) {
jksoft 1:8e4149b53a8a 353 Milkcocoa *instance = (Milkcocoa*)p;
jksoft 1:8e4149b53a8a 354 instance->cycle_Thread2();
jksoft 0:0a2f634d3324 355 }
jksoft 6:1b5ec3a15d67 356 #endif
jksoft 0:0a2f634d3324 357
jksoft 0:0a2f634d3324 358 MilkcocoaSubscriber::MilkcocoaSubscriber(GeneralFunction _cb) {
jksoft 0:0a2f634d3324 359 cb = _cb;
jksoft 0:0a2f634d3324 360 }
jksoft 0:0a2f634d3324 361