16
16
*/
17
17
18
18
#include " UBLOX_AT_CellularStack.h"
19
- #include " mbed_poll .h"
19
+ #include " rtos/ThisThread .h"
20
20
21
21
using namespace mbed ;
22
22
using namespace mbed_cellular_util ;
@@ -168,17 +168,26 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_sendto_impl(CellularSocket
168
168
MBED_ASSERT (socket->id != -1 );
169
169
170
170
int sent_len = 0 ;
171
- pollfh fhs;
172
- fhs.fh = _at.get_file_handle ();
173
- fhs.events = POLLIN;
171
+ uint8_t ch = 0 ;
174
172
175
173
if (socket->proto == NSAPI_UDP) {
176
174
if (size > UBLOX_MAX_PACKET_SIZE) {
177
175
return NSAPI_ERROR_PARAMETER;
178
176
}
179
177
_at.cmd_start_stop (" +USOST" , " =" , " %d%s%d%d" , socket->id , address.get_ip_address (), address.get_port (), size);
180
178
181
- (void )poll (&fhs, 1 , 50 );
179
+ for (int a = 0 ; a < 3 ; a++)
180
+ {
181
+ rtos::ThisThread::sleep_for (50 );
182
+ _at.read_bytes (&ch, 1 );
183
+ if (ch == ' @' )
184
+ break ;
185
+ }
186
+
187
+ if (ch != ' @' )
188
+ return NSAPI_ERROR_TIMEOUT;
189
+
190
+ rtos::ThisThread::sleep_for (50 ); // wait for 50ms before sending data
182
191
_at.write_bytes ((uint8_t *)data, size);
183
192
184
193
_at.resp_start (" +USOST:" );
@@ -201,7 +210,18 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_sendto_impl(CellularSocket
201
210
}
202
211
_at.cmd_start_stop (" +USOWR" , " =" , " %d%d" , socket->id , blk);
203
212
204
- (void )poll (&fhs, 1 , 50 );
213
+ for (int a = 0 ; a < 3 ; a++)
214
+ {
215
+ rtos::ThisThread::sleep_for (50 );
216
+ _at.read_bytes (&ch, 1 );
217
+ if (ch == ' @' )
218
+ break ;
219
+ }
220
+
221
+ if (ch != ' @' )
222
+ return NSAPI_ERROR_TIMEOUT;
223
+
224
+ rtos::ThisThread::sleep_for (50 ); // wait for 50ms before sending data
205
225
_at.write_bytes ((uint8_t *)buf, blk);
206
226
207
227
_at.resp_start (" +USOWR:" );
0 commit comments