Демонстрационная прошивка отладочного комплекта МТС NB-IoT
at_cmd_support.c
См. документацию.
1 #include "at_cmd_support.h"
2 
9 static volatile uint8_t response_buffer[AT_RESP_BUFFER_LENGTH];
10 static volatile uint16_t buffer_index=0;
11 static volatile uint8_t resp_buffer_overflow=0;
12 static volatile uint8_t resp_buffer_overrun=0;
13 static volatile uint8_t lock_buffer=0;
14 #define NO_RESP_RECEIVED 0
15 #define RECEIVED_OK 1
16 #define RECEIVED_ERROR 2
17 static volatile uint8_t resp_received=NO_RESP_RECEIVED;
18 //This is the sequences which terminate the response. By observing it we can determine when the complete response has arrived.
19 #define OK_LEN 2
20 #define ERR_LEN 5
21 static const uint8_t resp_end_OK[] = "OK";
22 static const uint8_t resp_end_ERR[] = "ERROR";
23 static volatile uint8_t OK_index=0;
24 static volatile uint8_t ERR_index=0;
25 
26 #if USE_ADVANCED_URC_SEARCH == 1
27 #define UDP_URC_LIST_INDEX 0
28 #define NIDD_URC_LIST_INDEX 1
29 volatile expected_URC_entry_t URC_search_list[NUM_URC_SUPPORTED] = {
30 
31 {"+UUSORF: ",0,0,0}, /* UDP data received */
32 {"+CRTDCP:",0,0,0} /* Control plane (NIDD) data received */
33 
34 };
35 #else
36 #define URC_UDPRCV_LEN 9
37 static const uint8_t resp_urc_udp_rcv[] = "+UUSORF: ";
38 static volatile uint8_t URC_index=0;
39 static volatile uint8_t URC_UDP_received=0;
40 #endif
41 
42 void USART3_IRQHandler(void)
43 {
44  volatile uint8_t tmp;
45  //static uint8_t urc_header_found=0;
46  volatile uint32_t SR_content;
47 #if USE_ADVANCED_URC_SEARCH == 1
48  uint8_t k;
49 #endif
50 
51  SR_content = USART3->SR;
52  tmp = USART3->DR;
53  USART3->SR = 0;
54 
55  if (!lock_buffer)
56  {
57  if (SR_content & USART_SR_ORE)
58  {
59  //Reset the search because of an overrun error
60  buffer_index=0;
61  OK_index=0;
62  ERR_index=0;
63 #if USE_ADVANCED_URC_SEARCH == 1
64  for (k=0; k<NUM_URC_SUPPORTED; k++)
65  {
66  URC_search_list[k].match_counter = 0;
67  }
68 #else
69  URC_index=0;
70 #endif
71  }
72 
73  if (tmp!=0)
74  {
75  response_buffer[buffer_index] = tmp;
76 
77 #ifndef NO_URC_SEARCH
78  #if USE_ADVANCED_URC_SEARCH == 1
79  //Perform symbol-by-symbol comparison for each URC we want to support
80  for (k=0; k<NUM_URC_SUPPORTED; k++)
81  {
82  if (URC_search_list[k].URC_detected == 0)
83  {
84  //If the header of this URC was already detected, there is no need to continue its search
85  if (URC_search_list[k].URC_header_detected == 0)
86  {
87  //Compare symbol by symbol
88  if (response_buffer[buffer_index] == URC_search_list[k].URC_string_name[URC_search_list[k].match_counter])
89  {
90  URC_search_list[k].match_counter++;
91 
92  //If the next symbol has a zero value, it means that we are at the end of the name string, i.e. URC header is detected
93  if (URC_search_list[k].URC_string_name[URC_search_list[k].match_counter] == 0)
94  {
95  URC_search_list[k].match_counter = 0;
96  URC_search_list[k].URC_header_detected = 1;
97  }
98  }
99  else
100  {
101  //Reset search at any non-matching character
102  URC_search_list[k].match_counter = 0;
103  }
104  }
105  else
106  {
107  //If URC header was found, then we just wait for CR-LF sequence, which completes the URC message
108  if ((response_buffer[buffer_index] == 0x0A) && (response_buffer[buffer_index - 1] == 0x0D))
109  {
110  lock_buffer = 1;
111  URC_search_list[k].URC_detected = 1;
112  URC_search_list[k].URC_header_detected = 0;
113  URC_search_list[k].match_counter = 0;
114  }
115  }
116  }
117  }
118  #else
119  #warning Firmware compiled with legacy URC search engine. NIDD will not work properly.
120  if (response_buffer[buffer_index]==resp_urc_udp_rcv[URC_index])
121  {
122  URC_index++;
123 
124  if (URC_index>=URC_UDPRCV_LEN)
125  {
126  URC_index=0;
127  urc_header_found=1;
128  }
129  }
130  else
131  {
132  URC_index=0;
133  }
134 
135  if ((urc_header_found) && (response_buffer[buffer_index]==0x0A) && (response_buffer[buffer_index-1]==0x0D))
136  {
137  /* URC ends with CR-LF */
138  lock_buffer=1;
139  URC_UDP_received=1;
140  urc_header_found=0;
141  }
142  #endif
143 #else
144 #warning URC support turned off. UDP and NIDD will not work properly.
145 #endif
146 
147 #ifndef DEBUG_NO_RESP_END_SEARCH
148  if (response_buffer[buffer_index]==resp_end_OK[OK_index])
149  {
150  OK_index++;
151 
152  if (OK_index>=OK_LEN)
153  {
154  lock_buffer=1;
155  OK_index=0;
156  resp_received = RECEIVED_OK;
157  }
158  }
159  else
160  {
161  OK_index=0;
162  }
163 
164  if (response_buffer[buffer_index]==resp_end_ERR[ERR_index])
165  {
166  ERR_index++;
167 
168  if (ERR_index>=ERR_LEN)
169  {
170  lock_buffer=1;
171  ERR_index=0;
172  resp_received = RECEIVED_ERROR;
173  }
174  }
175  else
176  {
177  ERR_index=0;
178  }
179 #else
180  #warning Response end detection is deactivated; AT-command engine is in debug mode.
181  resp_received=1;
182 #endif
183 
184  buffer_index++;
185  }
186  }
187  else
188  {
189  tmp = USART3->DR; //Just to clear interrupt/error flags
190 
191  //Ignore delimiters
192  if ((tmp!='\r') && (tmp!='\n') && (tmp!=' '))
193  {
194  resp_buffer_overrun=1;
195  }
196  }
197 
198  if (buffer_index>=AT_RESP_BUFFER_LENGTH)
199  {
200  buffer_index=AT_RESP_BUFFER_LENGTH-1;
201  resp_buffer_overflow=1;
202  }
203 }
204 
205 /* Wait some time for a response. If timeout has been reached, but no answer was received, the function returns the current state value, i.e. NO_RESP_RECEIVED */
206 uint8_t __wait_AT_response(uint32_t timeout)
207 {
208  volatile uint32_t safety_counter;
209 
210  safety_counter = 0;
211  while ((resp_received==NO_RESP_RECEIVED) && (safety_counter<timeout))
212  {
213  safety_counter++;
214  }
215 
216  return resp_received;
217 }
218 
219 /* Resets the state of a state machine controlling AT response reception, gets ready for the new data. */
220 void __AT_FSM_rearm(void)
221 {
222 #if USE_ADVANCED_URC_SEARCH == 1
223  uint8_t k;
224 #endif
225 
226  resp_received = NO_RESP_RECEIVED;
227  lock_buffer = 0;
228  resp_buffer_overflow = 0;
229  resp_buffer_overrun = 0;
230  buffer_index = 0;
231 #if USE_ADVANCED_URC_SEARCH == 1
232  for (k=0; k<NUM_URC_SUPPORTED; k++)
233  {
234  URC_search_list[k].match_counter = 0;
235  URC_search_list[k].URC_detected = 0;
236  URC_search_list[k].URC_header_detected = 0;
237  }
238 #else
239  URC_UDP_received = 0;
240 #endif
241 }
242 
243 uint16_t AT_ReadReponseBuffer(uint8_t* buffer_out,uint16_t buffer_length,uint8_t* is_overflowed,uint8_t* overrun_detected,uint8_t *error_status,uint32_t max_wait_time)
244 {
245  uint16_t k;
246  uint16_t data_length;
247  uint8_t wait_result;
248 
249 #ifndef NO_RESP_END_SEARCH
250  wait_result = __wait_AT_response(max_wait_time);
251 
252  if (wait_result==NO_RESP_RECEIVED)
253  {
254  /* Timeout has elapsed, but still no response received */
255  if (is_overflowed!=NULL)
256  {
257  (*is_overflowed) = 0;
258  }
259 
260  if (overrun_detected!=NULL)
261  {
262  (*overrun_detected) = 0;
263  }
264 
265  buffer_out[0]=0;
266 
267  __AT_FSM_rearm();
268 
269  return 0;
270  }
271 #endif
272 
273  lock_buffer=1; //Disable writing to buffer to safely copy its contents
274  data_length = buffer_index;
275 
276  if (buffer_out!=NULL)
277  {
278  for (k=0; k<data_length; k++)
279  {
280  if (k==(buffer_length-1))
281  {
282  break;
283  }
284 
285  buffer_out[k] = response_buffer[k];
286  }
287 
288  buffer_out[k] = 0;
289  }
290 
291  if (is_overflowed!=NULL)
292  {
293  (*is_overflowed) = resp_buffer_overflow;
294  }
295 
296  if (overrun_detected!=NULL)
297  {
298  (*overrun_detected) = resp_buffer_overrun;
299  }
300 
301  if (error_status!=NULL)
302  {
303  if (wait_result==RECEIVED_ERROR)
304  {
305  (*error_status) = 1;
306  }
307  else
308  {
309  (*error_status) = 0;
310  }
311  }
312 
313  __AT_FSM_rearm();
314 
315  return data_length;
316 }
317 
318 void AT_SendCommand(const uint8_t *cmd)
319 {
320  __AT_FSM_rearm();
321  UART_SendString(USART3,cmd);
322 }
323 
324 uint8_t AT_CreateUDPSocket(uint32_t max_wait_time)
325 {
326  uint8_t resp;
327  uint8_t *data_start;
328  uint8_t socket_id;
329 
330  AT_SendCommand("AT+USOCR=17\r\n");
331 
332  resp = __wait_AT_response(max_wait_time);
333 
334  if ((resp==NO_RESP_RECEIVED) || (resp==RECEIVED_ERROR))
335  {
336  if (resp==RECEIVED_ERROR)
337  {
338  __AT_FSM_rearm();
339  }
340 
341  return 255;
342  }
343 
344  lock_buffer = 1;
345  response_buffer[buffer_index]=0;
346 
347  data_start = strstr((char *)response_buffer,"+USOCR: ");
348 
349  if (data_start==NULL)
350  {
351  return 255;
352  }
353 
354  /*
355  Move to the position after "+USOCR: ", read the ASCII representation of the socket ID and convert it to integer in-place.
356  SARA-R410 only supports <10 sockets, so the value will always consist of one digit - no problem with this.
357  */
358  socket_id = data_start[8] - '0';
359 
360  __AT_FSM_rearm();
361 
362  return socket_id;
363 }
364 
365 uint8_t AT_CloseUDPSocket(uint8_t socket_id,uint32_t max_wait_time)
366 {
367  uint8_t cmd[20];
368  uint8_t result;
369 
370  snprintf(cmd,20,"AT+USOCL=%d\r\n",socket_id);
371 
372  AT_SendCommand(cmd);
373  result = __wait_AT_response(max_wait_time);
374 
375  if ((result == NO_RESP_RECEIVED) || (result == RECEIVED_ERROR))
376  {
377  if (result==RECEIVED_ERROR)
378  {
379  __AT_FSM_rearm();
380  }
381 
382  return 0;
383  }
384 
385  __AT_FSM_rearm();
386 
387  return 1;
388 }
389 
390 at_udp_error_t AT_SendUDPData(uint8_t socket_id,uint8_t *target_IP_string,uint16_t target_port,uint8_t *data,uint16_t data_length,uint32_t max_wait_time)
391 {
392  uint8_t cmd_header[30];
393  const uint8_t conv_LUT[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
394  uint32_t k;
395  uint8_t resp;
396 
397  UART_SendString(USART3,"AT+UDCONF=1,1\r\n");
398 
399  resp = __wait_AT_response(max_wait_time);
400 
401  if (resp==NO_RESP_RECEIVED)
402  {
403  return AT_NO_RESPONSE;
404  }
405 
406  __AT_FSM_rearm();
407 
408  if (resp==RECEIVED_ERROR)
409  {
410  return AT_ERROR;
411  }
412 
413  sprintf(cmd_header,"AT+USOST=%d,\"%s\",%d,%d,\"",socket_id,target_IP_string,target_port,data_length);
414  UART_SendString(USART3,cmd_header);
415 
416  for (k=0; k<data_length; k++)
417  {
418  UART_SendByte(USART3,conv_LUT[data[k] >> 4]);
419  UART_SendByte(USART3,conv_LUT[data[k] & 0x0F]);
420  }
421 
422  UART_SendString(USART3,"\"\r\n");
423 
424  resp = __wait_AT_response(max_wait_time);
425 
426  if (resp==NO_RESP_RECEIVED)
427  {
428  return AT_NO_RESPONSE;
429  }
430 
431  __AT_FSM_rearm();
432 
433  if (resp==RECEIVED_ERROR)
434  {
435  return AT_ERROR;
436  }
437 
438  return AT_NO_ERROR;
439 }
440 
441 uint8_t AT_CheckUDPReceived(uint8_t *socket_id,uint16_t *packet_length)
442 {
443  uint8_t *data_start;
444  uint8_t k;
445 #if USE_ADVANCED_URC_SEARCH == 1
446  if (URC_search_list[UDP_URC_LIST_INDEX].URC_detected == 0)
447 #else
448  if (URC_UDP_received==0)
449 #endif
450  {
451  if (socket_id!=NULL)
452  {
453  (*socket_id) = 255;
454  }
455 
456  if (packet_length!=NULL)
457  {
458  (*packet_length) = 0;
459  }
460 
461  return 0;
462  }
463 
464  response_buffer[buffer_index] = 0;
465 
466  data_start = strstr((char *)response_buffer,"+UUSORF: ");
467 
468  if (socket_id!=NULL)
469  {
470  /* The socket ID cannot be greater than 9 (in fact SARA-R410 supports inly 7 sockets), so we can go the simple way. */
471  (*socket_id) = data_start[9] - '0';
472  }
473 
474  k=0;
475  if (packet_length!=NULL)
476  {
477  /* But for the packet length we'll go the long way. */
478  (*packet_length) = 0;
479  while ((data_start[11+k]>='0') && (data_start[11+k]<='9') && (k<5))
480  {
481  (*packet_length) *= 10;
482  (*packet_length) += data_start[11 + k] - '0';
483  k++;
484  }
485  }
486 
487  __AT_FSM_rearm();
488 
489  if (k>=5)
490  {
491  /* Something went wrong. */
492  return 0;
493  }
494 
495  return 1;
496 }
497 
498 uint16_t AT_CheckNIDDReceived(uint8_t *data_out)
499 {
500 #if USE_ADVANCED_URC_SEARCH == 0
501 #warning AT_CheckNIDDReceived() is unavailable because advanced URC search is not included. Placeholder code is compiled instead of AT_CheckNIDDReceived().
502  return 0;
503 #else
504  uint32_t URC_data_length;
505  uint8_t URC_data_buffer[520];
506  uint16_t k;
507 
508  if (URC_search_list[NIDD_URC_LIST_INDEX].URC_detected == 0)
509  {
510  return 0;
511  }
512 
513  response_buffer[buffer_index] = 0;
514 
515  sscanf((char *)response_buffer,"\r\n\r\n+CRTDCP:%*d,%d,\"%[^\r\n\"]",&URC_data_length,URC_data_buffer);
516 
517  if (data_out != NULL)
518  {
519  k=0;
520  while ((k<URC_data_length) && (k<512))
521  {
522  data_out[k] = URC_data_buffer[k];
523  k++;
524  }
525 
526  data_out[k] = 0;
527  }
528 
529  __AT_FSM_rearm();
530 
531  return URC_data_length;
532 #endif
533 }
534 
535 inline uint8_t h_digit_to_nibble(uint8_t h_digit)
536 {
537  if ((h_digit>='0') && (h_digit<='9'))
538  {
539  return h_digit - '0';
540  }
541 
542  if ((h_digit>='A') && (h_digit<='F'))
543  {
544  return (h_digit - 'A') + 10;
545  }
546 
547  if ((h_digit>='a') && (h_digit<='f'))
548  {
549  return (h_digit - 'a') + 10;
550  }
551 
552  return 0;
553 }
554 
555 at_udp_error_t AT_ReadUDPData(uint8_t socket_id,uint16_t read_length,uint8_t *source_IP,uint16_t *source_port,uint8_t *data_out,uint32_t max_wait_time)
556 {
557  uint8_t cmd[20];
558  uint8_t resp;
559  uint8_t *response_pointer;
560  uint8_t ip_string[20];
561  uint16_t port;
562  uint16_t data_bytes_count;
563  uint8_t data_string[128];
564  uint8_t k;
565  uint16_t data_ptr;
566 
567  sprintf(cmd,"AT+USORF=%d,%d\r\n",socket_id,read_length);
568  AT_SendCommand(cmd);
569 
570  resp = __wait_AT_response(max_wait_time);
571 
572  if (resp == NO_RESP_RECEIVED)
573  {
574  return AT_NO_RESPONSE;
575  }
576 
577  if (resp == RECEIVED_ERROR)
578  {
579  __AT_FSM_rearm();
580 
581  return AT_ERROR;
582  }
583 
584  response_buffer[buffer_index] = 0;
585 
586  response_pointer = strstr((char *)response_buffer,"+USORF: ");
587 
588  if (sscanf(response_pointer,"+USORF: %*d,\"%[^\"]\",%d,%d,\"%[^\"]",ip_string,&port,&data_bytes_count,data_string) != 4)
589  {
590  __AT_FSM_rearm();
591 
592  return AT_FORMAT_ERROR;
593  }
594 
595  if (data_out!=NULL)
596  {
597  data_ptr=0;
598  k=0;
599 
600  while (k<(data_bytes_count*2))
601  {
602  data_out[data_ptr] = (h_digit_to_nibble(data_string[k]) << 4) | h_digit_to_nibble(data_string[k+1]);
603  data_ptr++;
604  k+=2;
605  }
606  }
607 
608  if (source_IP!=NULL)
609  {
610  strcpy(source_IP,ip_string);
611  }
612 
613  if (source_port!=NULL)
614  {
615  (*source_port) = port;
616  }
617 
618  __AT_FSM_rearm();
619 
620  return AT_NO_ERROR;
621 }
622 
623 int16_t AT_GetRSSI(uint32_t timeout)
624 {
625  uint8_t *result_pos;
626  uint8_t k;
627  int16_t rssi_num;
628  int16_t rssi_actual;
629  uint8_t buf_copy[100];
630  uint16_t buf_copy_length;
631  uint8_t error;
632 
633  AT_SendCommand("AT+CSQ\r\n");
634 
635  buf_copy_length = AT_ReadReponseBuffer(buf_copy,100,NULL,NULL,&error,timeout);
636 
637  if ((error!=0) || (buf_copy_length==0))
638  {
639  return 0;
640  }
641 
642  result_pos = strstr((char *)buf_copy,"+CSQ: ");
643 
644  if (result_pos==NULL)
645  {
646  return -1002;
647  }
648 
649  /*
650  There can be no more than 5 valuable characters, because both resulting values do not exceed 99;
651  so the longest string looks like "+CSQ: 99,99".
652  By setting k=6 we skip "+CSQ: " part.
653  */
654  k=6;
655  rssi_num = 0;
656  while ((result_pos[k]!=',') && (result_pos[k]!=0) && (k<8))
657  {
658  rssi_num *=10;
659  rssi_num += (result_pos[k] - '0');
660  k++;
661  }
662 
663  if ((rssi_num>=2) && (rssi_num<=30))
664  {
665  rssi_actual = 2*rssi_num - 113;
666  }
667  else
668  {
669  if (rssi_num==1)
670  {
671  rssi_actual = -111;
672  }
673 
674  if (rssi_num==31)
675  {
676  rssi_actual = -51;
677  }
678  }
679 
680  return rssi_actual;
681 }
682 
683 uint8_t AT_ReadICCID(uint8_t *ICCID,uint32_t timeout)
684 {
685  uint8_t *id_pos;
686  uint8_t k;
687  uint8_t buf_copy[100];
688  uint16_t buf_copy_length;
689  uint8_t error;
690 
691  AT_SendCommand("AT+CCID\r\n");
692 
693  buf_copy_length = AT_ReadReponseBuffer(buf_copy,100,NULL,NULL,&error,timeout);
694 
695  if ((error!=0) || (buf_copy_length==0))
696  {
697  if (ICCID!=NULL)
698  {
699  ICCID[0]=0;
700  }
701 
702  return 0;
703  }
704 
705  id_pos = strstr((char *)buf_copy,"+CCID: ");
706 
707  if (id_pos==NULL)
708  {
709  return 0;
710  }
711 
712  if (ICCID!=NULL)
713  {
714  k=0;
715  while ((id_pos[7+k]!='\r') && (k<49))
716  {
717  ICCID[k] = id_pos[7+k];
718  k++;
719  }
720  ICCID[k]=0;
721  }
722 
723  return 1;
724 }
725 
726 uint8_t AT_ReadIMEI(uint8_t *IMEI,uint32_t timeout)
727 {
728  uint8_t *resp_start;
729  uint8_t buf_copy[100];
730  uint16_t k;
731  uint16_t buf_copy_length;
732  uint8_t error;
733 
734  AT_SendCommand("AT+CGSN\r\n");
735  buf_copy_length = AT_ReadReponseBuffer(buf_copy,100,NULL,NULL,&error,timeout);
736 
737  if ((error!=0) || (buf_copy_length==0))
738  {
739  if (IMEI!=NULL)
740  {
741  IMEI[0]=0;
742  }
743 
744  return 0;
745  }
746 
747  resp_start = strstr(buf_copy,"AT+CGSN\r\r\n");
748 
749  if (IMEI!=NULL)
750  {
751  k=0;
752  while ((resp_start[10+k]!='\r') && (k<49))
753  {
754  IMEI[k] = resp_start[10+k];
755  k++;
756  }
757  IMEI[k] = 0;
758  }
759 
760  return 1;
761 }
762 
763 uint8_t AT_SendStringUsingNIDD(uint8_t *str,uint32_t timeout)
764 {
765  uint8_t cmd_buffer[512];
766  uint16_t string_length;
767  uint8_t error_state;
768 
769  //Determining the length of a string safely
770  string_length=0;
771  while ((str[string_length]!=0) && (string_length<450))
772  {
773  string_length++;
774  }
775 
776  if (string_length==450)
777  {
778  //Possibly unterminated string?
779  return 0;
780  }
781 
782  snprintf(cmd_buffer,512,"AT+CSODCP=1,%d,\"%s\"\r\n",string_length,str);
783  AT_SendCommand(cmd_buffer);
784 
785  AT_ReadReponseBuffer(NULL,0,NULL,NULL,&error_state,timeout);
786 
787  if (error_state!=0)
788  {
789  return 0;
790  }
791  else
792  {
793  return 1;
794  }
795 }
796 
797 uint8_t AT_IsRegistered(uint32_t timeout)
798 {
799  uint8_t resp[100];
800  uint8_t error;
801  uint32_t reg_state;
802  uint8_t *resp_ptr;
803  uint32_t res;
804 
805  AT_SendCommand("AT+CEREG?\r\n");
806  AT_ReadReponseBuffer(resp,100,NULL,NULL,&error,timeout);
807 
808  resp_ptr = strstr(resp,"+CEREG:");
809 
810  if (resp_ptr == NULL)
811  {
812  error++;
813  }
814  else
815  {
816  res = sscanf(resp_ptr,"+CEREG: %*d,%d",&reg_state);
817 
818  if ((reg_state != 1) || (res == 0))
819  {
820  error++;
821  }
822  }
823 
824  if (error!=0)
825  {
826  return 0;
827  }
828  else
829  {
830  return 1;
831  }
832 }
833 
834 uint8_t AT_SwitchPSM(uint8_t state,uint32_t timeout)
835 {
836  uint8_t error;
837 
838  if (state!=0)
839  {
840  AT_SendCommand("AT+CPSMS=1\r\n");
841  }
842  else
843  {
844  AT_SendCommand("AT+CPSMS=0\r\n");
845  }
846 
847  AT_ReadReponseBuffer(NULL,0,NULL,NULL,&error,timeout);
848 
849  return !(error);
850 }
AT_ReadReponseBuffer
uint16_t AT_ReadReponseBuffer(uint8_t *buffer_out, uint16_t buffer_length, uint8_t *is_overflowed, uint8_t *overrun_detected, uint8_t *error_status, uint32_t max_wait_time)
Чтение ответа модуля.
Definition: at_cmd_support.c:243
AT_CheckNIDDReceived
uint16_t AT_CheckNIDDReceived(uint8_t *data_out)
Проверка наличия NIDD-данных и, при их наличии, чтение принятой строки
Definition: at_cmd_support.c:498
at_cmd_support.h
AT_ReadICCID
uint8_t AT_ReadICCID(uint8_t *ICCID, uint32_t timeout)
Чтение ICCID SIM-карты/чипа
Definition: at_cmd_support.c:683
AT_CheckUDPReceived
uint8_t AT_CheckUDPReceived(uint8_t *socket_id, uint16_t *packet_length)
Позволяет проверить, есть ли в буфере радиомодуля входящий UDP-пакет.
Definition: at_cmd_support.c:441
AT_RESP_BUFFER_LENGTH
#define AT_RESP_BUFFER_LENGTH
Definition: at_cmd_support.h:24
UART_SendByte
void UART_SendByte(USART_TypeDef *uart_inst, uint8_t b)
Посылает байт через указанный USART.
Definition: uart_api.c:9
at_udp_error_t
at_udp_error_t
Definition: at_cmd_support.h:40
expected_URC_entry_t::URC_detected
uint8_t URC_detected
Definition: at_cmd_support.h:72
NUM_URC_SUPPORTED
#define NUM_URC_SUPPORTED
Количество URC, поиск которых будет производиться
Definition: at_cmd_support.h:58
AT_ReadUDPData
at_udp_error_t AT_ReadUDPData(uint8_t socket_id, uint16_t read_length, uint8_t *source_IP, uint16_t *source_port, uint8_t *data_out, uint32_t max_wait_time)
Чтение данных из указанного UDP-сокета
Definition: at_cmd_support.c:555
AT_ERROR
Definition: at_cmd_support.h:44
AT_SendUDPData
at_udp_error_t AT_SendUDPData(uint8_t socket_id, uint8_t *target_IP_string, uint16_t target_port, uint8_t *data, uint16_t data_length, uint32_t max_wait_time)
Посылает пакет UDP по указанному адресу.
Definition: at_cmd_support.c:390
AT_SendStringUsingNIDD
uint8_t AT_SendStringUsingNIDD(uint8_t *str, uint32_t timeout)
Пересылает данные с помощью технологии NIDD.
Definition: at_cmd_support.c:763
AT_FORMAT_ERROR
Definition: at_cmd_support.h:46
expected_URC_entry_t
Структура, описывающая URC-сообщение, поиск которого будет производиться во входном потоке символов о...
Definition: at_cmd_support.h:63
expected_URC_entry_t::match_counter
uint8_t match_counter
Definition: at_cmd_support.h:68
AT_SwitchPSM
uint8_t AT_SwitchPSM(uint8_t state, uint32_t timeout)
Включить или выключить использование модулем режима PSM.
Definition: at_cmd_support.c:834
AT_IsRegistered
uint8_t AT_IsRegistered(uint32_t timeout)
Проверка регистрации модуля в сети LTE.
Definition: at_cmd_support.c:797
AT_CreateUDPSocket
uint8_t AT_CreateUDPSocket(uint32_t max_wait_time)
Создает UDP-сокет средствами радиомодуля.
Definition: at_cmd_support.c:324
AT_NO_ERROR
Definition: at_cmd_support.h:50
AT_ReadIMEI
uint8_t AT_ReadIMEI(uint8_t *IMEI, uint32_t timeout)
Чтение IMEI радиомодуля
Definition: at_cmd_support.c:726
AT_SendCommand
void AT_SendCommand(const uint8_t *cmd)
Посылает AT-команду в модуль.
Definition: at_cmd_support.c:318
UART_SendString
void UART_SendString(USART_TypeDef *uart_inst, const uint8_t *str)
Definition: uart_api.c:18
AT_NO_RESPONSE
Definition: at_cmd_support.h:42
AT_GetRSSI
int16_t AT_GetRSSI(uint32_t timeout)
Получение мощности принимаемого сигнала в dBm.
Definition: at_cmd_support.c:623
expected_URC_entry_t::URC_header_detected
uint8_t URC_header_detected
Definition: at_cmd_support.h:70
AT_CloseUDPSocket
uint8_t AT_CloseUDPSocket(uint8_t socket_id, uint32_t max_wait_time)
Закрывает ранее созданный сокет UDP.
Definition: at_cmd_support.c:365