Initial commit
commit
be6a891b55
|
@ -0,0 +1 @@
|
||||||
|
out/
|
|
@ -0,0 +1,24 @@
|
||||||
|
#####################################################################
|
||||||
|
#### Please don't change this file. Use Makefile-user.mk instead ####
|
||||||
|
#####################################################################
|
||||||
|
# Including user Makefile.
|
||||||
|
# Should be used to set project-specific parameters
|
||||||
|
include ./Makefile-user.mk
|
||||||
|
|
||||||
|
# Important parameters check.
|
||||||
|
# We need to make sure SMING_HOME and ESP_HOME variables are set.
|
||||||
|
# You can use Makefile-user.mk in each project or use enviromental variables to set it globally.
|
||||||
|
|
||||||
|
ifndef SMING_HOME
|
||||||
|
$(error SMING_HOME is not set. Please configure it in Makefile-user.mk)
|
||||||
|
endif
|
||||||
|
ifndef ESP_HOME
|
||||||
|
$(error ESP_HOME is not set. Please configure it in Makefile-user.mk)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Include main Sming Makefile
|
||||||
|
ifeq ($(RBOOT_ENABLED), 1)
|
||||||
|
include $(SMING_HOME)/Makefile-rboot.mk
|
||||||
|
else
|
||||||
|
include $(SMING_HOME)/Makefile-project.mk
|
||||||
|
endif
|
|
@ -0,0 +1,39 @@
|
||||||
|
## Local build configuration
|
||||||
|
## Parameters configured here will override default and ENV values.
|
||||||
|
## Uncomment and change examples:
|
||||||
|
|
||||||
|
## Add your source directories here separated by space
|
||||||
|
# MODULES = app
|
||||||
|
# EXTRA_INCDIR = include
|
||||||
|
|
||||||
|
## ESP_HOME sets the path where ESP tools and SDK are located.
|
||||||
|
## Windows:
|
||||||
|
# ESP_HOME = c:/Espressif
|
||||||
|
|
||||||
|
## MacOS / Linux:
|
||||||
|
# ESP_HOME = /opt/esp-open-sdk
|
||||||
|
|
||||||
|
## SMING_HOME sets the path where Sming framework is located.
|
||||||
|
## Windows:
|
||||||
|
# SMING_HOME = c:/tools/sming/Sming
|
||||||
|
|
||||||
|
## MacOS / Linux
|
||||||
|
# SMING_HOME = /opt/sming/Sming
|
||||||
|
|
||||||
|
## COM port parameter is reqruied to flash firmware correctly.
|
||||||
|
## Windows:
|
||||||
|
# COM_PORT = COM3
|
||||||
|
|
||||||
|
## MacOS / Linux:
|
||||||
|
# COM_PORT = /dev/tty.usbserial
|
||||||
|
|
||||||
|
## Com port speed
|
||||||
|
# COM_SPEED = 115200
|
||||||
|
|
||||||
|
## Configure flash parameters (for ESP12-E and other new boards):
|
||||||
|
# SPI_MODE = dio
|
||||||
|
|
||||||
|
## SPIFFS options
|
||||||
|
DISABLE_SPIFFS = 1
|
||||||
|
# SPIFF_FILES = files
|
||||||
|
|
|
@ -0,0 +1,165 @@
|
||||||
|
#include <user_config.h>
|
||||||
|
#include <SmingCore/SmingCore.h>
|
||||||
|
|
||||||
|
// This should include WIFI_PWD & WIFI_SSID
|
||||||
|
#include "credentials.h"
|
||||||
|
|
||||||
|
#define TERM_WIDTH 132
|
||||||
|
#define TERM_HEIGHT 53
|
||||||
|
|
||||||
|
#define LED_PIN 2 // GPIO2
|
||||||
|
|
||||||
|
|
||||||
|
class IRCClient : protected TcpClient {
|
||||||
|
public:
|
||||||
|
IRCClient() : TcpClient(false) {}
|
||||||
|
|
||||||
|
using TcpClient::connect;
|
||||||
|
using TcpClient::getConnectionState;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual err_t onReceive(pbuf *buf) {
|
||||||
|
if(buf == NULL) {
|
||||||
|
return TcpClient::onReceive(buf);
|
||||||
|
} else {
|
||||||
|
int line, nextLine;
|
||||||
|
line = 0;
|
||||||
|
// debugf(NetUtils::pbufStrCopy(buf, 0, buf->tot_len));
|
||||||
|
|
||||||
|
do {
|
||||||
|
nextLine = NetUtils::pbufFindStr(buf, "\n", line);
|
||||||
|
|
||||||
|
if(nextLine - line > 1) {
|
||||||
|
String lineStr = NetUtils::pbufStrCopy(buf, line, nextLine - line);
|
||||||
|
parseLine(lineStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
line = nextLine + 1;
|
||||||
|
} while (nextLine != -1);
|
||||||
|
|
||||||
|
TcpClient::onReceive(buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual err_t onConnected(err_t err) {
|
||||||
|
Serial.println("onConnected");
|
||||||
|
setTimeOut(USHRT_MAX);
|
||||||
|
sendString("NICK vt520\nUSER termbot 0 * :vt520\n");
|
||||||
|
return TcpClient::onConnected(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void onError(err_t err) {
|
||||||
|
Serial.printf("Err: %d\n", err);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void onFinished(TcpClientState finishState) {
|
||||||
|
Serial.printf("Disconnected: %d\n", finishState);
|
||||||
|
}
|
||||||
|
|
||||||
|
void parseLine(String line) {
|
||||||
|
int d1 = line.indexOf(" ");
|
||||||
|
int d2 = line.indexOf(" ", d1 + 1);
|
||||||
|
int d3 = line.indexOf(" ", d2 + 1);
|
||||||
|
String arg1 = line.substring(0, d1);
|
||||||
|
String arg2 = line.substring(d1+1, d2);
|
||||||
|
String arg3 = line.substring(d2+1, d3);
|
||||||
|
debugf("parseLine('%s', '%s', '%s')\r\n", arg1.c_str(), arg2.c_str(), arg3.c_str());
|
||||||
|
|
||||||
|
if(arg2 == "001") {
|
||||||
|
sendString("PRIVMSG nickserv :GHOST vt520 papiezpedofil\n");
|
||||||
|
sendString("PRIVMSG nickserv :IDENTIFY vt520 papiezpedofil\n");
|
||||||
|
sendString("JOIN #hackerspace-pl\n");
|
||||||
|
Serial.printf("\033[2J\033[H");
|
||||||
|
Serial.printf("\033[!p\033[?7h");
|
||||||
|
Serial.printf("\033#3Connected\r\n");
|
||||||
|
Serial.printf("\033#4Connected\r\n\r\n\r\n");
|
||||||
|
} else if(arg2 == "PRIVMSG") {
|
||||||
|
String nickname = line.substring(1, line.indexOf("!"));
|
||||||
|
String msg = line.substring(line.indexOf(":", 1) + 1);
|
||||||
|
Serial.printf("<\033[1m%s\033[0m> %s\r\n", nickname.c_str(), msg.c_str());
|
||||||
|
} else if(arg1 == "PING") {
|
||||||
|
sendString("PONG " + arg2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TcpClient* currentClient = NULL;
|
||||||
|
|
||||||
|
void tcpServerClientConnected (TcpClient* client)
|
||||||
|
{
|
||||||
|
Serial.printf("Application onClientCallback : %s\r\n",client->getRemoteIp().toString().c_str());
|
||||||
|
if(currentClient == NULL) {
|
||||||
|
currentClient = client;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool tcpServerClientReceive (TcpClient& client, char *data, int size)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < size; i++) {
|
||||||
|
Serial.write(data[i]);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tcpServerClientComplete(TcpClient& client, bool succesfull)
|
||||||
|
{
|
||||||
|
debugf("Application CompleteCallback : %s \r\n",client.getRemoteIp().toString().c_str() );
|
||||||
|
currentClient = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
IRCClient client;
|
||||||
|
TcpServer tcpServer(tcpServerClientConnected, tcpServerClientReceive, tcpServerClientComplete);
|
||||||
|
|
||||||
|
Timer keepAliveTimer;
|
||||||
|
|
||||||
|
void init()
|
||||||
|
{
|
||||||
|
Serial.begin(9600);
|
||||||
|
system_set_os_print(0);
|
||||||
|
Serial.systemDebugOutput(false);
|
||||||
|
|
||||||
|
WifiStation.enable(true);
|
||||||
|
WifiAccessPoint.enable(false);
|
||||||
|
|
||||||
|
WifiStation.config(WIFI_SSID, WIFI_PWD);
|
||||||
|
WifiStation.waitConnection(*[]() {
|
||||||
|
Serial.print("Connected: ");
|
||||||
|
Serial.println(WifiStation.getIP());
|
||||||
|
tcpServer.listen(2137);
|
||||||
|
client.connect("chat.freenode.net", 6667);
|
||||||
|
}, 10, *[]() {
|
||||||
|
Serial.println("Connection failed.");
|
||||||
|
});
|
||||||
|
Serial.setCallback(*[](Stream& stream, char arrivedChar, unsigned short availableCharsCount) {
|
||||||
|
if(currentClient) {
|
||||||
|
currentClient->send(&arrivedChar, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
keepAliveTimer.initializeMs(10000, *[]() {
|
||||||
|
static int failureCounter = 0;
|
||||||
|
|
||||||
|
if(client.getConnectionState() != eTCS_Connected) {
|
||||||
|
if(failureCounter++ > 5)
|
||||||
|
System.restart();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
|
||||||
|
// Werks, lel
|
||||||
|
Serial.printf("\033[2J\033[H");
|
||||||
|
//Serial.printf("\033[!p\033[?7h");
|
||||||
|
Serial.printf("\033#3cymes szalom\r\n");
|
||||||
|
Serial.printf("\033#4cymes szalom\r\n");
|
||||||
|
Serial.printf("Yes was xD\r\n");
|
||||||
|
|
||||||
|
//Serial.printf("\x90" "1;1;0;10;1;1;12;0{\x20\x40????????????????????????;~@@@@@@~~??????~~GGGGGG~;TTTTTTTTTTTTTTTTTTTTTTTT\x9c");
|
||||||
|
//Serial.printf("\033)\x20\x40");
|
||||||
|
//Serial.printf("\x0f!!!\x0e!!!");
|
||||||
|
|
||||||
|
//Serial.printf("\x90" "1;1;0;12;1;1;12;0{ @---/---/---;????????/????????/????????;~@@@@@@~/~??????~/~GGGGGG~;TTTTTTTT/TTTTTTTT/TTTTTTTT\x9c");
|
||||||
|
/*Serial.printf("\033P1;1;1;0;0;2;0;0{P???owYn||~ywo??/?IRJaVNn^NVbJRI\033\\");
|
||||||
|
Serial.printf("!\033(P!");*/
|
||||||
|
// http://web.mit.edu/dosathena/doc/www/ek-vt520-rm.pdf - page 372
|
||||||
|
// CSI == \033[
|
||||||
|
// DCS == \x90
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
#ifndef CREDENTIALS_H
|
||||||
|
#define CREDENTIALS_H 1
|
||||||
|
|
||||||
|
#define WIFI_SSID "hackerspace.pl-guests"
|
||||||
|
#define WIFI_PWD "x---DD"
|
||||||
|
|
||||||
|
#endif /* ifndef CREDENTIALS_H */
|
|
@ -0,0 +1,45 @@
|
||||||
|
#ifndef __USER_CONFIG_H__
|
||||||
|
#define __USER_CONFIG_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// UART config
|
||||||
|
#define SERIAL_BAUD_RATE 115200
|
||||||
|
|
||||||
|
// ESP SDK config
|
||||||
|
#define LWIP_OPEN_SRC
|
||||||
|
#define USE_US_TIMER
|
||||||
|
|
||||||
|
// Default types
|
||||||
|
#define __CORRECT_ISO_CPP_STDLIB_H_PROTO
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
// Override c_types.h include and remove buggy espconn
|
||||||
|
#define _C_TYPES_H_
|
||||||
|
#define _NO_ESPCON_
|
||||||
|
|
||||||
|
// Updated, compatible version of c_types.h
|
||||||
|
// Just removed types declared in <stdint.h>
|
||||||
|
#include <espinc/c_types_compatible.h>
|
||||||
|
|
||||||
|
// System API declarations
|
||||||
|
#include <esp_systemapi.h>
|
||||||
|
|
||||||
|
// C++ Support
|
||||||
|
#include <esp_cplusplus.h>
|
||||||
|
// Extended string conversion for compatibility
|
||||||
|
#include <stringconversion.h>
|
||||||
|
// Network base API
|
||||||
|
#include <espinc/lwip_includes.h>
|
||||||
|
|
||||||
|
// Beta boards
|
||||||
|
#define BOARD_ESP01
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue