Code Monkey home page Code Monkey logo

mqttclient's Introduction

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-mqtt

Add 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 release

Call init then connect then subscribe

-(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:

-(void)messageReceived:(NSData *)messageData onTopic:(NSString *)topic;

Call init then connect then subscribe.

-(id)init;

-(id)initWithUsername:(NSString *)username 
             password:(NSString *)password;

-(void)connectToHost:(NSString *)host 
                port:(int)port  
           keepAlive:(int)keepAlive;

-(void)subscribeToTopic:(NSString *)topic;

mqttclient's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mqttclient's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.