Sample MQTT program - simple send and receive

Dependencies:   C12832 MQTT

Dependents:   MQTT_G_SENSOR

This program and the MQTT libraries it uses are part of the EclipseTM Paho project; specifically the embedded client.

This example and API are working, but are still in progress. Please give us your feedback.

HelloMQTT is an example of using the MQTT API. The MQTT API is portable across network interface stacks. MQTT is designed to be used with TCP/IP, but any transport with similar characteristics should be suitable.

HelloMQTT uses the NetworkInterface APIs in mbed OS 5 to show how this works. The MQTT library contains an MQTTNetwork.h header, which is a wrapper around the mbed networking interface. To switch between connectivity methods (the default is Ethernet) the easy-connect library is provided in this example application. You can change the connectivity method in mbed_app.json.

Adding new connectivity methods to the program is trivial, as long as they implement the mbed OS 5 NetworkStack API.

Committer:
icraggs
Date:
Mon Jul 27 09:16:08 2015 +0000
Revision:
17:0811bdbdd78a
Make sure QoS 2 works

Who changed what in which revision?

UserRevisionLine numberNew contents of line
icraggs 17:0811bdbdd78a 1 /*******************************************************************************
icraggs 17:0811bdbdd78a 2 * Copyright (c) 2014 IBM Corp.
icraggs 17:0811bdbdd78a 3 *
icraggs 17:0811bdbdd78a 4 * All rights reserved. This program and the accompanying materials
icraggs 17:0811bdbdd78a 5 * are made available under the terms of the Eclipse Public License v1.0
icraggs 17:0811bdbdd78a 6 * and Eclipse Distribution License v1.0 which accompany this distribution.
icraggs 17:0811bdbdd78a 7 *
icraggs 17:0811bdbdd78a 8 * The Eclipse Public License is available at
icraggs 17:0811bdbdd78a 9 * http://www.eclipse.org/legal/epl-v10.html
icraggs 17:0811bdbdd78a 10 * and the Eclipse Distribution License is available at
icraggs 17:0811bdbdd78a 11 * http://www.eclipse.org/org/documents/edl-v10.php.
icraggs 17:0811bdbdd78a 12 *
icraggs 17:0811bdbdd78a 13 * Contributors:
icraggs 17:0811bdbdd78a 14 * Ian Craggs - initial implementation
icraggs 17:0811bdbdd78a 15 * Sam Grove - added method to check the status of the Ethernet cable
icraggs 17:0811bdbdd78a 16 *******************************************************************************/
icraggs 17:0811bdbdd78a 17
icraggs 17:0811bdbdd78a 18 #if !defined(K64F_H)
icraggs 17:0811bdbdd78a 19 #define K64F_H
icraggs 17:0811bdbdd78a 20
icraggs 17:0811bdbdd78a 21 C12832 lcd(D11, D13, D12, D7, D10);
icraggs 17:0811bdbdd78a 22 BusOut led2 (LED_BLUE);
icraggs 17:0811bdbdd78a 23 BusOut r (D5);
icraggs 17:0811bdbdd78a 24 BusOut g (D9);
icraggs 17:0811bdbdd78a 25 BusOut b (D8);
icraggs 17:0811bdbdd78a 26 DigitalIn Up(A2); DigitalIn Down(A3); DigitalIn Right(A4); DigitalIn Left(A5); DigitalIn Click(D4);
icraggs 17:0811bdbdd78a 27 AnalogIn ain1(A0); AnalogIn ain2(A1);
icraggs 17:0811bdbdd78a 28
icraggs 17:0811bdbdd78a 29 #define LED2_OFF 1
icraggs 17:0811bdbdd78a 30 #define LED2_ON 0
icraggs 17:0811bdbdd78a 31
icraggs 17:0811bdbdd78a 32 #define DEFAULT_TYPE_NAME "iotsample-mbed-k64f"
icraggs 17:0811bdbdd78a 33
icraggs 17:0811bdbdd78a 34 //#include "lpc_phy.h"
icraggs 17:0811bdbdd78a 35 // need a wrapper since K64F and LPC1768 wont have the same name for mii read methods
icraggs 17:0811bdbdd78a 36 static uint32_t linkStatus(void)
icraggs 17:0811bdbdd78a 37 {
icraggs 17:0811bdbdd78a 38 return (1);
icraggs 17:0811bdbdd78a 39 }
icraggs 17:0811bdbdd78a 40
icraggs 17:0811bdbdd78a 41 #endif