123
Dependencies: MQTTSN
Subscription.h
- Committer:
- m_ahsan
- Date:
- 2019-08-06
- Revision:
- 15:8c473836feba
File content as of revision 15:8c473836feba:
int Subscription(MQTTSN::Client<MQTTSNUDP, Countdown> *client, MQTTSNUDP* ipstack, MQTTSN_topicid& topicid) { //Create Subscription //Mendatory resources: Operation, To, From, Request Identifier ,Resource Type, Content //Resource Specific Attributes [M]: // [0]: //struct Mendatory m1; (to, fr, rqi, ty, op) Request R1; R1.To = CSE_ID; R1.From = aei; R1.Request_Identifier = "createSub01"; R1.Resource_Type = 23; R1.Operation = 1; //struct CreateSub CSub; CSub.notificationEventType = 3; CSub.resourceName = "sub_monitor01";; CSub.notificationURI = aei; CSub.notificationContentType = 1; lcl = false; //buffer = Create_Cnt(); 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(rsc != 0){ printf("rsc = %d\n",rsc); break; } else rsc = 0; } if(rsc == 2001 ){ rsc = 0; return 0; } else if(rsc == 2002){ rsc = 0; return -1; } return 0; } int delete_sub (MQTTSN::Client<MQTTSNUDP, Countdown> *client, MQTTSNUDP* ipstack, MQTTSN_topicid& topicid) { Request R1; //Create to parameter URI cse01/AE01/cont_monitor01 sprintf(URI,"/%s/%s/sub_monitor01",CSE_ID, c_aei); R1.To = URI; R1.From = aei; R1.Request_Identifier = "deleteSub01"; R1.Operation = 4; buf = Delete_Req(R1); //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(rsc != 0){ printf("rsc = %d\n",rsc); break; } else rsc = 0; } return rsc; }