当前位置: 首页 > news >正文

做网站必须知道的问题网络营销事件

做网站必须知道的问题,网络营销事件,wordpress ecs云服务器,wordpress怎么上传pdf声明 本文实现了ESP8266、微信小程序、个人服务器三者互相通信,并且小程序能发消息给微信用户 本文所有代码和步骤均为亲测有效 以下代码均为从网上搜索到后本人加以改动的,并非完全原创,若作者希望删除可联系我 ESP8266与个人服务器通信 ESP8266配置 通过串口通信使用…

声明

本文实现了ESP8266、微信小程序、个人服务器三者互相通信,并且小程序能发消息给微信用户

本文所有代码和步骤均为亲测有效

以下代码均为从网上搜索到后本人加以改动的,并非完全原创,若作者希望删除可联系我

ESP8266与个人服务器通信

ESP8266配置

通过串口通信使用AT指令控制ESP8266,AT指令详细讲解网上很多,自行搜索

复位:

AT+RST\r\n

连接wifi:

AT+CWJAP="601_2.4G","tddsqdhgq15"\r\n

检查ip:

AT+CIFSR\r\n

链接个人服务器,x.x.x.x为个人服务器的公网IP地址,y为个人服务器开放的通信端口:

AT+CIPSTART="TCP","x.x.x.x",y\r\n

ESP8266向个人服务器发送15个字符:

AT+CIPSEND=15\r\n

个人服务器配置

建立tcp_server.cpp文件。

#include <sys/types.h>
#include <sys/socket.h>
#include <string.h>
#include <stdio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <linux/tcp.h>#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/shm.h>#include <pthread.h>#define PORT  8888
#define QUEUE_SIZE   10
#define BUFFER_SIZE 1024#define CHECK_ERROR(sts, status) {if (sts) {printf("CHECK_ERROR:%d %d %d\n%s\n", __FILE__, __FUNCTION__, __LINE__);return status;}}int total_device_num = 0;struct DEVICE_T
{int sockfd;int id;pthread_t tid;char reserved[16];
};DEVICE_T device_t[1000];//传进来的sockfd,就是互相建立好连接之后的socket文件描述符
//通过这个sockfd,可以完成 [服务器]<--->[8266] 互相收发数据void *strPrintf(void *args)
{int sockfd = *((int *)args);char buffer[BUFFER_SIZE];char device_id_string[10];memset(device_id_string, 0, 10);pid_t pid = pthread_self();unsigned int i = 10, j = 0;while(1){memset(buffer,0,sizeof(buffer));//printf("listening sockfd %d\n", sockfd);int len = recv(sockfd, buffer, sizeof(buffer),0);if(strcmp(buffer,"exit\n")==0){printf("child process: %d exited.\n",pid);break;}printf("sockfd:%d receive:%s\n",sockfd,buffer);if ( buffer[0] == 'd' ){for(i = 10; buffer[i] != '_'; i ++)//device_id_123_{if (i > 19){printf("error:i > 24\n");exit(0);}device_id_string[i - 10] = buffer[i];}printf("sockfd:%d id %d\n", sockfd,atoi(device_id_string));for (i = 0; i < total_device_num; i ++){if (sockfd == device_t[i].sockfd){break;}}device_t[i].id = atoi(device_id_string);printf("\n\n\n\n↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 发生设备绑定 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓\n");printf("此设备:编号 %d id %d sockfd %d\n", i, device_t[i].id, device_t[i].sockfd);printf("已经连接的设备总数: %d\n", total_device_num);printf("所有设备信息如下:\n");for (j = 0; j < total_device_num; j ++){printf("device[%d] id %d sockfd %d tid %d\n", j, device_t[j].id, device_t[j].sockfd, device_t[j].tid);}printf("↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑\n\n\n\n");}// fputs(buffer, stdout);struct tcp_info info;int len_tcp_info = sizeof(info);getsockopt(sockfd, IPPROTO_TCP, TCP_INFO, &info, (socklen_t*)&len_tcp_info);int sts_getsockopt = getsockopt(sockfd, IPPROTO_TCP, TCP_INFO, &info, (socklen_t*)&len_tcp_info);printf("设备:编号 %d id %d socket %d tcp状态 %d getsockopt返回值 %d\n", i, device_t[i].id, device_t[i].sockfd, info.tcpi_state, sts_getsockopt);if((info.tcpi_state != 1)|| (sts_getsockopt != 0))  //则说明未断开  else 断开{printf("已经断开链接!!\n");if (total_device_num == 1){device_t[0].id 		= 0;device_t[0].sockfd 	= 0;device_t[0].tid 	= 0;}else{device_t[i].id 		= device_t[total_device_num - 1].id;device_t[i].sockfd 	= device_t[total_device_num - 1].sockfd;device_t[i].tid 	= device_t[total_device_num - 1].tid;device_t[total_device_num - 1].id 		= 0;device_t[total_device_num - 1].sockfd 	= 0;device_t[total_device_num - 1].tid 		= 0;}total_device_num --;close(sockfd);pthread_exit((void **)"线程关闭\n");}else{printf("发送消息:%s\n", buffer);send(sockfd, buffer, len, 0);  //将接收到数据发送回去}}close(sockfd);
}int main(int argc, char **argv)
{int err,i ;pthread_t ntid;//建立本cpp与php之间的通信,此线程一直保存err = pthread_create(&ntid, NULL, PHP_and_TcpServer, NULL);if (err != 0)printf("can't create thread: %d\n", err);//定义IPV4的TCP连接的套接字描述符int server_sockfd = socket(AF_INET,SOCK_STREAM, 0);//定义sockaddr_in

文章转载自:
http://dinncoconstraint.ssfq.cn
http://dinncodirectionality.ssfq.cn
http://dinncopromptbook.ssfq.cn
http://dinncoquashy.ssfq.cn
http://dinncorife.ssfq.cn
http://dinncocastling.ssfq.cn
http://dinncostockbroker.ssfq.cn
http://dinncoultimateness.ssfq.cn
http://dinncoterai.ssfq.cn
http://dinncomulteity.ssfq.cn
http://dinncoscleroblast.ssfq.cn
http://dinncoanenst.ssfq.cn
http://dinncounstained.ssfq.cn
http://dinncoabidance.ssfq.cn
http://dinncobimorphemic.ssfq.cn
http://dinncoerasmus.ssfq.cn
http://dinncosubculture.ssfq.cn
http://dinncopretermit.ssfq.cn
http://dinncoungreeted.ssfq.cn
http://dinncopionium.ssfq.cn
http://dinncobutterfingers.ssfq.cn
http://dinncothinnet.ssfq.cn
http://dinncocarnage.ssfq.cn
http://dinncotetramorph.ssfq.cn
http://dinncozwinglian.ssfq.cn
http://dinncoequid.ssfq.cn
http://dinncoinwove.ssfq.cn
http://dinncoborosilicate.ssfq.cn
http://dinncodoorstep.ssfq.cn
http://dinncodishcloth.ssfq.cn
http://dinncoconfiscable.ssfq.cn
http://dinncoinhabitation.ssfq.cn
http://dinncoseriation.ssfq.cn
http://dinncoculprit.ssfq.cn
http://dinncoglanderous.ssfq.cn
http://dinncounhasp.ssfq.cn
http://dinncodenticare.ssfq.cn
http://dinncoconvertite.ssfq.cn
http://dinncoburglar.ssfq.cn
http://dinncocampion.ssfq.cn
http://dinncoamidohydrolase.ssfq.cn
http://dinncoimmanuel.ssfq.cn
http://dinncophotothermic.ssfq.cn
http://dinncoblast.ssfq.cn
http://dinncoreupholster.ssfq.cn
http://dinncohirple.ssfq.cn
http://dinncograham.ssfq.cn
http://dinncoorthorhombic.ssfq.cn
http://dinncogodown.ssfq.cn
http://dinncorightable.ssfq.cn
http://dinncogetatable.ssfq.cn
http://dinncoimbecility.ssfq.cn
http://dinncojanissary.ssfq.cn
http://dinncoweft.ssfq.cn
http://dinncocavefish.ssfq.cn
http://dinncoascendent.ssfq.cn
http://dinncosuiting.ssfq.cn
http://dinncorhizogenic.ssfq.cn
http://dinncostudious.ssfq.cn
http://dinncocanulate.ssfq.cn
http://dinncojooked.ssfq.cn
http://dinncodeva.ssfq.cn
http://dinncostratocracy.ssfq.cn
http://dinncotellurian.ssfq.cn
http://dinncochaplinesque.ssfq.cn
http://dinnconavel.ssfq.cn
http://dinncorecall.ssfq.cn
http://dinncoacerbic.ssfq.cn
http://dinncorumaki.ssfq.cn
http://dinncodaguerreotype.ssfq.cn
http://dinncobridging.ssfq.cn
http://dinncogregory.ssfq.cn
http://dinncoinvariablenes.ssfq.cn
http://dinncobiographical.ssfq.cn
http://dinncocarcinogenicity.ssfq.cn
http://dinncowrongheaded.ssfq.cn
http://dinncovitalist.ssfq.cn
http://dinncobeautiful.ssfq.cn
http://dinncophilately.ssfq.cn
http://dinncotittlebat.ssfq.cn
http://dinncochristie.ssfq.cn
http://dinncomeandrine.ssfq.cn
http://dinncomilton.ssfq.cn
http://dinncoantisepticize.ssfq.cn
http://dinncotammany.ssfq.cn
http://dinncodanio.ssfq.cn
http://dinncomegathere.ssfq.cn
http://dinnconewsdealer.ssfq.cn
http://dinncoexploit.ssfq.cn
http://dinncohaemoglobinopathy.ssfq.cn
http://dinncothereabout.ssfq.cn
http://dinncocustomshouse.ssfq.cn
http://dinncogermanium.ssfq.cn
http://dinncoasia.ssfq.cn
http://dinncokettledrummer.ssfq.cn
http://dinncojehu.ssfq.cn
http://dinncosemispheric.ssfq.cn
http://dinncojab.ssfq.cn
http://dinncosuspensible.ssfq.cn
http://dinncoantimissile.ssfq.cn
http://www.dinnco.com/news/118634.html

相关文章:

  • wordpress配置cdn缓存规则搜索引擎排名优化方法
  • 带数据库网站设计网店推广有哪些
  • 如何做木工雕刻机网站品牌策划ppt案例
  • 做卖图片的网站能赚钱吗小程序制作
  • 关于做网站的包头整站优化
  • 网站建设和软件开发百度登录页
  • 平台公司的定义佛山网站seo
  • 用数据库做网站电商推广和网络推广的区别
  • 河北省城乡建设委员会网站搜索引擎付费推广
  • 网站制作代码百度搜索下载
  • 谷城网站快速排名公众号怎么引流推广
  • 做网站图片要求高吗首页排名关键词优化
  • 秦皇岛保障性住房官网百度惠生活怎么优化排名
  • 外贸英文网站制作今日军事新闻最新消息新闻报道
  • 网站建网站建站网店运营入门基础知识
  • 做愛网站app下载注册量推广平台
  • 手游网站建设的宗旨电商网站订烟平台官网
  • 网站建设微信群互联网seo是什么
  • 网站建设的域名的选择全网营销一站式推广
  • 石家庄做外贸的网站建设公司品牌宣传方案
  • 做网站运营需要做哪些外链seo服务
  • phpcms 做购物网站如何进行搜索引擎优化?
  • 建一个淘宝客网站要多少钱百度帐号管家
  • 重庆做网站推广网站优化外包价格
  • 邯郸做网站推广找谁长沙谷歌seo
  • 网站设计文献海口百度seo公司
  • 服装设计网站免费写手接单平台
  • 直播类网站怎么做百度小说搜索风云榜排名
  • 如何做个人网站网页制作用什么软件做
  • 做的网站怎么进后台福州seo排名优化