Ejemplo n.º 1
0
void myconnect(IPStack& ipstack, MQTT::Client<IPStack, Countdown, 1000>& client, MQTTPacket_connectData& data)
{
	printf("Connecting to %s:%d\n", opts.host, opts.port);
	int rc = ipstack.connect(opts.host, opts.port);
	if (rc != 0)
	    printf("rc from TCP connect is %d\n", rc);

	rc = client.connect(data);
	if (rc != 0)
	{
		printf("Failed to connect, return code %d\n", rc);
		exit(-1);	
	}
	printf("Connected\n");
}
Ejemplo n.º 2
0
void InitializeMQTTCommunication()
{
	version = 0.3;
	printf("Version is %f\n", version);

	const char* hostname = "52.207.148.30";						// iot.eclipse.org
	printf("Connecting to %s:%d\n", hostname, PORT_NUM);
	rc = ipStackVar.connect(hostname, PORT_NUM);
	if (rc != 0)
		printf("rc from TCP connect is %d\n", rc);

	printf("MQTT connecting\n");
	MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
	data.MQTTVersion = 3;
	data.clientID.cstring = (char*)"mbed-icraggs";
	rc = client.connect(data);
	if (rc != 0)
		printf("rc from MQTT connect is %d\n", rc);
	printf("MQTT connected\n");
}