Skip to content

Commit

Permalink
Update to publish MQTT angle
Browse files Browse the repository at this point in the history
  • Loading branch information
graham22 committed Jan 24, 2024
1 parent f5f9b36 commit ff7320b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions code/ESP32/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"typeinfo": "cpp"
}
}
3 changes: 3 additions & 0 deletions code/ESP32/include/LinearActuatorNoPot.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
#include <ThreadController.h>
#include <Thread.h>
#include "Enumerations.h"
#include "IOT.h"

#define noise 2
#define histeresis 2
#define shortCheckInterval 100
#define longCheckInterval 5000
#define POSITIONINTERVAL 5 // Move array when sun moves 5 degrees past current position

extern SkyeTracker::IOT _iot;

namespace SkyeTracker
{

Expand Down
2 changes: 1 addition & 1 deletion code/ESP32/src/IOT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ char _mqttServer[IOTWEBCONF_WORD_LEN];
char _mqttPort[5];
char _mqttUserName[IOTWEBCONF_WORD_LEN];
char _mqttUserPassword[IOTWEBCONF_WORD_LEN];
u_int _uniqueId = 0;
u_int32_t _uniqueId = ESP.getEfuseMac() & 0xFFFFFFFF;
IotWebConfSeparator seperatorParam = IotWebConfSeparator("MQTT");
IotWebConfParameter mqttServerParam = IotWebConfParameter("MQTT server", "mqttServer", _mqttServer, IOTWEBCONF_WORD_LEN);
IotWebConfParameter mqttPortParam = IotWebConfParameter("MQTT port", "mqttSPort", _mqttPort, 5, "text", NULL, "1883");
Expand Down
5 changes: 5 additions & 0 deletions code/ESP32/src/LinearActuatorNoPot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ namespace SkyeTracker
setInterval(shortCheckInterval);
_requestedAngle = angle;
enabled = true;
char angle[16];
sprintf(angle, "%.0f", _requestedAngle);
char subtopic[32];
sprintf(subtopic, "%sAngle", _name);
_iot.publish(subtopic, angle, false);
}
}

Expand Down
1 change: 1 addition & 0 deletions code/ESP32/src/Tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ namespace SkyeTracker

void Tracker::setState(TrackerState state)
{
logd("setState: %d", state);
if (_trackerState != state) {
_trackerState = state;
_config.SendConfiguration();
Expand Down

0 comments on commit ff7320b

Please sign in to comment.