Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using with a local MQTT broker #1

Open
Cyb3rn0id opened this issue May 9, 2020 · 1 comment
Open

Using with a local MQTT broker #1

Cyb3rn0id opened this issue May 9, 2020 · 1 comment

Comments

@Cyb3rn0id
Copy link

Cyb3rn0id commented May 9, 2020

I'm trying to use the PIC-IOT with a local MQTT server having a not default port and user password.
I suppose this part of code in Header Files/MCC Generated Files/config/mqtt_config.h is used to set MQTT parameters:

`// MCC generated parameters

#define CFG_MQTT_PORT 8883

#define CFG_MQTT_HOSTURL "a1gqt8sttiign3.iot.us-east-2.amazonaws.com"

#define CFG_MQTT_CONN_TIMEOUT 10

#define CFG_MQTT_BROKERIP 0x00000000

#define CFG_MQTT_TXBUFFER_SIZE 400

#define CFG_MQTT_RXBUFFER_SIZE 400

#define CFG_MQTT_USERNAME "mchpUser"

#define CFG_MQTT_PASSWORD "microchip"

#define CFG_QOS 0

#define CFG_PUBTOPIC "mchp/iot/events"

#define CFG_SUBTOPIC "mchp/iot/config"

#define TCPIP_BSD 1`

BUT: my local MQTT Broker has not an HOSTURL but I've IP address: 192.168.1.101.
Now I suppose, in this case, I must leave blank the CFG_MQTT_HOSTURL parameter and then fill the CFG_MQTT_BROKERIP in hex format. But CFG_MQTT_BROKERIP macro is not used in any part of code! So I suppose I must put my IP address in the CFG_MQTT_HOSTURL, but nothing works (I've changed PORT, USER and PASSWORD to match my local broker).

How can I use this example for publishing MQTT Topics in my local MQTT broker?

@mchpmujumdmm
Copy link

The MCC MQTT v2.0.0 library provides an example to connect the PIC IoT board to a local MQTT server.

Requirements:

Steps:

  • Install MCC plugin in MPLAB X
  • Create an empty project using PIC24FJ128GA705.
  • Open MCC plugin

Configuring the MQTT Library:

  • Add MQTT library to the MCC configuration
  • Select Wireless [WINC15XX] as the 'Transport Layer' during MQTT library configuration in MCC. The WINC15XX library will load automatically (this step might take some time).
  • The host IP address can be entered in the 'Host Address' field in the UI.
  • Publish and subscribe topics can be customized using the 'Publish Topic' and 'Subscribe Topic' fields

Configuring the WINC15XXLibrary:

  • Navigate to the WINC15XX library. Enter the SSID and password of the Wi-Fi network.
  • The PIC IoT pinout can be used to configure the WINC15XX pins.

For additional information please refer to the 'Running the Example' section of the MQTT library Release Notes.

After code generation, the app_mqttExampleInit() and app_mqttScheduler() function should be called in the main.c file:

int main(void)
{
    SYSTEM_Initialize();
    app_mqttExampleInit();
    while (1)
    {
        app_mqttScheduler();
    }
}

After programming the PIC IoT Development Board, the application will establish MQTT connection and publish packets to the MQTT broker every 10 seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants