webBuilder.UseUrls("http://0.0.0.0:80/");
class Serial {
public:
std::function<void()> onCall;
};
class Protocol {
private:
Serial *serial;
int i = 0;
public:
Protocol() {}
Protocol(Serial &s) {
serial = &s;
serial->onCall = [this]() {
this->i = 200;
};
}
void Test() {
serial->onCall();
std::cout << i << std::endl;
}
};
int main() {
auto s = Serial();
Protocol p;
p = { s };
p.Test();
std::system("pause");
}
Protocol p = s;
class SensorTask : public Thread<300> {
private:
Protocol<10, 100> protocol;
public:
virtual void Loop() override {
protocol = { BSP::serial2, BSP::serial2DDPin };
while (true) {
auto status = protocol.GetData();
Sleep(1s);
}
}
};