123
Dependencies: MQTTSN
Diff: contentInstance.h
- Revision:
- 15:8c473836feba
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contentInstance.h Tue Aug 06 05:32:43 2019 +0000 @@ -0,0 +1,59 @@ + +int contentInstance(MQTTSN::Client<MQTTSNUDP, Countdown> *client, MQTTSNUDP* ipstack, MQTTSN_topicid& topicid) +{ + //Create Container + //Mendatory resources: Operation, To, From, Request Identifier ,Resource Type, Content + //Resource Specific Attributes [M]: App-ID, requestReachability, supportedReleaseVersions + // [0]: PointofAccess, ResourceName + + //struct Mendatory m1; (to, fr, rqi, ty, op) + Request R1; + R1.To = CSE_ID; + R1.From = aei; + R1.Request_Identifier = "createCin01"; + R1.Resource_Type = 4; + R1.Operation = 1; + + //struct CreateAE CAE; + CIN.resourceName = "cin_monitor01"; + CIN.contentInfo = "text/plains:0"; + CIN.content = "25"; + //buffer = Create_Cnt(); + lcl = false; + buf = Create_Req(R1); + //buf[0] = '\0'; + + //PUBLISH + if ((rc = publish(client, ipstack, topicid)) != 0) + printf("rc from MQTT Publish is %d\n", rc); + else + printf("Published Buffer: %s to Topic %s\n",buf, MQTT_TOPIC); + + while(1) + { + client->yield(4000); + /*if(isMessageArrived) { + isMessageArrived = false; + // Just print it out here. + //printf("\r\nMessage arrived:\r\n%s\r\n", messageBuffer); + //process_msg(); + //free(messageBuffer); + } */ + if(rsc != 0){ + //reg_resp = true; + printf("rsc = %d\n",rsc); + break; + } + else rsc = 0; + } + if(rsc == 2001 ){ + rsc = 0; + return 0; + } + else if(rsc == 2002){ + rsc = 0; + return -1; + } + //wait for response + return 0; +}