Push ( this i will edit in future and not push again )
the first live functions steps

...
AP Mode = OK
STA Mode = OK
AP + STA = ok ( it can be all two mode's same time! )
Modul in a Infrastructure eMbedded with WPA2 + SSID and Password that will get IP from a DHCP well
From Network ping then all Net Clients ok
Broadcast ping with nmap ok
GPIO's switched =
EDIT2:
PC = Server ( Linux example )
ESP8266 = Client , USB TTL Adapter example to PC
Little Linux Server for Test with a ESP8266 as client
Code: Select all
/* A simple server in the internet domain using TCP
The port number is passed as an argument */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
void error(const char *msg)
{
perror(msg);
exit(1);
}
int main(int argc, char *argv[])
{
int sockfd, newsockfd, portno;
socklen_t clilen;
char buffer[256];
struct sockaddr_in serv_addr, cli_addr;
int n;
if (argc < 2) {
fprintf(stderr,"ERROR, no port provided\n");
exit(1);
}
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
error("ERROR opening socket");
bzero((char *) &serv_addr, sizeof(serv_addr));
portno = atoi(argv[1]);
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = INADDR_ANY;
serv_addr.sin_port = htons(portno);
if (bind(sockfd, (struct sockaddr *) &serv_addr,
sizeof(serv_addr)) < 0)
error("ERROR on binding");
listen(sockfd,5);
clilen = sizeof(cli_addr);
newsockfd = accept(sockfd,
(struct sockaddr *) &cli_addr,
&clilen);
if (newsockfd < 0)
error("ERROR on accept");
do {
bzero(buffer,256);
n = read(newsockfd,buffer,255);
if (n < 0) error("ERROR reading from socket");
printf("Here is the message: %s\n",buffer);
n = write(newsockfd,"I got your message",18);
if (n < 0) error("ERROR writing to socket");
} while(1);
close(newsockfd);
close(sockfd);
return 0;
}
The AT Protokoll for the client
Code: Select all
reset and Info to Modul:
AT+RST
setting as Station:
AT+CWMODE=1
connect to Router:
AT+CWJAP="ssid","passwort"
get DHCP IP Adresse :
AT+CIFSR
start TCP-Server ( Linux Server Code Top ) in a console
server <port>
multi conn:
AT+CIPMUX=1
connect with the Server:
AT+CIPSTART=4,"TCP","xxx.xxx.xxx.xxx",<port>
Send 10 chars:
AT+CIPSEND=4,10
send more chars - connection would be online ...
AT+CIPSEND=4,<counts>
Edit3:
PC = Client
ESP8266 = Server, USB TTL PC example
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
void error(const char *msg)
{
perror(msg);
exit(0);
}
int main(int argc, char *argv[])
{
int sockfd, portno, n;
struct sockaddr_in serv_addr;
struct hostent *server;
char buffer[256];
if (argc < 3) {
fprintf(stderr,"usage %s hostname port\n", argv[0]);
exit(0);
}
portno = atoi(argv[2]);
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
error("ERROR opening socket");
server = gethostbyname(argv[1]);
if (server == NULL) {
fprintf(stderr,"ERROR, no such host\n");
exit(0);
}
bzero((char *) &serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
bcopy((char *)server->h_addr,
(char *)&serv_addr.sin_addr.s_addr,
server->h_length);
serv_addr.sin_port = htons(portno);
if (connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0)
error("ERROR connecting");
do {
printf("Please enter the message: ");
bzero(buffer,256);
fgets(buffer,255,stdin);
n = write(sockfd,buffer,strlen(buffer));
} while (1);
if (n < 0)
error("ERROR writing to socket");
bzero(buffer,256);
n = read(sockfd,buffer,255);
if (n < 0)
error("ERROR reading from socket");
printf("%s\n",buffer);
close(sockfd);
return 0;
}
Protokoll
Code: Select all
ESP8266 Modul now Server:
reset and Info to Modul:
AT+RST
Set as Station:
AT+CWMODE=1
Connect with Router :
AT+CWJAP="ssid","password"
Get IP over DHCP:
AT+CIFSR
multi conn:
AT+CIPMUX=1
Start ESP8266 Modul as Server:
AT+CIPSERVER=1,8888
at console , start the client and write Text..
echo at Modul over UART
If client closed, Server waits for new connection.
Without Client - Telent can used too.
/~telnet <modul-ip> <port>
Update support for two Baudraten 57.6 & 115.200
src=
http://www.electrodragon.com/w/index.ph ... oldid=6957
from mail..
new version 091
Our engineers are working on the new version, it has a slightly different layout with the image we posted on store, if you receive this one, please note:
Connect all the four pins (or only CH_PD) in between to VCC, not necessary to connect 10K resistor, CH_PD ensure the module start from flash, and low mode will enter into updating firmware mode, pin RST can restart the module.
There are two leds on the board, one is power led, another one is status LED, when power up, pwr led keeps on and status led will blink once.
baud rate may work at 115200 or 57600
Best wishes
Rudi
btw:
next future
http://detail.1688.com/offer/4025819424 ... gsda_offer