OneM2M / Mbed OS MQTTSN_AE_ESP_copy-1

Dependencies:   MQTTSN

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers container.h Source File

container.h

00001 
00002 int Container(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     //Create to parameter URI cse01/AE01
00012     sprintf(URI,"/%s/%s",CSE_ID, c_aei);
00013     R1.To = URI; 
00014     R1.From = aei;
00015     R1.Request_Identifier = "createCont01";
00016     R1.Resource_Type = 3;
00017     R1.Operation = 1;
00018     
00019     //struct CreateAE CAE;
00020     CAE.resourceName = "cont_monitor01";
00021     lcl = false;
00022     //buffer = Create_Cnt();
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 
00036         if(rsc != 0){ 
00037             //reg_resp = true;
00038             printf("rsc = %d\n",rsc);
00039             break;
00040         }
00041         else rsc = 0;
00042     }
00043     if(rsc == 2001 ){ 
00044         rsc = 0;
00045         return 0;
00046     }
00047     else if(rsc == 2002){
00048         rsc = 0;
00049         return -1;
00050     }
00051     return 0;
00052 }
00053 
00054 int delete_cnt (MQTTSN::Client<MQTTSNUDP, Countdown> *client, MQTTSNUDP* ipstack,  MQTTSN_topicid& topicid)
00055 {
00056     Request R1;
00057     //Create to parameter URI cse01/AE01/cont_monitor01
00058     sprintf(URI,"/%s/%s/cont_monitor01",CSE_ID, c_aei);
00059     R1.To = URI; 
00060     R1.From = aei;
00061     R1.Request_Identifier = "deleteCont01";
00062     R1.Operation = 4;
00063     buf = Delete_Req(R1);
00064     //PUBLISH
00065     if ((rc = publish(client, ipstack, topicid)) != 0)
00066          printf("rc from MQTT Publish is %d\n", rc);
00067     else
00068          printf("Published Buffer: %s to Topic %s\n",buf, MQTT_TOPIC);
00069     while(1)
00070     {
00071         client->yield(4000);
00072         if(rsc != 0){ 
00073             printf("rsc = %d\n",rsc);
00074             break;
00075         }
00076         else rsc = 0;
00077     }
00078     return rsc;
00079 }