109 {
110 switch (u8Msg) {
111 case SOCKET_MSG_BIND: {
112 auto bindMsg = reinterpret_cast<tstrSocketBindMsg*>(pvMsg);
113
114 if (bindMsg && bindMsg->status == 0) {
115
116 listen(sock, 1);
117 }
118 } break;
119 case SOCKET_MSG_LISTEN: {
120 auto listenMsg = reinterpret_cast<tstrSocketListenMsg*>(pvMsg);
121 if (listenMsg && listenMsg->status == 0) {
122
123 accept(sock, nullptr, nullptr);
124 }
125 } break;
126 case SOCKET_MSG_ACCEPT: {
127 auto acceptMsg = reinterpret_cast<tstrSocketAcceptMsg*>(pvMsg);
128 if (acceptMsg && (acceptMsg->sock >= 0)) {
130
132
134 }
135 } break;
136 case SOCKET_MSG_RECV: {
137 auto recvMsg = reinterpret_cast<tstrSocketRecvMsg*>(pvMsg);
138 if (recvMsg && (recvMsg->s16BufferSize > 0)) {
139 {
140 chibios_rt::CriticalSectionLocker csl;
141
142 for (size_t i = 0; i < recvMsg->s16BufferSize; i++) {
144 }
145 }
146
147 size_t nextRecv;
148 if (recvMsg->u16RemainingSize < 1) {
149
150 nextRecv = 1;
151 }
else if (recvMsg->u16RemainingSize >
sizeof(
rxBuf)) {
152
153 nextRecv =
sizeof(
rxBuf);
154 } else {
155
156 nextRecv = recvMsg->u16RemainingSize;
157 }
158
159
160 recv(sock, &
rxBuf, nextRecv, 0);
161 } else {
162 close(sock);
163
165
166 {
167 chibios_rt::CriticalSectionLocker csl;
169 }
170 }
171 } break;
172 case SOCKET_MSG_SEND: {
173
174 chibios_rt::CriticalSectionLocker csl;
176 } break;
177 }
178}
static int connectionSocket
static NO_CACHE uint8_t rxBuf[512]
static input_queue_t wifiIqueue
chibios_rt::BinarySemaphore sendDoneSemaphore(true)