File tree 1 file changed +11
-7
lines changed
1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 6
6
7
7
#include " ST-LIB.hpp"
8
8
9
- uint32_t local_serversocket_port = 8202 ;
10
- std::string localip = " 127.0.0.1" ;
11
- std::unique_ptr<ServerSocket> serversocket = nullptr ;
12
- StackPacket* inputpacket = nullptr ;
9
+
13
10
14
11
int main (void ) {
15
12
#ifdef SIM_ON
16
13
SharedMemory::start ();
17
14
#endif
15
+ uint32_t local_serversocket_port = 8202 ;
16
+ std::string localip = " 127.0.0.1" ;
17
+ std::unique_ptr<ServerSocket> serversocket = nullptr ;
18
+ StackPacket* inputpacket = nullptr ;
18
19
DigitalInput input (PA1);
19
20
bool value = false ;
20
21
serversocket = std::make_unique<ServerSocket>(localip,local_serversocket_port);
21
22
StackPacket* mypacket = new StackPacket (15 ,&value);// Random id
22
23
STLIB::start ();
23
24
24
- Time::register_low_precision_alarm (100 ,[&](){
25
+ Time::register_low_precision_alarm (1000 ,[&](){
25
26
if (mysocket->is_connected () == false ){
26
27
mysocket->reconnect ();
27
28
}
28
29
});
29
30
31
+ Time::register_low_precision_alarm (200 ,[&](){
32
+ serversocket->send_packet (mypacket);
33
+ });
34
+
30
35
while (1 ) {
31
36
value = input.read_pin_state ();
32
- serversocket->send_packet (mypacket);
33
37
STLIB::update ();
34
- std::this_thread::sleep_for (std::chrono::milliseconds (500 ));
38
+ std::this_thread::sleep_for (std::chrono::milliseconds (150 ));
35
39
}
36
40
}
37
41
You can’t perform that action at this time.
0 commit comments