{"id":2405,"date":"2022-02-23T21:03:06","date_gmt":"2022-02-23T13:03:06","guid":{"rendered":"http:\/\/www.tinywsn.net\/wordpress\/?post_type=docs&#038;p=2405"},"modified":"2022-02-25T13:03:59","modified_gmt":"2022-02-25T05:03:59","slug":"template","status":"publish","type":"docs","link":"http:\/\/www.tinywsn.net\/wordpress\/index.php\/docs\/manual\/node\/node-wbed\/template\/","title":{"rendered":"\u7528\u6237\u7a0b\u5e8f"},"content":{"rendered":"\n<div class=\"wp-block-columns alignwide\">\n<div class=\"wp-block-column\" style=\"flex-basis:66.66%\">\n<p>\u5728\u5185\u5d4c\u6a21\u5f0f\u4e2d\uff0c\u7528\u6237\u7a0b\u5e8f\u548c\u7cfb\u7edf\u7a0b\u5e8f\u8fd0\u884c\u5728\u540c\u4e00\u5904\u7406\u5668\u4e0a\uff0c\u4f46\u662f\u5b83\u662f\u72ec\u7acb\u7f16\u8bd1\u548c\u94fe\u63a5\u7684\uff0c\u53ef\u4ee5\u52a8\u6001\u4e0b\u8f7d\u5230\u8282\u70b9\u6a21\u5757\uff0c\u6269\u5145\u8282\u70b9\u529f\u80fd\uff0c\u7528\u6765\u63a7\u5236\u5916\u63a5\u5916\u63a5\u5404\u7c7b\u4f20\u611f\u5668\uff0c\u662f\u5bf9\u8282\u70b9\u6a21\u5757\u7684\u4e8c\u6b21\u5f00\u53d1\uff0c\u8fd9\u6837\u4e0d\u4f46\u53ef\u4ee5\u8282\u7701\u4e00\u4e2a\u5916\u90e8\u5904\u7406\u5668\u3002\u800c\u4e14\u7528\u6237\u7a0b\u5e8f\u53ea\u9700\u5173\u6ce8\u65b0\u589e\u63a5\u53e3\u548c\u8bbe\u5907\uff0c\u8fd9\u6837\u5c31\u6bd4\u8f83\u5bb9\u6613\u8fbe\u5230\u603b\u4f53\u529f\u8017\u8981\u6c42\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"480\" height=\"450\" src=\"http:\/\/www.tinywsn.net\/wordpress\/wp-content\/uploads\/2022\/01\/wipc-mmap.jpg\" alt=\"\" class=\"wp-image-2105\" srcset=\"http:\/\/www.tinywsn.net\/wordpress\/wp-content\/uploads\/2022\/01\/wipc-mmap.jpg 480w, http:\/\/www.tinywsn.net\/wordpress\/wp-content\/uploads\/2022\/01\/wipc-mmap-300x281.jpg 300w\" sizes=\"(max-width: 480px) 100vw, 480px\" \/><\/figure>\n\n\n\n<p>\u7528\u6237\u7a0b\u5e8f\u7684\u57fa\u672c\u539f\u7406\u548c\u6ce8\u610f\u4e8b\u9879\u53ef\u4ee5\u53c2\u89c1\u4e0b\u9762\u94fe\u63a5\uff1a<br><a href=\"http:\/\/www.tinywsn.net\/wordpress\/index.php\/docs\/manual\/node\/node-wbed\/\">http:\/\/www.tinywsn.net\/wordpress\/index.php\/docs\/manual\/node\/node-wbed\/<\/a><\/p>\n\n\n\n<p>\u4e0b\u9762\u7684\u8fde\u63a5\u662f\u7528\u6237\u7a0b\u5e8f\u5f00\u53d1\u5305SDK\uff0c\u5305\u542b\u4e86\u8bb8\u591a\u7684\u4f8b\u7a0b\u4ee5\u53ca\u5404\u7c7b\u4f20\u611f\u5668\u603b\u7ebf\u7684\u9a71\u52a8\uff1a<br><a href=\"https:\/\/gitee.com\/tinywsn\/fw-stm32l1-wbed-usr\">https:\/\/gitee.com\/tinywsn\/fw-stm32l1-wbed-usr<\/a><\/p>\n\n\n\n<p>\u4f20\u611f\u5668\u901a\u8fc7\u6269\u5c55\u677f\uff0c\u5b89\u88c5\u5728\u8282\u70b9\u6a21\u5757\u4e0a\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u7528\u6237\u7a0b\u5e8f\u7528\u914d\u7f6e\u8f6f\u4ef6TinyCFG\u4e0b\u8f7d\u5230\u6a21\u5757\u5185\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"480\" height=\"640\" src=\"http:\/\/www.tinywsn.net\/wordpress\/wp-content\/uploads\/2022\/02\/extb-ds18b20.jpg\" alt=\"\" class=\"wp-image-2453\" srcset=\"http:\/\/www.tinywsn.net\/wordpress\/wp-content\/uploads\/2022\/02\/extb-ds18b20.jpg 480w, http:\/\/www.tinywsn.net\/wordpress\/wp-content\/uploads\/2022\/02\/extb-ds18b20-225x300.jpg 225w\" sizes=\"(max-width: 480px) 100vw, 480px\" \/><\/figure>\n\n\n\n<h2>\u8f6f\u4ef6\u7ed3\u6784<\/h2>\n\n\n\n<p>\u7528\u6237\u7a0b\u5e8f\u548c\u7cfb\u7edf\u7a0b\u5e8f\u901a\u8fc7\u6d88\u606f\u8fdb\u884c\u4ea4\u4e92\uff0c\u4e3a\u4e86\u63d0\u9ad8\u7cfb\u7edf\u7684\u54cd\u5e94\u6548\u7387\uff0c\u7528\u6237\u7a0b\u5e8f\u91c7\u7528\u7684\u4e8b\u4ef6\u9a71\u52a8\u7684\u72b6\u6001\u673a\u6a21\u578b\uff0c\u5176\u4e2d\u6d88\u606f\u7684\u6765\u6e90\u4e3b\u8981\u6709\u4e09\u7c7b\uff0c\u7528\u6237\u7a0b\u5e8f\u53ea\u9700\u5bf9\u63a5\u6536\u6d88\u606f\u8fdb\u884c\u54cd\u5e94\uff1a<\/p>\n\n\n\n<ul><li>\u7cfb\u7edf\u7a0b\u5e8f\u4ea7\u751f\u7684\u6d88\u606f<\/li><li>\u4e2d\u65ad\u7a0b\u5e8f\u4ea7\u751f\u7684\u6d88\u606f<\/li><li>\u7528\u6237\u7a0b\u5e8f\u81ea\u5df1\u7684\u6d88\u606f<\/li><\/ul>\n\n\n\n<p>\u4e3a\u4e86\u66f4\u597d\u7684\u914d\u548c\u7cfb\u7edf\u7a0b\u5e8f\uff0c\u4e0b\u56fe\u5c31\u662f\u76ee\u63a8\u8350\u91c7\u7528\u7684\u7684\u72b6\u6001\u8f6c\u6362\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"514\" height=\"385\" src=\"http:\/\/www.tinywsn.net\/wordpress\/wp-content\/uploads\/2022\/02\/wbed-exam-state.jpg\" alt=\"\" class=\"wp-image-2408\" srcset=\"http:\/\/www.tinywsn.net\/wordpress\/wp-content\/uploads\/2022\/02\/wbed-exam-state.jpg 514w, http:\/\/www.tinywsn.net\/wordpress\/wp-content\/uploads\/2022\/02\/wbed-exam-state-300x225.jpg 300w\" sizes=\"(max-width: 514px) 100vw, 514px\" \/><\/figure>\n\n\n\n<p>\u4ece\u56fe\u4e2d\u53ef\u4ee5\u770b\u51fa\u5171\u67095\u4e2a\u72b6\u6001\uff0c\u5176\u4e2ddef(\u9ed8\u8ba4\u6d88\u606f\u5904\u7406\u72b6\u6001)\u662f\u540e\u53f0\u72b6\u6001\uff0c\u4e00\u76f4\u5b58\u5728\uff0c\u5176\u4ed6\u90fd\u662f\u524d\u53f0\u72b6\u6001\uff0c\u53ea\u6709\u4e00\u4e2a\u662f\u5f53\u524d\u6fc0\u6d3b\u7684\u72b6\u6001\uff0c\u5b83\u4eec\u4e4b\u95f4\u6839\u636e\u63a5\u53d7\u7684\u6d88\u606f\u8fdb\u884c\u5207\u6362\uff0c\u4e0b\u8868\u5bf9\u5404\u4e2a\u72b6\u6001\u5206\u522b\u8fdb\u884c\u8bf4\u660e<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-regular\"><table><thead><tr><th>\u7b26\u53f7<\/th><th>\u540d\u79f0<\/th><th>\u8bf4\u660e<\/th><\/tr><\/thead><tbody><tr><td>init<\/td><td>\u521d\u59cb\u72b6\u6001<\/td><td>\u7cfb\u7edf\u4e0a\u7535\u8fdb\u5165\u7684\u72b6\u6001\uff0c\u8fdb\u884c\u7a0b\u5e8f\u548c\u8bbe\u5907\u7684\u521d\u59cb\u5316<\/td><\/tr><tr><td>disc<\/td><td>\u65ad\u94fe\u72b6\u6001<\/td><td>\u5f53\u65e0\u7ebf\u65ad\u94fe\u8fdb\u5165\u7684\u72b6\u6001\uff0c\u5173\u95ed\u8bbe\u5907\u8fdb\u5165\u4f4e\u529f\u8017\u6a21\u5f0f<\/td><\/tr><tr><td>conn<\/td><td>\u8fde\u63a5\u72b6\u6001<\/td><td>\u5904\u7406\u5404\u7c7b\u7cfb\u7edf\u6d88\u606f\uff0c\u53d1\u9001\u6d4b\u91cf\u7ed3\u679c\uff0c\u5f53\u8f6c\u6362\u5b9a\u65f6\u5668<br>\u89e6\u53d1\u65f6\uff0c\u8fdb\u5165\u8f6c\u6362\u72b6\u6001<\/td><\/tr><tr><td>conv<\/td><td>\u8f6c\u6362\u72b6\u6001<\/td><td>\u542f\u52a8\u4f20\u611f\u5668\u8f6c\u6362\uff0c\u7ed3\u675f\u540e\u5173\u95ed\u4f20\u611f\u5668\uff0c\u8fd4\u56de\u8fde\u63a5\u72b6\u6001<\/td><\/tr><tr><td>def<\/td><td>\u9ed8\u8ba4\u72b6\u6001<\/td><td>\u9ed8\u8ba4\u6d88\u606f\u5904\u7406\u72b6\u6001\uff0c\u672a\u5904\u7406\u7684\u6d88\u606f\u90fd\u8fdb\u5165\u8fd9\u4e2a\u72b6\u6001<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2>\u521d\u59cb\u72b6\u6001<\/h2>\n\n\n\n<figure class=\"wp-block-table is-style-regular\"><table class=\"has-fixed-layout\"><thead><tr><th>\u6d88\u606f<\/th><th>\u52a8\u4f5c<\/th><th>\u8df3\u8f6c<\/th><\/tr><\/thead><tbody><tr><td>WIPC_MSG_FSM_INIT<\/td><td>\u8fdb\u5165\u72b6\u6001\u673a\u521d\u59cb\u5316\u6d88\u606f\uff0c\u5f00\u59cb\u8bbe\u5907\u521d\u59cb\u5316\uff0c\u5f00\u542f\u4e00\u4e2a\u540c\u6b65\u5b9a\u65f6\u5668\uff0c\u4ee5\u4fbf\u63d0\u524d\u4e00\u4e2a\u65f6\u9699\u5524\u9192\uff0c\u5b8c\u6210\u4f20\u611f\u5668\u6d4b\u91cf<\/td><td>\u8fde\u63a5\u72b6\u6001\uff08\u5982\u679c\u5728\u7ebf\uff09<br>\u65ad\u94fe\u72b6\u6001\uff08\u5982\u679c\u65ad\u94fe\uff09<\/td><\/tr><\/tbody><\/table><figcaption> \u53c2\u89c1fw-stm32l1-wbed-usr\/apps\/ds18b20\/s_init.c<\/figcaption><\/figure>\n\n\n\n<pre id=\"block-10a0e52d-6d4f-4d90-8e30-a4faeaa8ef50\" class=\"wp-block-preformatted\">\/\/ \u521d\u59cb\u72b6\u6001\u673a\u6d88\u606f\u5904\u7406\u5165\u53e3\nwipc_result_t init_msg_proc(uint8_t msg, void *in, void *out, ctx_t *ctx)\n{\n&nbsp; wipc_msg_tmr_init_t tmr_init;\n&nbsp; \n&nbsp; switch(msg){\n&nbsp; case WIPC_MSG_FSM_INIT:\n&nbsp; &nbsp; \/\/ \u521d\u59cb\u5316NVM\u5185\u5b58\n&nbsp; &nbsp; net_msg_send(WIPC_MSG_NVM_LOAD, 0, &amp;((ctx_t*)ctx)-&gt;nvm, ctx);\n&nbsp; &nbsp; \/\/ \u521d\u59cb\u5316\u8bbe\u5907\n&nbsp; &nbsp; pwr_init(true);\n&nbsp; &nbsp; led_init(((ctx_t*)ctx)-&gt;nvm.led);\n      \/\/ \u5f00\u542f\u4e00\u540c\u6b65\u5b9a\u65f6\u5668\n&nbsp; &nbsp; tmr_init.type = WIPC_TMR_SYNC;\n      \/\/ \u63d0\u524d\u4e00\u4e2a\u65f6\u9699\u5524\u9192\n&nbsp; &nbsp; tmr_init.arg.oft = -1;\n&nbsp; &nbsp; net_msg_send(WIPC_MSG_TMR_INIT, &amp;tmr_init, 0, 0);\n      \/\/ \u521d\u59cb\u5316\u4f20\u611f\u5668\n&nbsp; &nbsp; ds18b20_init(&amp;ctx-&gt;ds18b20);\n&nbsp; &nbsp; \/\/ \u6839\u636e\u5f53\u524d\u7f51\u7edc\u72b6\u6001\uff0c\n      \/\/ \u5207\u6362\u5230\u4e0d\u540c\u72b6\u6001\u673a\n&nbsp; &nbsp; if(((wipc_msg_sys_init_t*)in)-&gt;stat &amp; WIPC_S_CONN){\n&nbsp; &nbsp; &nbsp; fsm_goto(conn_msg_proc, ctx);\n&nbsp; &nbsp; }else{\n&nbsp; &nbsp; &nbsp; fsm_goto(disc_msg_proc, ctx);\n&nbsp; &nbsp; }\n&nbsp; &nbsp; return WIPC_RES_SUCC;\n&nbsp; case WIPC_MSG_FSM_EXIT: \n&nbsp; &nbsp; return WIPC_RES_SUCC;\n&nbsp; default:\n&nbsp; &nbsp; return WIPC_RES_CONT; \n&nbsp; } \n}<\/pre>\n\n\n\n<h2>\u8fde\u63a5\u72b6\u6001<\/h2>\n\n\n\n<figure class=\"wp-block-table is-style-regular\"><table class=\"has-fixed-layout\"><thead><tr><th>\u6d88\u606f<\/th><th>\u52a8\u4f5c<\/th><th>\u8df3\u8f6c<\/th><\/tr><\/thead><tbody><tr><td>WIPC_MSG_TMR_TICK<\/td><td>\u540c\u6b65\u5b9a\u65f6\u5668\u89e6\u53d1\u6d88\u606f\uff0c\u8df3\u8f6c\u5230\u8f6c\u6362\u72b6\u6001\uff0c\u5f00\u542f\u4f20\u611f\u5668\u6d4b\u91cf<\/td><td>\u8f6c\u6362\u72b6\u6001<\/td><\/tr><tr><td>WIPC_MSG_NTS_INIT<\/td><td>\u8282\u70b9\u65f6\u9699\u5f00\u59cb\u6d88\u606f\uff0c\u68c0\u67e5\u4f20\u611f\u5668\u6d4b\u91cf\u7ed3\u679c\uff0c\u53d1\u9001\u6570\u636e<\/td><td><\/td><\/tr><\/tbody><\/table><figcaption>\u53c2\u89c1fw-stm32l1-wbed-usr\/apps\/ds18b20\/s_conn.c<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ \u8fde\u63a5\u72b6\u6001\u673a\u6d88\u606f\u5904\u7406\u5165\u53e3\nwipc_result_t conn_msg_proc(uint8_t msg, void *in, void *out, ctx_t *ctx)\n{\n&nbsp; switch(msg){\n&nbsp; case WIPC_MSG_FSM_INIT:\n&nbsp; &nbsp; return WIPC_RES_SUCC;\n&nbsp; case WIPC_MSG_FSM_EXIT: \n&nbsp; &nbsp; return WIPC_RES_SUCC;\n&nbsp; case WIPC_MSG_TMR_TICK:\n&nbsp; &nbsp; &nbsp;\/\/ \u68c0\u67e5\u5b9a\u65f6\u5668\u7684\u7c7b\u522b\n&nbsp; &nbsp; if(((wipc_msg_tmr_tick_t*)in)-&gt;type == WIPC_TMR_SYNC){\n&nbsp; &nbsp; &nbsp; &nbsp;\/\/ \u8df3\u8f6c\u5230\u8f6c\u6362\u72b6\u6001\n&nbsp; &nbsp; &nbsp; fsm_goto(conv_msg_proc, ctx);\n&nbsp; &nbsp; &nbsp; return WIPC_RES_SUCC;\n&nbsp; &nbsp; }\n&nbsp; &nbsp; return WIPC_RES_SUCC; \n&nbsp; case WIPC_MSG_NTS_INIT:\n&nbsp; &nbsp; \/\/ \u68c0\u67e5\u8f6c\u6362\u7684\u7ed3\u679c\n&nbsp; &nbsp; if(ctx-&gt;flag &amp; CTX_F_DONE){\n&nbsp; &nbsp; &nbsp; uint8_t *q = CTX_USR_BUF(ctx);\n&nbsp; &nbsp; &nbsp; stringf((char*)q, \"val,t,%.1fC\", ctx-&gt;t);\n         \/\/ \u53d1\u9001\u6d4b\u91cf\u6570\u636e\n&nbsp; &nbsp; &nbsp; tx_usr_data(q, strlen((char*)q), TX_F_NONE, ctx);\n&nbsp; &nbsp; &nbsp; ctx-&gt;flag &amp;=~CTX_F_DONE;\n&nbsp; &nbsp; &nbsp; return WIPC_RES_SUCC;\n&nbsp; &nbsp; } &nbsp; &nbsp;\n&nbsp; &nbsp; return WIPC_RES_FAIL;\n&nbsp; default:\n&nbsp; &nbsp; return WIPC_RES_CONT; \n&nbsp; } \n}<\/pre>\n\n\n\n<h2>\u8f6c\u6362\u72b6\u6001<\/h2>\n\n\n\n<figure class=\"wp-block-table is-style-regular\"><table class=\"has-fixed-layout\"><thead><tr><th>\u6d88\u606f<\/th><th>\u52a8\u4f5c<\/th><th>\u8df3\u8f6c<\/th><\/tr><\/thead><tbody><tr><td>WIPC_MSG_FSM_INIT<\/td><td>\u8fdb\u5165\u72b6\u6001\u673a\u521d\u59cb\u5316\u6d88\u606f\uff0c \u91cd\u65b0\u521d\u59cb\u5316\u5904\u4e8e\u4f4e\u529f\u8017\u6a21\u5f0f\u7684\u8bbe\u5907\uff0c\u6253\u5f00\u4f20\u611f\u5668\u7684\u7535\u6e90\uff0c\u7b49\u5f85\u4e0a\u7535\u7a33\u5b9a<\/td><td><\/td><\/tr><tr><td>WIPC_MSG_WAIT_DONE<\/td><td>\u4e0a\u7535\u7a33\u5b9a\u5b8c\u6210\uff0c\u542f\u52a8\u4f20\u611f\u5668\u7684\u8f6c\u6362<\/td><td><\/td><\/tr><tr><td>WIPC_MSG_CONV_DONE<\/td><td>\u4f20\u611f\u5668\u8f6c\u6362\u7ed3\u675f\uff0c\u83b7\u53d6\u6d4b\u91cf\u6570\u636e<\/td><td>\u8fde\u63a5\u72b6\u6001<\/td><\/tr><tr><td>WIPC_MSG_WAIT_TMRO<\/td><td>\u4f20\u611f\u5668\u8f6c\u6362\u5931\u8d25\uff0c\u8df3\u8f6c\u56de\u539f\u6765\u72b6\u6001<\/td><td>\u8fde\u63a5\u72b6\u6001<\/td><\/tr><tr><td>WIPC_MSG_FSM_EXIT<\/td><td>\u9000\u51fa\u72b6\u6001\u673a\u6790\u6784\u5316\u6d88\u606f\uff0c \u5173\u95ed\u8bbe\u5907\u4f7f\u5f97\u5b83\u4eec\u8fdb\u5165\u4f4e\u529f\u8017\u6a21\uff0c\u5173\u95ed\u4f20\u611f\u5668\u7535\u6e90<\/td><td><\/td><\/tr><\/tbody><\/table><figcaption>\u53c2\u89c1fw-stm32l1-wbed-usr\/apps\/ds18b20\/s_conv.c<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ \u8f6c\u6362\u72b6\u6001\u673a\u6d88\u606f\u5904\u7406\u5165\u53e3\nwipc_result_t conv_msg_proc(uint8_t msg, void *in, void *out, ctx_t *ctx)\n{\n&nbsp; switch(msg){\n&nbsp; case WIPC_MSG_FSM_INIT:\n&nbsp; &nbsp; \/\/ \u6253\u5f00\u7535\u6e90\uff0c\u91cd\u65b0\u521d\u59cb\u5316\u8bbe\u5907\n&nbsp; &nbsp; pwr_reinit(true);\n&nbsp; &nbsp; led_reinit(ctx-&gt;nvm.led);\n&nbsp; &nbsp; ds18b20_reinit(&amp;ctx-&gt;ds18b20);\n&nbsp; &nbsp; \/\/ \u7b49\u5f85\u4f20\u611f\u5668\u7535\u6e90\u7a33\u5b9a\n&nbsp; &nbsp; dev_wait_msec(&amp;ctx-&gt;ds18b20.wait, DS18B20_PWRON_MSEC, ctx);\n&nbsp; &nbsp; return WIPC_RES_SUCC;\n&nbsp; case WIPC_MSG_FSM_EXIT: \n&nbsp; &nbsp; \/\/ \u505c\u6b62\u7cfb\u7edf\u65f6\u949f\u8282\u62cd\n&nbsp; &nbsp; drv_wait_halt(&amp;ctx-&gt;ds18b20.wait);\n&nbsp; &nbsp; \/\/ \u5173\u95ed\u7535\u6e90\u548c\u8bbe\u5907\n&nbsp; &nbsp; ds18b20_deinit(&amp;ctx-&gt;ds18b20);\n&nbsp; &nbsp; led_deinit();\n&nbsp; &nbsp; pwr_deinit();\n&nbsp; &nbsp; return WIPC_RES_SUCC;\n&nbsp; case WIPC_MSG_LPM_REQ:\n&nbsp; &nbsp; \/\/ \u963b\u6b62\u7cfb\u7edf\u8fdb\u5165\u4f4e\u529f\u8017\u6a21\u5f0f&nbsp;\n&nbsp; &nbsp; return WIPC_RES_FAIL;\n&nbsp; case WIPC_MSG_SYS_TICK:\n&nbsp; &nbsp; \/\/ msec tick\n&nbsp; &nbsp; drv_msec_tick(&amp;ctx-&gt;ds18b20.wait, &amp;ctx-&gt;ds18b20);\n&nbsp; &nbsp; return WIPC_RES_SUCC;\n&nbsp; case WIPC_MSG_WAIT_TMRO:\n&nbsp; &nbsp; \/\/ \u4f20\u611f\u5668\u8f6c\u6362\u5931\u8d25\n&nbsp; &nbsp; fsm_goto(conn_msg_proc, ctx);\n&nbsp; &nbsp; return WIPC_RES_SUCC; &nbsp;\n&nbsp; case WIPC_MSG_WAIT_DONE:\n      \/\/ \u91cd\u7f6e\u4e00\u4e0b\u4f20\u611f\u5668\n&nbsp; &nbsp; ds18b20_reset(&amp;ctx-&gt;ds18b20);\n&nbsp; &nbsp; \/\/ \u542f\u52a8\u4f20\u611f\u5668\u7684\u8f6c\u6362\n&nbsp; &nbsp; if(!ds18b20_conv(&amp;ctx-&gt;ds18b20)){\n&nbsp; &nbsp; &nbsp; fsm_goto(conn_msg_proc, ctx);\n&nbsp; &nbsp; &nbsp; return WIPC_RES_FAIL;\n&nbsp; &nbsp; }\n&nbsp; &nbsp; return WIPC_RES_SUCC;\n&nbsp; case WIPC_MSG_CONV_DONE:\n&nbsp; &nbsp; \/\/ \u4f20\u611f\u5668\u8f6c\u6362\u7ed3\u675f\n&nbsp; &nbsp; if(ds18b20_get(&amp;ctx-&gt;ds18b20, &amp;ctx-&gt;t)){\n&nbsp; &nbsp; &nbsp; ctx-&gt;flag |= CTX_F_DONE;\n&nbsp; &nbsp; }\n&nbsp; &nbsp; \/\/ goto conn\n&nbsp; &nbsp; fsm_goto(conn_msg_proc, ctx); &nbsp;\n&nbsp; &nbsp; return WIPC_RES_SUCC;\n&nbsp; default:\n&nbsp; &nbsp; return WIPC_RES_CONT; \n&nbsp; } \n}<\/pre>\n\n\n\n<h2>\u65ad\u94fe\u72b6\u6001<\/h2>\n\n\n\n<figure class=\"wp-block-table is-style-regular\"><table class=\"has-fixed-layout\"><thead><tr><th>\u6d88\u606f<\/th><th>\u52a8\u4f5c<\/th><th>\u8df3\u8f6c<\/th><\/tr><\/thead><tbody><tr><td>WIPC_MSG_FSM_INIT<\/td><td>\u8fdb\u5165\u72b6\u6001\u673a\u521d\u59cb\u5316\u6d88\u606f\uff0c \u5173\u95ed\u8bbe\u5907\u4f7f\u5f97\u5b83\u4eec\u8fdb\u5165\u4f4e\u529f\u8017\u6a21\uff0c\u5173\u95ed\u4f20\u611f\u5668\u7535\u6e90<\/td><td><\/td><\/tr><\/tbody><\/table><figcaption>\u53c2\u89c1fw-stm32l1-wbed-usr\/apps\/ds18b20\/s_disc.c<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ \u65ad\u94fe\u72b6\u6001\u6d88\u606f\u5904\u7406\u5165\u53e3\nwipc_result_t disc_msg_proc(uint8_t msg, void *in, void *out, ctx_t *ctx)\n{\n&nbsp; switch(msg){\n&nbsp; case WIPC_MSG_FSM_INIT:\n&nbsp; &nbsp; \/\/ \u505c\u6b62\u7cfb\u7edf\u65f6\u949f\u8282\u62cd\n&nbsp; &nbsp; drv_wait_halt(&amp;ctx-&gt;ds18b20.wait);\n&nbsp; &nbsp; \/\/ \u5173\u95ed\u7535\u6e90\u548c\u8bbe\u5907\n&nbsp; &nbsp; ds18b20_deinit(&amp;ctx-&gt;ds18b20);\n&nbsp; &nbsp; led_deinit();\n&nbsp; &nbsp; pwr_deinit();\n&nbsp; &nbsp; return WIPC_RES_SUCC;\n&nbsp; case WIPC_MSG_FSM_EXIT: \n&nbsp; &nbsp; return WIPC_RES_SUCC;\n&nbsp; default:\n&nbsp; &nbsp; return WIPC_RES_CONT; \n&nbsp; } \n}<\/pre>\n\n\n\n<h2>\u9ed8\u8ba4\u72b6\u6001<\/h2>\n\n\n\n<figure class=\"wp-block-table is-style-regular\"><table class=\"has-fixed-layout\"><thead><tr><th>\u6d88\u606f<\/th><th>\u52a8\u4f5c<\/th><th>\u8df3\u8f6c<\/th><\/tr><\/thead><tbody><tr><td>WIPC_MSG_NET_CONN<\/td><td>\u63a5\u53d7\u5230\u7f51\u7edc\u8fde\u63a5\u6d88\u606f\uff0c\u5207\u6362\u5230\u8fde\u63a5\u72b6\u6001<\/td><td><\/td><\/tr><tr><td>WIPC_MSG_NET_DISC<\/td><td>\u63a5\u53d7\u5230\u7f51\u7edc\u65ad\u94fe\u6d88\u606f\uff0c\u5207\u6362\u5230\u65ad\u94fe\u72b6\u6001<\/td><td><\/td><\/tr><tr><td>WIPC_MSG_USR_DATA<\/td><td>\u63a5\u53d7\u5230\u7f51\u7edc\u7684\u547d\u4ee4\uff0c\u89e3\u6790\u547d\u4ee4\uff0c\u6267\u884c\u54cd\u5e94\u52a8\u4f5c<\/td><td><\/td><\/tr><\/tbody><\/table><figcaption>\u53c2\u89c1fw-stm32l1-wbed-usr\/apps\/ds18b20\/s_def.c<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ \u9ed8\u8ba4\u72b6\u6001\u6d88\u606f\u5904\u7406\u5165\u53e3\nwipc_result_t def_msg_proc(uint8_t msg, void *in, void *out, ctx_t *ctx)\n{\n&nbsp; switch(msg){\n&nbsp; case WIPC_MSG_LPM_REQ:\n&nbsp; &nbsp; return WIPC_RES_SUCC;\n&nbsp; case WIPC_MSG_LPM_INIT:\n&nbsp; &nbsp; return WIPC_RES_SUCC;\n&nbsp; case WIPC_MSG_LPM_EXIT:\n&nbsp; &nbsp; return WIPC_RES_SUCC; &nbsp;\n&nbsp; case WIPC_MSG_NET_CONN:\n      \/\/ \u5207\u6362\u5230\u8fde\u63a5\u72b6\u6001\n&nbsp; &nbsp; fsm_goto(conn_msg_proc, ctx);\n&nbsp; &nbsp; return WIPC_RES_SUCC;\n&nbsp; case WIPC_MSG_NET_DISC:\n      \/\/ \u5207\u6362\u5230\u65ad\u94fe\u72b6\u6001\n&nbsp; &nbsp; fsm_goto(disc_msg_proc, ctx);\n&nbsp; &nbsp; return WIPC_RES_SUCC; &nbsp; &nbsp;\n&nbsp; case WIPC_MSG_USR_DATA:\n      \/\/ \u63a5\u53d7\u5230\u7f51\u7edc\u547d\u4ee4\n&nbsp; &nbsp; return rx_usr_data(in, out, ctx);\n&nbsp; case WIPC_MSG_IRQ_VTOR:\n&nbsp; &nbsp; return WIPC_RES_SUCC;\n&nbsp; default:\n&nbsp; &nbsp; return WIPC_RES_FAIL;\n&nbsp; }\n}<\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-column\" style=\"flex-basis:33.33%\"><\/div>\n<\/div>\n\n\n\n<p><\/p>\n","protected":false},"featured_media":0,"parent":263,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","docs_category":[],"_links":{"self":[{"href":"http:\/\/www.tinywsn.net\/wordpress\/index.php\/wp-json\/wp\/v2\/docs\/2405"}],"collection":[{"href":"http:\/\/www.tinywsn.net\/wordpress\/index.php\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"http:\/\/www.tinywsn.net\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"http:\/\/www.tinywsn.net\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=2405"}],"version-history":[{"count":31,"href":"http:\/\/www.tinywsn.net\/wordpress\/index.php\/wp-json\/wp\/v2\/docs\/2405\/revisions"}],"predecessor-version":[{"id":2492,"href":"http:\/\/www.tinywsn.net\/wordpress\/index.php\/wp-json\/wp\/v2\/docs\/2405\/revisions\/2492"}],"up":[{"embeddable":true,"href":"http:\/\/www.tinywsn.net\/wordpress\/index.php\/wp-json\/wp\/v2\/docs\/263"}],"wp:attachment":[{"href":"http:\/\/www.tinywsn.net\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=2405"}],"wp:term":[{"taxonomy":"docs_category","embeddable":true,"href":"http:\/\/www.tinywsn.net\/wordpress\/index.php\/wp-json\/wp\/v2\/docs_category?post=2405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}