Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nsnick/mqttclient
An Objective-C wrapper for libmosquitto with TLS support
https://github.com/nsnick/mqttclient
ios libmosquitto mqtt mqtt-client objective-c
Last synced: about 15 hours ago
JSON representation
An Objective-C wrapper for libmosquitto with TLS support
- Host: GitHub
- URL: https://github.com/nsnick/mqttclient
- Owner: nsnick
- License: mit
- Created: 2015-04-27T20:22:34.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-04-28T03:31:40.000Z (over 9 years ago)
- Last Synced: 2023-03-01T14:36:06.250Z (over 1 year ago)
- Topics: ios, libmosquitto, mqtt, mqtt-client, objective-c
- Language: Objective-C
- Homepage:
- Size: 141 KB
- Stars: 17
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MQTTClient
MQTTClient is an Objective-C wrapper for libmosquitto. MQTTClient supports authentication and TLS encryption.
MQTTClient has been tested with libmosquitto 1.4.1. Download the latest libmosquitto here: http://mosquitto.org/download/# MQTTClient with TLS
Add MQTTClient.h and MQTTClient.m to your project.Add the libmosquitto source from the link above to your project.
Compile openssl for iOS using the instructions here:
https://github.com/x2on/OpenSSL-for-iPhone
Add the compiled openssl framework to your project.Create certificates for client and server using:
http://rockingdlabs.dunmire.org/exercises-experiments/ssl-client-certs-to-secure-mqttAdd client.crt, client.key, and ca.crt to your project.
Set a preprocessor flag in XCode "WITH_TLS" by clicking the project in XCode then click the target then click build settings
Search for preprocessor macros and add "WITH_TLS" to debug and releaseCall init then connect then subscribe
```objc
-(id)initWithUsername:(NSString *)username
password:(NSString *)password
caCert:(NSString *)caCert
clientCert:(NSString *)clientCert
clientKey:(NSString *)clientKey;-(void)connectToHost:(NSString *)host
port:(int)port
keepAlive:(int)keepAlive;-(void)subscribeToTopic:(NSString *)topic;
```
# MQTTClient without TLS
Add MQTTClient.h and MQTTClient.m to your project.
Add the libmosquitto source from the link above to your project.Designate one of the objects as the MQTTClientDelegate
There is one required method:
```objc
-(void)messageReceived:(NSData *)messageData onTopic:(NSString *)topic;
```
Call init then connect then subscribe.
```objc
-(id)init;-(id)initWithUsername:(NSString *)username
password:(NSString *)password;-(void)connectToHost:(NSString *)host
port:(int)port
keepAlive:(int)keepAlive;-(void)subscribeToTopic:(NSString *)topic;
```