This shows you the differences between two versions of the page.
| — | app-notes:metric-cloudsetup:sdk-gnss-mqtt-publish [2020/11/12 09:34] (current) – created erdmann | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | <file c sdk-gnss-mqtt-publish.are> | ||
| + | HOST = " | ||
| + | PORT = 1883; | ||
| + | KEEPALIVE = 60; | ||
| + | PROTOCOL = " | ||
| + | USERNAME = " | ||
| + | PASSWORD = " | ||
| + | CLIENT_ID = " | ||
| + | TOPIC = " | ||
| + | QOS = 0; | ||
| + | RETAIN = 0; | ||
| + | MESSAGE = ""; | ||
| + | CLEAN_SESSION = true; | ||
| + | MQTT_HANDLE = 0; | ||
| + | /*create new mqtt instance*/ | ||
| + | MQTT_HANDLE = nb_mqttlib_new(CLIENT_ID, | ||
| + | |||
| + | if (nb_mqttlib_set_protocol_version(MQTT_HANDLE, | ||
| + | printf(" | ||
| + | exit(1); | ||
| + | } | ||
| + | |||
| + | if (nb_mqttlib_set_user_pw(MQTT_HANDLE, | ||
| + | printf(" | ||
| + | |||
| + | exit(1); | ||
| + | } | ||
| + | |||
| + | if (nb_mqttlib_connect(MQTT_HANDLE, | ||
| + | printf(" | ||
| + | exit(1); | ||
| + | } | ||
| + | |||
| + | |||
| + | while (1) { | ||
| + | sys_tmp = nb_status(" | ||
| + | gps_long = nb_status(" | ||
| + | gps_lat = nb_status(" | ||
| + | gps_hdop = nb_status(" | ||
| + | gps_vdop = nb_status(" | ||
| + | gps_pdop = nb_status(" | ||
| + | gps_altitude = nb_status(" | ||
| + | gps_satellites_used = nb_status(" | ||
| + | gps_satellites_inview = nb_status(" | ||
| + | gps_horizontal_speed = nb_status(" | ||
| + | |||
| + | /* create the message */ | ||
| + | MESSAGE=sprintf(" | ||
| + | |||
| + | / | ||
| + | // | ||
| + | |||
| + | /* publish the message to mqtt broker */ | ||
| + | ret = nb_mqttlib_publish(MQTT_HANDLE, | ||
| + | |||
| + | if(ret< | ||
| + | nb_syslog(" | ||
| + | } | ||
| + | |||
| + | sleep(30); | ||
| + | } | ||
| + | |||
| + | exit(0); | ||
| + | </ | ||