lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @file at_utils.h |
| 3 | * @brief Ìṩ¸øÓ¦ÓÃʹÓõÄsoftapƽ̨¹«¹²½Ó¿Ú |
| 4 | * |
| 5 | * Copyright (C) 2017 Sanechips Technology Co., Ltd. |
| 6 | * @author |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | * |
| 12 | */ |
| 13 | #ifndef __AT_UTILS_H__ |
| 14 | #define __AT_UTILS_H__ |
| 15 | #include "os_type_def.h" |
| 16 | #include "softap_api.h" |
| 17 | |
| 18 | /******************************************************************************* |
| 19 | * Type definitions * |
| 20 | ******************************************************************************/ |
| 21 | |
| 22 | |
| 23 | /******************************************************************************* |
| 24 | * Global function declarations * |
| 25 | ******************************************************************************/ |
| 26 | /** |
| 27 | * @brief ¶¨ÒåATÉÏÏÂÎĵ±Ç°´¦ÀíµÄ״̬»ú£¬ÒÔ¾ö¶¨ÏÂÒ»²½´¦Àí |
| 28 | * @param AT_END ATÁ÷³Ì½áÊø£¬¿Í»§¶Ë¿ÉÒÔÏòÉϲãapp·¢ËÍÏìÓ¦ÏûÏ¢£¬·þÎñ¶ËÐèÒªÏòatͨµÀ·¢ËÍatÏìÓ¦ÃüÁî |
| 29 | * @param AT_CONTINUE AT½»»¥Á÷³Ì¼ÌÐø |
| 30 | * @param AT_END_AND_MSG ÓÃÓÚ·þÎñ¶ËÊÕµ½ATÇëÇóºó£¬Á¢¼´»Ø¸´OK½á¹ûÂ룬ͬʱ»¹Ðè·¢ËÍÏûÏ¢¸ø·þÎñ¶ËAPP |
| 31 | * @param AT_STATE_MAX ÉÏÏÞºê |
| 32 | */ |
| 33 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 34 | enum at_context_state { |
| 35 | AT_END = 0, //ATÁ÷³Ì½áÊø£¬¿Í»§¶Ë¿ÉÒÔÏòÉϲãapp·¢ËÍÏìÓ¦ÏûÏ¢£¬·þÎñ¶ËÐèÒªÏòatͨµÀ·¢ËÍatÏìÓ¦ÃüÁî |
| 36 | AT_CONTINUE,//AT½»»¥Á÷³Ì¼ÌÐø |
| 37 | AT_END_AND_MSG,//ÓÃÓÚ·þÎñ¶ËÊÕµ½ATÇëÇóºó£¬Á¢¼´»Ø¸´OK½á¹ûÂ룬ͬʱ»¹Ðè·¢ËÍÏûÏ¢¸ø·þÎñ¶ËAPP |
| 38 | AT_WAIT_AUTO,//ÓÃÓÚÊÕµ½Ó¦´ðºó£¬ÉÐδ»ñÈ¡µ½ÏëÒªµÄÖ÷¶¯Éϱ¨Ê±£¬·µ»Ø¸ÃÖµ£»Ä¿Ç°½öÓÃÓÚPDP¼¤»îµÄzgipdnsÖ÷¶¯Éϱ¨³ÙÓÚOKºóÉϱ¨µÄÇé¿ö |
| 39 | AT_STATE_MAX,//ÉÏÏÞºê |
| 40 | }; |
| 41 | #endif |
| 42 | |
| 43 | /** |
| 44 | * @brief ´¦Àí×÷Ϊ·þÎñ¶ËµÄÊÕµ½µÄÇëÇóÃüÁî¡£¶ÔÓÚat_ctl±¾µØµÄ·þÎñ¶Ë£¬ÊÕµ½ÇëÇóÖ®ºó£¬×÷Ϊͬ²½´¦Àí·½Ê½Ö±½ÓÔڸú¯ÊýÖд¦Àí£¬²¢·µ»Øok |
| 45 | *¶ÔÓÚDEMO·þÎñ¶Ë(¿Í»§¶þ´Î¿ª·¢×¢²áµÄ·þÎñ¶Ë)ÊÕµ½µÄÇëÇ󣬱ØÐëͨ¹ýÒì²½ÏûÏ¢µÄ·½Ê½£¬ÓÉDEMOµÄAPP·þÎñ¶Ëͨ¹ýÏûÏ¢½øÐÐÓ¦´ð |
| 46 | * @param at_fd ½ÓÊÕATÃüÁîµÄͨµÀ |
| 47 | * @param at_paras ATÃüÁî²ÎÊý |
| 48 | * @param res_msg ÈôΪͬ²½´¦Àí·½Ê½£¬res_msgΪ»Ø¸´µÄ½á¹ûÂ룻ÈôΪÒì²½´¦Àí·½Ê½£¬res_msgΪATÃüÁîת»»ºóµÄÏûÏ¢½á¹¹Ìå |
| 49 | * @param res_msglen ²ÎÊýres_msgµÄ³¤¶È |
| 50 | * @return intÐͽá¹ûÂë ·µ»Øenum at_context_stateö¾ÙÖµ£¬AT_END±íʾͬ²½Ó¦´ð·½Ê½£»AT_CONTINUE±íʾÒì²½Ó¦´ð·½Ê½,ÓÉ¿ò¼Ü¾ö¶¨ÏÂÒ»²½´¦Àí |
| 51 | * @note ¿É²Î¿¼Ê¾Àý´úÂë: user_regist.c |
| 52 | */ |
| 53 | typedef int (*ser_req_func2)(int at_fd, char *at_paras, void ** res_msg, int *res_msglen); |
| 54 | |
| 55 | |
| 56 | /** |
| 57 | * @brief ·þÎñ¶ËAPP·¢Ë͵ÄÓ¦´ðÏûÏ¢µÄATÃüÁî·â×°£¬×îÖÕ×é×°³ÉATÓ¦´ðÃüÁîºó£¬´Óat_fdͨµÀ·¢Ë͸øÔ¶¶Ë¿Í»§¶Ë |
| 58 | * @param rsp_msg APP·¢Ë͵ÄÓ¦´ðÏûÏ¢ÄÚÈÝ |
| 59 | * @param ret ATÃüÁî |
| 60 | * @param retlen ATÃüÁ¶È |
| 61 | * @return intÐͽá¹ûÂë ·µ»Øenum at_context_stateö¾ÙÖµ |
| 62 | * @note ¿É²Î¿¼Ê¾Àý´úÂë: user_regist.c |
| 63 | */ |
| 64 | typedef int (*app_rsp_proc)(void *rsp_msg, void**ret, int *retlen); |
| 65 | |
| 66 | /** |
| 67 | * @brief ¶ÔÓÚÉϱ¨atÃüÁî´¦Àíº¯Êý£¬°üº¬²éѯÖмä½á¹ûºÍÖ÷¶¯Éϱ¨µÄatÃüÁî´¦Àí |
| 68 | * ¶ÔÓÚpsÏà¹ØµÄÖ÷¶¯Éϱ¨ºÍ²éѯÖмä½á¹ûÉϱ¨£¬Ò»°ãÎÞÐ轫Éϱ¨ÄÚÈÝ·¢Ë͸øÆäËûÄ£¿éÓ¦Óã¬Òò´Ë¾¡Á¿Ê¹ÓÃnvºÍÈ«¾Ö±äÁ¿µÄ·½Ê½´æ·Å |
| 69 | * ¶ÔÓÚÀ©Õ¹atµÄÖмä½á¹ûÉϱ¨£¬Ò»°ãÐèÒª½«²éѯ½á¹û·¢Ë͸øÆäËûÄ£¿éÓ¦Ó㬶¯Ì¬ÉêÇëÄڴ棬·ÅÔÚcontextÉÏÏÂÎÄÖеÄapp_para±äÁ¿ÖÐ |
| 70 | * @param at_paras ATÃüÁî×Ö·û´® |
| 71 | * @return charÐÍ×Ö·û´®£¬±íʾת»»ºóµÄatÃüÁî²ÎÊý |
| 72 | * @note |
| 73 | * at_paraÖ¸ÏòÈ¥µôATÃüÁîÍ·²¿ºóµÄµÚÒ»¸ö×Ö·û£¬¼´¡®£º¡¯ |
| 74 | * ·µ»ØµÄATÃüÁîÒ²ÊÇ': '¿ªÍ·µÄATÃüÁî²ÎÊý£¬ |
| 75 | * Àý£º+CSQ: <rssi>,<ber>,<act>, at_paraΪ: <rssi>,<ber>,<act>, ·µ»Ø: <rssi>,<ber> |
| 76 | */ |
| 77 | |
| 78 | typedef char * (*format_inform_func)(char *at_paras); |
| 79 | |
| 80 | |
| 81 | /** |
| 82 | * @brief Éú³Éat¶¯×÷ÇëÇóÃüÁî |
| 83 | * @param cmd ATÃüÁîÇëÇóÃû³Æ |
| 84 | * @param param ATÃüÁîÇëÇó²ÎÊý |
| 85 | * @return at¶¯×÷ÇëÇó×Ö·û´®µÄÖ¸Õë |
| 86 | * @note ÓÉat_ctl¸ºÔðÊÍ·ÅÄÚ´æ |
| 87 | */ |
| 88 | char* at_act_build(char* cmd, char* param); |
| 89 | |
| 90 | /** |
| 91 | * @brief Éú³Éat²éѯÇëÇóÃüÁî |
| 92 | * @param cmd ATÃüÁîÇëÇóÃû³Æ |
| 93 | * @return at²éѯÇëÇó×Ö·û´®µÄÖ¸Õë |
| 94 | * @note ÓÉat_ctl¸ºÔðÊÍ·ÅÄÚ´æ |
| 95 | */ |
| 96 | char* at_query_build(char* cmd); |
| 97 | |
| 98 | |
| 99 | /** |
| 100 | * @brief Éú³Éat²éѯÇëÇóÃüÁîµÄÏìÓ¦ÃüÁµ±ÓÐÖмä½á¹ûÉϱ¨Ê±£¬ÔÚser_ops_t2µÄrsp_actµ÷Ó㬠|
| 101 | * ¸Ãº¯ÊýÖн«ÖмäÉϱ¨½á¹ûºÍokatÃüÁî×é×°ÔÚÒ»Æð£¬Í¨¹ýmallocÉêÇëʹÓõÄÄڴ棬²¢·µ»Ø |
| 102 | * ¸ÃÖ¸Õë¸øÍâ²ãµ÷Óú¯ÊýʹÓã¬×îÖÕÓÉÍâ²ãµ÷Óú¯ÊýÊͷŸÃÄÚ´æ |
| 103 | * @param cmd ATÃüÁîÏìÓ¦Ãû³Æ |
| 104 | * @param param ATÃüÁîÏìÓ¦²ÎÊý |
| 105 | * @return at¶¯×÷ÏìÓ¦×Ö·û´®µÄÖ¸Õë |
| 106 | * @note input: cmd "xx" |
| 107 | * param "yy,zz" |
| 108 | * output: \r\n+xx:yy,zz\r\n |
| 109 | */ |
| 110 | char* at_query_result_build(char* cmd, char* param); |
| 111 | |
| 112 | |
| 113 | |
| 114 | /** |
| 115 | * @brief Éú³ÉatÏìÓ¦½á¹ûOKº¯Êý |
| 116 | * @return atÏìÓ¦½á¹ûOK×Ö·û´®µÄÖ¸Õë |
| 117 | * @note ÓÉat_ctl¸ºÔðÊÍ·ÅÄÚ´æ |
| 118 | */ |
| 119 | char* at_ok_build(); |
| 120 | |
| 121 | |
| 122 | /** |
| 123 | * @brief atÃüÁî½âÎö |
| 124 | * @param fmt ÿ¸ö²ÎÊýÊä³öµÄÊý¾Ý¸ñʽ |
| 125 | * @param buf ÔʼÊý¾Ý |
| 126 | * @param pval Êä³ö¸ñʽ»¯ºóÊý¾ÝÖµ |
| 127 | * @return ¿ÉÒÔÕýÈ·½âÎö²ÎÊýµÄ¸öÊý |
| 128 | * @note ¸ñʽ½öÖ§³Ö%dºÍ%s,ͬʱ¿ÉÒÔÔÚÿ¸ö¸ñʽǰ¼ÓÉÏÊý×ÖÒÔÖ¸¶¨ |
| 129 | ±äÁ¿¿ÉÒÔ¸³ÖµµÄ¿Õ¼ä´óС£¬µ¥Î»Îª×Ö½Ú£¬ÀýÈç%2d±íʾ½ÓÊÜ´æ´¢¿Õ¼äΪ2×Ö½Ú£»%5s±íʾËãÉÏ'\0'£¬×î¶à¿ÉÒÔ |
| 130 | ½ÓÊÜ5¸ö×Ö·û¡£µ±%d²»Ö¸¶¨Êý×Öʱ£¬°´ÕÕ4×Ö½Ú½øÐи³Öµ£¬%sÔò°´ÕÕʵ¼Ê½âÎöµÄ×Ö·û´®³¤¶ÈÍêÈ«¸³Öµ£¬ÓпÉÄÜ |
| 131 | »áÓÐÔ½½ç¡£ |
| 132 | *ʾÀý |
| 133 | <pre> |
| 134 | char buf[]="1,2,\"test\""; |
| 135 | int n1 = 0; |
| 136 | int n2 = 0; |
| 137 | char *n3 = malloc(strlen(buf)); |
| 138 | char *p[] = {&n1,&n2,n3}; |
| 139 | ret = parse_param2("%d,%d,%s", buf, (void**)p); |
| 140 | //½âÎöºón1==1 n2==2 n3=="test" |
| 141 | ret = parse_param2("%4d,%d,%3s", buf, (void**)p); |
| 142 | //½âÎöºón1==1 n2==2 n3=="te" |
| 143 | retµÄֵΪ3 |
| 144 | </pre> |
| 145 | */ |
| 146 | int parse_param2(char *fmt, char *buf, void **pval); |
| 147 | |
| 148 | |
| 149 | /** |
| 150 | * @brief ATÃüÁî½âÎö½Ó¿Ú |
| 151 | * @param fmt ATÇëÇó»òÏìÓ¦µÄ¸ñʽ»¯·½Ê½ |
| 152 | * @param buf ATÇëÇó»òÏìÓ¦µÄ×Ö·û´®Ö¸Õë²»º¬Í·²¿ºÍ¿Õ¸ñ |
| 153 | * @param pval ¸ñʽ»¯ºóµÄATÃüÁî |
| 154 | * @return 0±íʾ½âÎö²ÎÊýÕý³££¬ÄÚ²¿½øÐÐÑϸñµÄ²ÎÊý¼ì²é£¬°üÀ¨²ÎÊý¸öÊýÒ»ÖÂÐÔ¼ì²é£¬¶ÔÓÚ¿ÉÑ¡²ÎÊý£¬ÐèÒªµ÷ÓÃÕß×ÔÐп¼ÂÇ |
| 155 | * @note |
| 156 | * 1. ½âÎöµÄATÃüÁî±ØÐë°´ÕÕ3GPP27007±ê×¼ÐÒ飬²ÎÊýÒÔ¶ººÅ¸ô¿ª£¬×Ö·û´®Ðè´øË«ÒýºÅ£¬·ñÔò»á¶ÏÑÔ |
| 157 | * 2. ×Ö·û´®½âÎöʱµÄÈë²Î³¤¶È±ØÐë´óÓÚ¿ÉÄܽâ³öµÄ×Ö·û´®³¤¶È£¬·ñÔò»áÔ½½ç |
| 158 | * 3. ·µ»ØÖµÇë²Î¿¼Ã¶¾Ùenum SAP_ERR£¬º¬¿ÉÑ¡²ÎÊýÒ»ÖÂÐÔ¼ì²é |
| 159 | * 4. ÈôfmtÖ¸¶¨µÄ²ÎÊýÀàÐͱØÐëÓëpvalÖÐÖ¸ÕëµÄÒ»Ò»¶ÔÓ¦ |
| 160 | * 5. ʾÀý |
| 161 | <pre> |
| 162 | char buf[]="1,2,\"test\""; |
| 163 | int n1 = 0; |
| 164 | int n2 = 0; |
| 165 | char *n3 = malloc(strlen(buf)); |
| 166 | char *p[] = {&n1,&n2,n3}; |
| 167 | ret = parse_param_safe("%d,%d,%s", buf, (void**)p); |
| 168 | //½âÎöºón1==1 n2==2 n3=="test" |
| 169 | ret = parse_param_safe("%4d,%d,%3s", buf, (void**)p); |
| 170 | //½âÎöºón1==1 n2==2 n3=="te" |
| 171 | </pre> |
| 172 | * @warning |
| 173 | */ |
| 174 | int parse_param_safe(char *fmt, char *buf, void **pval); |
| 175 | |
| 176 | |
| 177 | /** |
| 178 | * @brief Ó¦Ó÷¢ËͶ¯×÷Àà»ò²éѯÀàATÇëÇó¸ø3GPPÐÒéÕ»£¬²¢³¬Ê±µÈ´ý¶¯×÷½á¹û£»×¢Ò⣺¸Ã½Ó¿ÚÖ»ÄÜÓÃÓÚ²éѯºÍÉèÖúÍÖ´ÐÐÇëÇó£¬Í¨¹ýÈë²Î½øÐÐÖмä½á¹ûµÄÄÚ²¿½âÎö´¦Àí£¬²¢ÇÒ |
| 179 | ÓÐÖмä½á¹ûÉϱ¨Ê±£¬Ö»Ö§³ÖÒ»ÌõÖмä½á¹ûµÄÉϱ¨½âÎö£» |
| 180 | * @param req_at ÇëÇóATÃüÁ´óСдÃô¸Ð£¬±ØÐë´óд |
| 181 | * @param info_fmt ATÏìÓ¦µÄ¸ñʽ»¯·½Ê½ |
| 182 | * @param pval ¸ñʽ»¯ºóµÄATÏìÓ¦£¬¾ßÌåʹÓòο´parse_param½Ó¿Ú |
| 183 | * @param safe_parm_check ָʾÊÇ·ñ¶Ô²ÎÊý¸öÊý½øÐÐÒ»ÖÂÐÔ¼ì²é£¬0±íʾº¬¿ÉÑ¡²ÎÊý£¬²»¶Ô²ÎÊý¸öÊý½øÐмì²é;1±íʾ¶Ô²ÎÊý¸öÊý½øÐÐÑϸñ¼ì²é |
| 184 | * @param timeout timeout==0 ±íʾÓÀ¾ÃµÈ´ý½á¹ûÂ룬·ñÔòµÈ´ýʱ¼äΪ[timeout]Ãë |
| 185 | * @return 0±íʾ·µ»Ø³É¹¦£¬ÆäËûÖµ±íʾʧ°Ü´íÎóÂë |
| 186 | * @note |
| 187 | * 1. Óû§Ê¹ÓÃʱ£¬Èô²»ÏëÓɸýӿÚÄÚ²¿½øÐвÎÊýµÄ¸ñʽ»¯½âÎö£¬¿ÉÒÔ½«info_fmt¸³ÖµÎª"%s"£¬pval¸³ÖµÎªchar **p˫ָÕ룬ÕâÑù²ÎÊý½«×÷ΪÕûÌå×Ö·û´®·µ»Ø¸øµ÷ÓÃÕß |
| 188 | * 2. ¶ÔÓÚZMGL,CPBR, COPS=?µÈÒ»ÌõÇëÇó»áÓжàÌõÖмä½á¹ûÇé¿ö£¬¸Ãº¯Êý²»ÊÊÓà |
| 189 | * 3. ×Ö·û´®½âÎöʱµÄÈë²Î³¤¶È±ØÐë´óÓÚ¿ÉÄܽâ³öµÄ×Ö·û´®³¤¶È£¬·ñÔò»áÔ½½ç |
| 190 | * 4. µ±´æÔÚÖмäÉϱ¨Ê±£¬pvalºÍinfo_fmt²»Îª¿Õ£»µ±ÎªÖмäÉϱ¨Ê±£¬Á½¸ö±ØÐë½ÔΪ¿Õ |
| 191 | * 5. pvalºÍinfo_fmtÁ½ÕßҪô¶¼ÎªNULL,Ҫô¶¼²»ÎªNULL£¬²»ÄÜ´æÔÚÆäÖÐÒ»¸öΪNULL£¬ÁíÒ»¸ö²»ÎªNULLµÄÇé¿ö |
| 192 | * 6. ʾÀý |
| 193 | <pre> |
| 194 | int ret = 0; |
| 195 | ret = get_modem_info2("AT+CFUN=1\r", NULL, NULL); |
| 196 | //·µ»Ø¼´±íʾִÐгɹ¦ |
| 197 | |
| 198 | char *pstr = malloc(50); |
| 199 | memset(pstr,0,50); |
| 200 | ret = get_modem_info2("AT+CIMI\r", "%s", (void**)&pstr,0,10); |
| 201 | //·µ»Øºópstr==111111111111111 |
| 202 | |
| 203 | int n1 = 0; |
| 204 | int n2 = 0; |
| 205 | int n3 = 0; |
| 206 | char *p2[] = {&n1,&n2,&n3}; |
| 207 | ret = get_modem_info2("AT+CCIOTOPT?\r", "%d,%d,%d", (void**)p2,0,10); |
| 208 | //+CCIOTOPT: 1,2,3½âÎöºón1==1 n2==2 n3==3 |
| 209 | </pre> |
| 210 | * @warning |
| 211 | */ |
| 212 | int get_modem_info2(char *req_at,char *info_fmt,void **pval, int safe_parm_check, int timeout); |
| 213 | |
| 214 | |
| 215 | /** |
| 216 | * @brief ÓÃÓÚ¿ª»ú×¢²áËùÓеķþÎñ¶Ë¾ßÌåATÃüÁîʼþ£¬³£ÓÃÓÚÉϲ㼰¿Í»§¶¨ÖÆ£¬²»×¼ÓÃÓÚPSÐÒéÕ»¡£ |
| 217 | * @param at_cmd_prefix ATÃüÁîǰ׺ָÕë |
| 218 | * @param module_id Ô´Ä£¿é¶ÓÁÐid |
| 219 | * @param req_msg_id ÇëÇóÏûÏ¢id |
| 220 | * @param rsp_msg_id ÏìÓ¦ÏûÏ¢id |
| 221 | * @param req_rcv_act ÊÕµ½ÇëÇóÏûϢʱµÄ´¦Àíº¯Êý |
| 222 | * @param rsp_act ÊÕµ½ÏìÓ¦½á¹ûʱµÄ´¦Àíº¯Êý |
| 223 | * @return intÐͽá¹ûÂë |
| 224 | * @retval ³É¹¦ 0 |
| 225 | * @note ¿É²Î¿¼Ê¾Àý´úÂë: user_regist.c |
| 226 | */ |
| 227 | int register_serv_func2(char *at_cmd_prefix, int module_id, int req_msg_id, int rsp_msg_id, ser_req_func2 req_rcv_act, app_rsp_proc rsp_act); |
| 228 | |
| 229 | /** |
| 230 | * @brief ×¢²áÉϱ¨ATÃüÁîµÄ¸ñʽ»¯´¦Àíº¯Êý£¬ÍⲿMCU·¢ËÍATÃüÁmodem·µ»ØµÄÖмä½á¹û²»Âú×ãÍⲿMCUµÄ¸ñʽҪÇó£¬ |
| 231 | ÐèÒªat_ctl½øÐÐת»» |
| 232 | * @param at_cmd_prefix ATÃüÁîǰ׺ָÕë |
| 233 | * @param inform_act ½ÓÊÕµ½ATÃüÁîÖмä½á¹ûµÄת»»´¦Àíº¯Êý |
| 234 | * @return intÐͽá¹ûÂë |
| 235 | * @retval ³É¹¦ 0 |
| 236 | * @note |
| 237 | */ |
| 238 | int register_formatInform_func(char *at_cmd_prefix, format_inform_func inform_act); |
| 239 | |
| 240 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 241 | /** |
| 242 | * @brief ¿É´òÓ¡×Ö·û´®×ª»»Îª×Ö½ÚÊý¾Ý £¬È磺 |
| 243 | "C8329BFD0E01" --> {0xC8, 0x32, 0x9B, 0xFD, 0x0E, 0x01} |
| 244 | * @param pSrc Ô´×Ö·û´®Ö¸Õë |
| 245 | * @param pDst Ä¿±êÊý¾ÝÖ¸Õë |
| 246 | * @param nSrcLength Ô´×Ö·û´®³¤¶È |
| 247 | * @return Ä¿±êÊý¾Ý³¤¶È |
| 248 | * @note |
| 249 | * @warning |
| 250 | */ |
| 251 | int string2bytes(const char* pSrc, unsigned char* pDst, int nSrcLength); |
| 252 | /** |
| 253 | * @brief ×Ö½ÚÊý¾Ýת»»Îª¿É´òÓ¡×Ö·û´® £¬È磺 |
| 254 | {0xC8, 0x32, 0x9B, 0xFD, 0x0E, 0x01} --> "C8329BFD0E01" |
| 255 | * @param pSrc Ô´Êý¾ÝÖ¸Õë |
| 256 | * @param pDst Ä¿±ê×Ö·û´®Ö¸Õë |
| 257 | * @param nSrcLength Ô´Êý¾Ý³¤¶È |
| 258 | * @return Ä¿±êÊý¾Ý³¤¶È£» |
| 259 | * @note |
| 260 | * @warning |
| 261 | */ |
| 262 | int bytes2string(const unsigned char* pSrc, char* pDst, int nSrcLength); |
| 263 | |
| 264 | |
| 265 | |
| 266 | /** |
| 267 | * @brief ÔÚºöÂÔ´óСдµÄÇé¿öÏ£¬±È½ÏÁ½¸öat×Ö·û´®ÊÇ·ñÏàͬ |
| 268 | * @param dest Ä¿±ê×Ö·û´® |
| 269 | * @param source Ô´×Ö·û´® |
| 270 | * @return 0±íʾÁ½×Ö·û´®ÍêÈ«Ïàͬ£¬Èç¹ûµÚÒ»¸öÈë²Î´óÓÚµÚ¶þ¸öÈë²Î£¬·µ»ØÕýÖµ£¬·ñÔò·µ»Ø¸ºÖµ£» |
| 271 | * @note |
| 272 | * @warning |
| 273 | */ |
| 274 | int at_strcmp(const char *dest, const char *source); |
| 275 | |
| 276 | |
| 277 | /** |
| 278 | * @brief ÔÚºöÂÔ´óСдµÄÇé¿öÏ£¬±È½ÏÁ½¸öat×Ö·û´®Ç°size³¤¶ÈÊÇ·ñÏàͬ |
| 279 | * @param dest Ä¿±ê×Ö·û´® |
| 280 | * @param source Ô´×Ö·û´® |
| 281 | * @param size ±È½ÏµÄ×Ö½ÚÊý |
| 282 | * @return 0±íʾÁ½×Ö·û´®Ç°size³¤¶ÈÍêÈ«Ïàͬ£¬Èç¹ûµÚÒ»¸öÈë²Î´óÓÚµÚ¶þ¸öÈë²Î£¬·µ»ØÕýÖµ£¬·ñÔò·µ»Ø¸ºÖµ£» |
| 283 | * @note |
| 284 | * @warning |
| 285 | */ |
| 286 | int at_strncmp(const char *dest, const char *source, int size); |
| 287 | |
| 288 | /** |
| 289 | * @brief ÔÚºöÂÔ´óСдµÄÇé¿öÏ£¬ÔÚsourceÖÐѰÕÒsubstr×Ó´®µÄλÖà |
| 290 | * @param dest Ä¿±ê×Ö·û´® |
| 291 | * @param source Ô´×Ö·û´® |
| 292 | * @return Èç¹ûÕÒµ½£¬Ö±½Ó·µ»ØsubstrÔÚsourceÖеÚÒ»´Î³öÏÖµÄλÖã¬Èç¹ûûÓÐÕÒµ½£¬·µ»ØNULL |
| 293 | * @note |
| 294 | * @warning |
| 295 | */ |
| 296 | char * at_strstr(const char * source, const char * substr); |
| 297 | |
| 298 | |
| 299 | //ÓÃÓÚ¼ÆËãÀÛ¼ÓµÄCHECKSUMÖµ |
| 300 | unsigned short get_chksum(const unsigned char *ptr, unsigned short len); |
| 301 | #endif |
| 302 | |
| 303 | #endif |
| 304 | |