Skip to content

Commit

Permalink
Applied style
Browse files Browse the repository at this point in the history
  • Loading branch information
themarpe committed Nov 24, 2021
1 parent 859fefc commit 40a79d3
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions examples/bootloader/poe_set_ip.cpp
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
#include <chrono>
#include <string>
#include <iostream>
#include <string>

#include "depthai/depthai.hpp"
#include "depthai/xlink/XLinkConnection.hpp"

// for string delimiter
std::vector<int> split (std::string s, std::string delimiter) {
std::vector<int> split(std::string s, std::string delimiter) {
size_t pos_start = 0, pos_end, delim_len = delimiter.length();
std::string token;
std::vector<int> res;

while ((pos_end = s.find (delimiter, pos_start)) != std::string::npos) {
token = s.substr (pos_start, pos_end - pos_start);
while((pos_end = s.find(delimiter, pos_start)) != std::string::npos) {
token = s.substr(pos_start, pos_end - pos_start);
pos_start = pos_end + delim_len;
res.push_back (stoi(token));
res.push_back(stoi(token));
}
res.push_back(stoi(s.substr(pos_start)));
return res;
}

std::string checkStr(std::string str) {
std::vector<int> v = split (str, ".");
std::vector<int> v = split(str, ".");
if(v.size() != 4) {
std::cout << "Entered value " << str << " doesn't contain 3 dots. Value has to be in the following format: '255.255.255.255'" << std::endl;
exit(0);
}
for (auto i : v) {
for(auto i : v) {
if(i < 0 || 255 < i) {
std::cout << "Entered values can't be above 255!" << std::endl;
exit(0);
Expand Down Expand Up @@ -79,19 +79,23 @@ int main(int argc, char** argv) {
return 0;
}
auto conf = dai::DeviceBootloader::Config();
if (key == '1') conf.setStaticIPv4(ip, mask, gateway);
else conf.setDynamicIPv4(ip, mask, gateway);
if(key == '1') {
conf.setStaticIPv4(ip, mask, gateway);
} else {
conf.setDynamicIPv4(ip, mask, gateway);
}

std::tie(success, error) = bl.flashConfig(conf);
}
else if(key == '3') {
} else if(key == '3') {
std::tie(success, error) = bl.flashConfigClear();
}
else {
} else {
std::cout << "Entered value should either be '1', '2' or '3'!";
return 0;
}

if(success) std::cout << "Flashing successful." << std::endl;
else std::cout << "Flashing failed: " << error << std::endl;
if(success) {
std::cout << "Flashing successful." << std::endl;
} else {
std::cout << "Flashing failed: " << error << std::endl;
}
}

0 comments on commit 40a79d3

Please sign in to comment.