OneM2M / Mbed OS MQTTSN_AE_ESP_copy-1

Dependencies:   MQTTSN

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers registration.h Source File

registration.h

00001 
00002 int Registration(MQTTSN::Client<MQTTSNUDP, Countdown> *client, MQTTSNUDP* ipstack,  MQTTSN_topicid& topicid)
00003 {
00004     //Create AE
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     Request R1;
00009     AE_ID = "S";                    //Initial registration
00010     //struct Mendatory m1;
00011     R1.To = CSE_ID; 
00012     R1.From = AE_ID;
00013     R1.Request_Identifier = "createAE11";
00014     R1.Resource_Type = 2;
00015     R1.Operation = 1;
00016     
00017     //struct CreateAE CAE;
00018     CAE.resourceName = MQTT_CLIENT_ID;
00019     CAE.requestReachability = true;
00020     CAE.App_ID = "A01.com.sensor011";
00021     //buffer = Create_AE();
00022     lcl = false;
00023     buf = Create_Req(R1);
00024     printf("string in buf is %s\n",buf);
00025     //buf[0] = '\0';
00026     
00027     
00028     //PUBLISH
00029 
00030     if ((rc = publish(client, ipstack, topicid)) != 0)
00031          printf("rc from MQTT Publish is %d\n", rc);
00032     else
00033          printf("Published Buffer: %s to Topic %s\n",buf, MQTT_TOPIC);
00034 
00035     while(1)
00036     {
00037            
00038         client->yield(4000);
00039         /*if(isMessageArrived) {
00040             isMessageArrived = false;
00041             // Just print it out here.
00042             //printf("\r\nMessage arrived:\r\n%s\r\n", messageBuffer);
00043             //process_msg();
00044             
00045             //free(messageBuffer);
00046         } */ 
00047         if(rsc != 0){ 
00048             //reg_resp = true;
00049             printf("rsc = %d\n",rsc);
00050             break;
00051         }
00052         else rsc = 0;
00053     }
00054     if(rsc == 2001 ){ 
00055         rsc = 0;
00056         return 0;
00057     }
00058     else if(rsc == 2002){
00059         rsc = 0;
00060         return -1;
00061     }
00062     //wait for response
00063     return 0;
00064 }