標(biāo)題:
STM32 W5500 MQTT源程序
[打印本頁]
作者:
dysuperman
時間:
2020-4-24 15:01
標(biāo)題:
STM32 W5500 MQTT源程序
對剛學(xué)MQTT的師兄有幫助
單片機源程序如下:
#include "usart.h"
#include "device.h"
#include "spi2.h"
#include "ult.h"
#include "socket.h"
#include "w5500.h"
#include "24c16.h"
#include "md5.h"
#include "mqtt.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
extern uint8 txsize[]; // 引用外部變量,聲明Socket發(fā)送緩存大小
extern uint8 rxsize[]; // 引用外部變量,聲明Socket接收緩存大小
uint8_t domain_ip[4]={192,168,1,106};//115,29,225,215
uint8_t domain_name[]="www.embed-net.com";
uint8 buffer[2048];// 定義一個2KB的數(shù)組,用來存放Socket的通信數(shù)據(jù)
int main(void)
{
static char meassage[200];
int rc=0;
/***** MCU時鐘初始化 *****/
Systick_Init(72);
/***** 中斷控制器配置 *****/
NVIC_Configuration();
/*****TIM2 定時配置****/
TIM2_Configuration();
/* 實戰(zhàn)定時器的中斷優(yōu)先級 */
TIM2_NVIC_Configuration();
/***** GPIO、SPI初始化 *****/
GPIO_Configuration();
WIZ_SPI_Init();
/***** 串口初始化 *****/
USART1_Init();
/***** 初始化eeprom *****/
at24c16_init();
/***** 硬重啟W5500 *****/
Reset_W5500();
/***** W5500的IP信息初始化 *****/
set_default();// 設(shè)置默認(rèn)MAC、IP、GW、SUB、DNS
set_network();// 配置初始化IP信息并打印,初始化8個Socket
/***** 打開W5500的Keepalive功能 *****/
//setkeepalive(0);
printf("W5500 Init Complete!\r\n");
printf("Start TCP Client Test!\r\n");
srand(0);
while(1)
{
if(rc==0)
{
memset(meassage,0,sizeof(meassage));
do_mqtt_subscrib("wizled",meassage);//訂閱主題pyboard_led
rc++;
printf("%d\n\r",rc);
}
}
}
復(fù)制代碼
所有資料51hei提供下載:
STM32 W5500 MQTT.7z
(1.87 MB, 下載次數(shù): 140)
2020-4-24 16:12 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
作者:
hank007
時間:
2021-7-16 11:30
剛好要做這方面的應(yīng)用。謝謝樓主
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1