OneM2M / Mbed OS MQTTSN_AE_ESP_copy-1

Dependencies:   MQTTSN

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers contentInstance.h Source File

contentInstance.h

00001 
00002 int contentInstance(MQTTSN::Client<MQTTSNUDP, Countdown> *client, MQTTSNUDP* ipstack,  MQTTSN_topicid& topicid)
00003 {
00004     //Create Container
00005     //Mendatory resources: Operation, To, From, Request Identifier ,Resource Type, Content 
00006     //Resource Specific Attributes [M]: App-ID, requestReachability, supportedReleaseVersions
00007     //                              [0]: PointofAccess, ResourceName
00008 
00009     //struct Mendatory m1; (to, fr, rqi, ty, op)
00010     Request R1;
00011     R1.To = CSE_ID; 
00012     R1.From = aei;
00013     R1.Request_Identifier = "createCin01";
00014     R1.Resource_Type = 4;
00015     R1.Operation = 1;
00016     
00017     //struct CreateAE CAE;
00018     CIN.resourceName = "cin_monitor01";
00019     CIN.contentInfo = "text/plains:0"; 
00020     CIN.content = "25";
00021     //buffer = Create_Cnt();
00022     lcl = false;
00023     buf = Create_Req(R1);
00024     //buf[0] = '\0'; 
00025         
00026     //PUBLISH
00027     if ((rc = publish(client, ipstack, topicid)) != 0)
00028          printf("rc from MQTT Publish is %d\n", rc);
00029     else
00030          printf("Published Buffer: %s to Topic %s\n",buf, MQTT_TOPIC);
00031 
00032     while(1)
00033     {     
00034         client->yield(4000);
00035         /*if(isMessageArrived) {
00036             isMessageArrived = false;
00037             // Just print it out here.
00038             //printf("\r\nMessage arrived:\r\n%s\r\n", messageBuffer);
00039             //process_msg();
00040             //free(messageBuffer);
00041         } */
00042         if(rsc != 0){ 
00043             //reg_resp = true;
00044             printf("rsc = %d\n",rsc);
00045             break;
00046         }
00047         else rsc = 0;
00048     }
00049     if(rsc == 2001 ){ 
00050         rsc = 0;
00051         return 0;
00052     }
00053     else if(rsc == 2002){
00054         rsc = 0;
00055         return -1;
00056     }
00057     //wait for response
00058     return 0;
00059 }