Все должно быть в одной директории. В Arduino-ide должны появиться вкладки.
ядро и IDE какая?
1.8 что то там , но работает и на 2-й версии.
Ядро не должно влиять.
Ide их все открывает и компилит вместе.
коню понятно…в каком файле эта функция?
Забыл один файл. Детектирование телевизоров.
File - ssdputils.ino
void check_write_parm_cc(String mac,String ext_file,String url_location ,String s_find,String p_parm) {
char s_parm[48];
char e_parm[50];
char *f_parm;
char *fe_parm;
int parm_len;
//memset(s_parm,0,48);
//memset(e_parm,0,50);
//Serial.printf("Processing %s\n",p_parm.c_str());
sprintf(s_parm,"<%s>",p_parm.c_str());
sprintf(e_parm,"</%s>",p_parm.c_str());
parm_len=strlen(s_parm);
f_parm=strstr(s_find.c_str(),s_parm)+parm_len;
if (f_parm!=NULL) {
fe_parm=strstr(s_find.c_str(),e_parm);
if (fe_parm!=NULL) {
char str_url[1024];
//memset(str_url,0,1024);
char rstr_url[1024];
//memset(rstr_url,0,1024);
if (fe_parm-f_parm>0) {
if (fe_parm-f_parm<1022) {
strncpy(str_url,f_parm,fe_parm-f_parm);
str_url[fe_parm-f_parm]=0;
} else {
strncpy(str_url,f_parm,1022);
str_url[fe_parm-f_parm]=0;
}
} else {
return;
}
if (strstr(str_url,"://")) {
strcpy(rstr_url,str_url);
} else {
if (strstr(url_location.c_str(),"://")) {
strcpy(rstr_url,url_location.c_str());
strcat(rstr_url,str_url);
} else {
strcpy(rstr_url,str_url);
}
}
//Serial.printf("Write %s to %s%s\n",rstr_url,mac.c_str(),ext_file.c_str());
writeFile(String(mac+ext_file).c_str(),rstr_url);
}
}
}
void check_write_parm(String mac,String ext_file,String url_location ,String s_find,String p_parm) {
String s_parm="<"+p_parm+">";
String e_parm="</"+p_parm+">";
int parm_len=s_parm.length();
int f_parm=s_find.indexOf(s_parm);
if (f_parm>-1){
int fe_parm=s_find.indexOf(e_parm);
if (fe_parm>-1) {
String str_url=s_find.substring(f_parm+parm_len,fe_parm);
int has_http=str_url.indexOf("://");
if (has_http>-1) {
} else {
str_url=url_location+str_url;
}
Serial.println("Write "+mac+ext_file+" "+str_url);
//writeFile(String("/"+mac+ext_file).c_str(),str_url.c_str());
writeFile(String(mac+ext_file).c_str(),str_url.c_str());
}
}
}
String get_url_content(String url) {
HTTPClient httpclient;
WiFiClient hclient;
//delay(2000);
if (httpclient.begin(hclient,url)) {
//if (httpclient.begin(hclient,"http://192.168.113.86:52323/dmr.xml")) {
//if (httpclient.begin(hclient,host.substring(7),port,urlpath,false)) {
//if (httpclient.begin(hclient,host.substring(7),port,pbuf.c_str(),false)) {
int httpCode = httpclient.GET();
if (httpCode > 0) {
if (httpCode == 401) {
httpCode = httpclient.GET();
}
// HTTP header has been send and Server response header has been handled
//Serial.printf("[HTTP] GET... code: %d\n", httpCode);
if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
String payload = httpclient.getString();
httpclient.end();
hclient.stop();
return payload;
}
}
}
httpclient.end();
hclient.stop();
return "";
}
void parse_ssdp(String ip,String mac,String p_url_location) {
String p_parse=get_url_content(p_url_location);
String url_location;
if (p_url_location.indexOf("/dmr.xml")>-1) {
url_location=p_url_location.substring(0,p_url_location.length()-8);
} else if (p_url_location.indexOf("/smp_")>-1) {
url_location=p_url_location.substring(0,p_url_location.indexOf("/smp_"));
} else {
url_location=p_url_location.substring(0,p_url_location.length()-1);
}
//Serial.println(p_parse);
if (p_parse.length()>2) {
check_write_parm(mac,".avtrurl",url_location,p_parse.substring(p_parse.indexOf("AVTransport:1")),"controlURL");
check_write_parm(mac,".avtrurls",url_location,p_parse.substring(p_parse.indexOf("AVTransport:1")),"SCPDURL");
check_write_parm(mac,".rendurl",url_location,p_parse.substring(p_parse.indexOf("RenderingControl:1")),"controlURL");
check_write_parm(mac,".rendurls",url_location,p_parse.substring(p_parse.indexOf("RenderingControl:1")),"SCPDURL");
check_write_parm(mac,".irccurl",url_location,p_parse.substring(p_parse.indexOf("IRCC:1")),"controlURL");
check_write_parm(mac,".irccurls",url_location,p_parse.substring(p_parse.indexOf("IRCC:1")),"SCPDURL");
/*check_write_parm(ip,".ipname",url_location,p_parse,"friendlyName");
check_write_parm(mac,".macname",url_location,p_parse,"friendlyName");
check_write_parm(ip,".ipprod",url_location,p_parse,"manufacturer");
check_write_parm(mac,".macprod",url_location,p_parse,"manufacturer");
check_write_parm(ip,".ipmname",url_location,p_parse,"modelName");
check_write_parm(mac,".macmname",url_location,p_parse,"modelName");
check_write_parm(ip,".ipmnum",url_location,p_parse,"modelNumber");
check_write_parm(mac,".macmnum",url_location,p_parse,"modelNumber");
check_write_parm(mac,".wifimac",url_location,p_parse,"wifiMac");
check_write_parm(mac,".wiremac",url_location,p_parse,"wiredMac");
check_write_parm(mac,".btmac",url_location,p_parse,"bluetoothMac");*/
check_write_parm(ip,".ipname"," ",p_parse,"friendlyName");
check_write_parm(mac,".macname"," ",p_parse,"friendlyName");
check_write_parm(ip,".ipprod"," ",p_parse,"manufacturer");
check_write_parm(mac,".macprod"," ",p_parse,"manufacturer");
if (p_parse.indexOf("LG WebOSTV DMRplus")==-1) {
check_write_parm(ip,".ipmname"," ",p_parse,"modelName");
check_write_parm(mac,".macmname"," ",p_parse,"modelName");
if (p_parse.indexOf("Samsung")>-1) {
if (p_parse.indexOf("AllShare1.0")>-1) {
check_write_parm(ip,".ipsmhub"," ",p_parse,"modelNumber");
check_write_parm(mac,".macsmhub"," ",p_parse,"modelNumber");
}
}
} else {
if (p_parse.indexOf("LG WebOSTV DMRplus")>-1) {
check_write_parm(ip,".ipwebos"," ",p_parse,"modelNumber");
check_write_parm(mac,".macwebos"," ",p_parse,"modelNumber");
} else if (p_parse.indexOf("WEBOS")>-1) {
check_write_parm(ip,".ipwebos"," ",p_parse,"modelNumber");
check_write_parm(mac,".macwebos"," ",p_parse,"modelNumber");
}
}
if (p_parse.indexOf("WEBOS")>-1) {
check_write_parm(ip,".ipwebos"," ",p_parse,"modelNumber");
check_write_parm(mac,".macwebos"," ",p_parse,"modelNumber");
}
check_write_parm(ip,".ipmnum"," ",p_parse,"modelNumber");
check_write_parm(mac,".macmnum"," ",p_parse,"modelNumber");
check_write_parm(mac,".wifimac"," ",p_parse,"wifiMac");
if (p_parse.indexOf("wiredMac")>-1) {
check_write_parm(ip,".ipwebos"," ",p_parse,"wiredMac");
check_write_parm(mac,".macwebos"," ",p_parse,"wiredMac");
}
check_write_parm(mac,".wiremac"," ",p_parse,"wiredMac");
check_write_parm(mac,".btmac"," ",p_parse,"bluetoothMac");
}
}
void parse_tvs() {
String lf=String("<html><body>");
String dpp="";
//Serial.printf("Listing directory: %s\n", dirname);
Dir root = LittleFS.openDir("");
while (root.next()) {
String f_n=String(root.fileName());
if (f_n.indexOf(".dsc")>-1) {
String s_mac=f_n.substring(0,f_n.indexOf(".dsc"));
if (LittleFS.exists(String(s_mac+".on"))) {
Dir sroot=LittleFS.openDir(f_n.c_str());
while (sroot.next()) {
String s_url=getFile(String(f_n+"/"+sroot.fileName()).c_str());
String s_ip=getFile(String(s_mac+".macip").c_str());
char t_mac[20];
if (find_arp(s_ip,t_mac)==1) {
Serial.printf("Process tv mac %s ip %s url %s\n",s_mac.c_str(),s_ip.c_str(),s_url.c_str());
parse_ssdp(s_ip,s_mac,s_url);
} else {
LittleFS.remove(String(s_mac+".on").c_str());
}
}
}
}
}
}
другое дело )))
Variables and constants in RAM (global, static), used 49808 / 80192 bytes (62%)
║ SEGMENT BYTES DESCRIPTION
╠══ DATA 2132 initialized variables
╠══ RODATA 16868 constants
╚══ BSS 30808 zeroed variables
. Instruction RAM (IRAM_ATTR, ICACHE_RAM_ATTR), used 60671 / 65536 bytes (92%)
║ SEGMENT BYTES DESCRIPTION
╠══ ICACHE 32768 reserved space for flash instruction cache
╚══ IRAM 27903 code in IRAM
. Code in flash (default, ICACHE_FLASH_ATTR), used 469176 / 1048576 bytes (44%)
║ SEGMENT BYTES DESCRIPTION
╚══ IROM 469176 code in flash
Небольшая инструкция.
Модуль после подключения слушает сеть и при включении телевизора (если телевизор умеет) ловит upnp пакеты. Проанализировав их он исходя из модели настраивает нужную библиотеку на работу с ним. В файловой системе модуля есть список файлов. Имя файла - mac адрес тв, а расширение определяет нужный функциона (url). В web сервере модуля есть возможность посмотреть то, что нашлось.
Для тестирования - напишите мне, чтобы не проходить стандартную процедуру регистрации.