Skip to main content

Posts

Showing posts from August, 2016

Gulp command not found on Mac OSX

Was getting following error after installing gulp on mac.

Sachins-MBP:MyApp sachin$ gulp
-bash: gulp: command not found
After fighting for hours and searching on internet, tuned out to be a very simple fix. While installing gulp missed the parameter to install globally.

Sachins-MBP:MyApp sachin$ npm install -g gulp

Yay !!!! Its working, thought to write to save time for somebody else.

MQTT - Eclipse Paho integration for Android

For MQTT integration, recently explored Paho Android project, very simple to use, here are the steps:

Intialize a client, set required options and connect.

    MqttAndroidClient mqttClient = new MqttAndroidClient(BaseApplication.getAppContext(), broker, MQTT_CLIENT_ID);
    //Set call back class
    mqttClient.setCallback(new MqttCallbackHandler(BaseApplication.getAppContext()));
    MqttConnectOptions connOpts = new MqttConnectOptions();
    IMqttToken token = mqttClient.connect(connOpts);


Subscribe to a topic.

    token.setActionCallback(new IMqttActionListener() {
      @Override
      public void onSuccess(IMqttToken arg0) {
           mqttClient.subscribe("TOPIC_NAME" + userId, 2, null, new IMqttActionListener() {
                @Override
                public void onSuccess(IMqttToken asyncActionToken) {
                    Log.d(LOG_TAG, "Successfully subscribed to topic.");
                }

                @Override
                public void onFailure…