Skip to content

Commit

Permalink
should be updated
Browse files Browse the repository at this point in the history
Signed-off-by: Brenton Poke <[email protected]>
  • Loading branch information
BrentonPoke committed Oct 22, 2024
1 parent 4e1baef commit a3beb32
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions examples/Basic-Ducks/DuckLink/DuckLink.ino
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

// create a built-in duck link
DuckLink duck;

bool sendSensorData();
bool runSensor(void *);
// create a timer with default settings
auto timer = timer_create_default();

Expand All @@ -35,9 +36,9 @@ void setup() {
// setup the duck NOTE: The Device ID must be exactly 8 bytes otherwise it
// will get rejected
std::string deviceId("DUCK0001");
std::vector<byte> devId;
std::array<byte,8> devId;
int rc;
devId.insert(devId.end(), deviceId.begin(), deviceId.end());
std::copy(deviceId.begin(), deviceId.end(), devId.begin());
rc = duck.setupWithDefaults(devId);
if (rc != DUCK_ERR_NONE) {
Serial.print("[LINK] Failed to setup ducklink: rc = ");
Expand Down Expand Up @@ -80,12 +81,12 @@ std::vector<byte> stringToByteVector(const std::string& str) {
bool sendSensorData() {
bool result = false;
const byte* buffer;

std::string message = std::string("Counter:") + std::to_string(counter);
Serial.print("[LINK] sensor data: ");
Serial.println(message.c_str());

int err = duck.sendData(topics::status, stringToByteVector(message));
std::vector<byte> data = stringToByteVector(message);
int err = duck.sendData(topics::status, data.data(),data.size());
if (err == DUCK_ERR_NONE) {
result = true;
counter++;
Expand Down

0 comments on commit a3beb32

Please sign in to comment.