user_main.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /******************************************************************************
  2. * Copyright 2013-2014 Espressif Systems (Wuxi)
  3. *
  4. * FileName: user_main.c
  5. *
  6. * Description: entry file of user application
  7. *
  8. * Modification history:
  9. * 2015/1/23, v1.0 create this file.
  10. *******************************************************************************/
  11. #include "osapi.h"
  12. #include "at_custom.h"
  13. #include "user_interface.h"
  14. // test :AT+TEST=1,"abc"<,3>
  15. void ICACHE_FLASH_ATTR
  16. at_setupCmdTest(uint8_t id, char *pPara)
  17. {
  18. int result = 0, err = 0, flag = 0;
  19. uint8 buffer[32] = {0};
  20. pPara++; // skip '='
  21. //get the first parameter
  22. // digit
  23. flag = at_get_next_int_dec(&pPara, &result, &err);
  24. // flag must be ture because there are more parameter
  25. if (flag == FALSE) {
  26. at_response_error();
  27. return;
  28. }
  29. if (*pPara++ != ',') { // skip ','
  30. at_response_error();
  31. return;
  32. }
  33. os_sprintf(buffer, "the first parameter:%d\r\n", result);
  34. at_port_print(buffer);
  35. //get the second parameter
  36. // string
  37. at_data_str_copy(buffer, &pPara, 10);
  38. at_port_print("the second parameter:");
  39. at_port_print(buffer);
  40. at_port_print("\r\n");
  41. if (*pPara == ',') {
  42. pPara++; // skip ','
  43. result = 0;
  44. //there is the third parameter
  45. // digit
  46. flag = at_get_next_int_dec(&pPara, &result, &err);
  47. // we donot care of flag
  48. os_sprintf(buffer, "the third parameter:%d\r\n", result);
  49. at_port_print(buffer);
  50. }
  51. if (*pPara != '\r') {
  52. at_response_error();
  53. return;
  54. }
  55. at_response_ok();
  56. }
  57. void ICACHE_FLASH_ATTR
  58. at_testCmdTest(uint8_t id)
  59. {
  60. uint8 buffer[32] = {0};
  61. os_sprintf(buffer, "%s\r\n", "at_testCmdTest");
  62. at_port_print(buffer);
  63. at_response_ok();
  64. }
  65. void ICACHE_FLASH_ATTR
  66. at_queryCmdTest(uint8_t id)
  67. {
  68. uint8 buffer[32] = {0};
  69. os_sprintf(buffer, "%s\r\n", "at_queryCmdTest");
  70. at_port_print(buffer);
  71. at_response_ok();
  72. }
  73. void ICACHE_FLASH_ATTR
  74. at_exeCmdTest(uint8_t id)
  75. {
  76. uint8 buffer[32] = {0};
  77. os_sprintf(buffer, "%s\r\n", "at_exeCmdTest");
  78. at_port_print(buffer);
  79. at_response_ok();
  80. }
  81. extern void at_exeCmdCiupdate(uint8_t id);
  82. at_funcationType at_custom_cmd[] = {
  83. {"+TEST", 5, at_testCmdTest, at_queryCmdTest, at_setupCmdTest, at_exeCmdTest},
  84. #ifdef AT_UPGRADE_SUPPORT
  85. {"+CIUPDATE", 9, NULL, NULL, NULL, at_exeCmdCiupdate}
  86. #endif
  87. };
  88. void user_rf_pre_init(void)
  89. {
  90. }
  91. void user_init(void)
  92. {
  93. char buf[64] = {0};
  94. at_customLinkMax = 5;
  95. at_init();
  96. os_sprintf(buf,"compile time:%s %s",__DATE__,__TIME__);
  97. at_set_custom_info(buf);
  98. at_port_print("\r\nready\r\n");
  99. at_cmd_array_regist(&at_custom_cmd[0], sizeof(at_custom_cmd)/sizeof(at_custom_cmd[0]));
  100. }