-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
countertrack implements MQTT Mosquitto client and persists data in
sqlite3 database. Includes makefile and configuration script for using GPIOs
- Loading branch information
1 parent
1070f0a
commit 227ffe3
Showing
8 changed files
with
272 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <cstdio> | ||
#include <cstring> | ||
#include <ctime> | ||
#include <string> | ||
|
||
#include "mqtt_publisher.h" | ||
#include <mosquittopp.h> | ||
|
||
using namespace std; | ||
|
||
mqtt_publisher::mqtt_publisher(const char *id, const char *host, int port, const char* publishTopic) : mosquittopp(id) | ||
{ | ||
int keepalive = 60; | ||
published_flag = 0; | ||
topic = publishTopic; | ||
|
||
/* Connect immediately. This could also be done by calling | ||
* mqtt_tempconv->connect(). */ | ||
connect(host, port, keepalive); | ||
}; | ||
|
||
void mqtt_publisher::on_connect(int rc) | ||
{ | ||
printf("Connected with code %d.\n", rc); | ||
|
||
} | ||
|
||
void mqtt_publisher::on_publish(int rc) | ||
{ | ||
printf("Sent\n"); | ||
published_flag = 1; | ||
} | ||
|
||
void mqtt_publisher::on_message(const struct mosquitto_message *message) | ||
{ | ||
|
||
} | ||
|
||
void mqtt_publisher::on_disconnect(int rc) | ||
{ | ||
printf("Disconnected\n"); | ||
} | ||
|
||
int mqtt_publisher::get_published_flag() | ||
{ | ||
return published_flag; | ||
} | ||
|
||
void mqtt_publisher::set_published_flag() | ||
{ | ||
published_flag = 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef TEMPERATURE_CONVERSION_H | ||
#define TEMPERATURE_CONVERSION_H | ||
|
||
#include <mosquittopp.h> | ||
|
||
class mqtt_publisher : public mosqpp::mosquittopp | ||
{ | ||
public: | ||
mqtt_publisher(const char *id, const char *host, int port, const char* publishTopic); | ||
~mqtt_publisher(); | ||
|
||
void on_connect(int rc); | ||
void on_publish(int rc); | ||
void on_message(const struct mosquitto_message *message); | ||
void on_disconnect(int rc); | ||
int get_published_flag(); | ||
void set_published_flag(); | ||
|
||
private: | ||
int published_flag; | ||
const char* topic; | ||
const char* data; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
all: | ||
g++ -I/usr/local/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/main.d" -MT"src/main.d" -o "src/main.o" "../src/main.cpp" | ||
|
||
g++ -I/usr/local/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"Gait/gait.d" -MT"Gait/gait.d" -o "Gait/gait.o" "../Gait/Gait.cpp" | ||
|
||
g++ -I/usr/local/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"ZoneRegister/zoneRegister.d" -MT"ZoneRegister/zoneRegister.d" -o "ZoneRegister/zoneRegister.o" "../ZoneRegister/ZoneRegister.cpp" | ||
|
||
g++ -I/usr/local/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"Mat/mat.d" -MT"Mat/mat.d" -o "Mat/mat.o" "../Mat/Mat.cpp" | ||
|
||
g++ -I/usr/local/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"MQTT_Publisher/mqtt_publisher.d" -MT"MQTT_Publisher/mqtt_publisher.d" -o "MQTT_Publisher/mqtt_publisher.o" "../MQTT_Publisher/mqtt_publisher.cpp" | ||
|
||
g++ -L/usr/local/lib -o "countertrack-sensor" ./src/main.o ./Mat/mat.o ./Gait/gait.o ./ZoneRegister/zoneRegister.o ./MQTT_Publisher/mqtt_publisher.o -lmosquittopp -lsqlite3 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash -e | ||
|
||
if [ ! -d /sys/class/gpio/gpio30 ]; then echo 30 > /sys/class/gpio/export; fi #P9_11 | ||
if [ ! -d /sys/class/gpio/gpio60 ]; then echo 60 > /sys/class/gpio/export; fi #P9_12 | ||
if [ ! -d /sys/class/gpio/gpio31 ]; then echo 31 > /sys/class/gpio/export; fi #P9_13 | ||
if [ ! -d /sys/class/gpio/gpio50 ]; then echo 50 > /sys/class/gpio/export; fi #P9_14 | ||
if [ ! -d /sys/class/gpio/gpio48 ]; then echo 48 > /sys/class/gpio/export; fi #P9_15 | ||
if [ ! -d /sys/class/gpio/gpio51 ]; then echo 51 > /sys/class/gpio/export; fi #P9_16 | ||
if [ ! -d /sys/class/gpio/gpio3 ]; then echo 3 > /sys/class/gpio/export; fi #P9_21 | ||
if [ ! -d /sys/class/gpio/gpio2 ]; then echo 2 > /sys/class/gpio/export; fi #P9_22 | ||
if [ ! -d /sys/class/gpio/gpio49 ]; then echo 49 > /sys/class/gpio/export; fi #P9_23 | ||
if [ ! -d /sys/class/gpio/gpio15 ]; then echo 15 > /sys/class/gpio/export; fi #P9_24 | ||
|
||
echo in > /sys/class/gpio/gpio30/direction | ||
echo in > /sys/class/gpio/gpio60/direction | ||
echo in > /sys/class/gpio/gpio31/direction | ||
echo in > /sys/class/gpio/gpio50/direction | ||
echo in > /sys/class/gpio/gpio48/direction | ||
echo in > /sys/class/gpio/gpio51/direction | ||
echo in > /sys/class/gpio/gpio3/direction | ||
echo in > /sys/class/gpio/gpio2/direction | ||
echo in > /sys/class/gpio/gpio49/direction | ||
echo in > /sys/class/gpio/gpio15/direction | ||
|
||
|
||
|
||
|