-
Notifications
You must be signed in to change notification settings - Fork 0
Basic interface
Jensah edited this page May 21, 2021
·
9 revisions
The Basic interface consists of the following:
a a a a a a a a a a a a a a a a a a a a a a
MQTT is used on the Alset Vehicle (Arduino Board) and the Android Application. The connection can be configured to connect to any host.
The car subscribes to the following topics:
namespace mqtt_topic
{
const auto CONTROL_GLOBAL = "/smartcar/control/#";
const auto CONTROL_SPEED = "/smartcar/control/speed";
const auto CONTROL_STEERING = "/smartcar/control/steering";
const auto TELEMETRY_SPEED = "/smartcar/telemetry/speed";
const auto TELEMETRY_FRONT_ULTRASONIC = "/smartcar/telemetry/frontUltrasonic";
const auto TELEMETRY_BACK_INFRARED = "/smartcar/telemetry/backInfrared";
const auto CAMERA = "/smartcar/camera";
}Each topic is then published through stand-alone methods:
void publishCameraFrame()
{
#ifdef __SMCE__
Camera.readFrame(frameBuffer.data());
mqtt.publish(mqtt_topic::CAMERA, frameBuffer.data(), frameBuffer.size(), false, 0);
#endif
}void publishCarSpeed()
{
mqtt.publish(mqtt_topic::TELEMETRY_SPEED, String(car.getSpeed()));
}void publishFrontUltrasonic()
{
#ifdef __SMCE__
const long distance = frontUSSensor.getDistance();
static long previousDistance = -1;
if (distance == previousDistance) {
return;
}
previousDistance = distance;
mqtt.publish(mqtt_topic::TELEMETRY_FRONT_ULTRASONIC, String(distance));
#endif
}void publishBackInfrared()
{
#ifdef __SMCE__
const long distance = backIRSensor.getDistance();
static long previousDistance = -1;
if (distance == previousDistance) {
return;
}
previousDistance = distance;
mqtt.publish(mqtt_topic::TELEMETRY_BACK_INFRARED, String(distance));
#endif
}