blinker + 天猫 + arduino dlna 投屏
第一次发帖;怎么不能设置求助&分享啊;dlna部分功能没问题;
http_send();可以投屏推送网络地址给电视机和本地的爱奇艺万能联播;
但是,使用blinker遇到了各种各样的问题,,,
譬如:
Freeheap: 1280
16:29:57.069 -> isJson: {"data":{"state":"online"},"fromDevice":"6503990CFUGZS3Q42CPIB1EA","toDevice":"6503990d287311ebb5da5254","deviceType":"OwnApp"}
16:29:57.103 -> ERROR: Print data is not Json! {"data":{"state":"online"},"fromDevice":"6503990CFUGZS3Q42CPIB1EA","toDevice":"6503990d287311ebb5da5254","deviceType":"OwnApp"}
16:29:57.103 -> Freeheap: 2320
16:29:57.103 -> heartBeat isParsed
16:29:57.103 -> checkNum count: 1
16:29:57.103 -> isParsed
他自己发包,居然说设备在线,不是json格式,,,无语。。。
慢慢琢磨,如果有进展,还会继续更新;
也请大神help;
理想的目标就是
天猫精灵,客厅的灯红色,播放汪汪队;
天猫精灵,客厅的灯蓝色,播放猪猪侠;
努力ing。。。。
怎么没人理呀,,粘点源代码
#ifndef ESP8266SSDP_H
#define ESP8266SSDP_H
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClientSecure.h>
class UdpContext;
class SSDPClass{
public:
SSDPClass();
~SSDPClass();
bool begin();
void end();
void update();
void send();
void http_send();
bool _havetv;
protected:
char tuuid;
UdpContext* _server;
//WiFiClientSecure httpclient;
//HTTPClient http;
uint16_t _port;
IPAddress _respondToAddr;
uint16_t_respondToPort;
IPAddress _remoteAddr;
uint16_t_remotePort;
bool _pending;
};
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SSDP)
extern SSDPClass SSDP;
#endif
#endif
#ifndef LWIP_OPEN_SRC
#define LWIP_OPEN_SRC
#endif
#include <functional>
#include "ESP8266SSDP.h"
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h> // http ->tcp
#include "WiFiUdp.h"
#include "debug.h"
#include <WiFiClientSecure.h>
extern "C" {
#include "osapi.h"
#include "ets_sys.h"
#include "user_interface.h"
}
#include "lwip/opt.h"
#include "lwip/udp.h"
#include "lwip/inet.h"
#include "lwip/igmp.h"
#include "lwip/mem.h"
#include "include/UdpContext.h"
#define DEBUG_SSDPSerial
#define SSDP_PORT 1900
#define SSDP_BUFFER_SIZE64
#define SSDP_MULTICAST_ADDR 239, 255, 255, 250
static const char _ssdp_response_template[] PROGMEM =
"HTTP/1.1 200 OK\r\n"
"EXT:\r\n";
static const char _dlna_tcpsend_template[] PROGMEM =
"POST /AVTransport/%s/control.xml HTTP/1.1\r\n"
"HOST: %s:%d\r\n"
"CONTENT-LENGTH: %d\r\n"
"CONTENT-TYPE: text/xml; charset=\"utf-8\"\r\n"
"SOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#%s\"\r\n"
"USER-AGENT: Linux/3.3.0, UPnP/1.0, libupnp/1.6.19\r\n"
"\r\n";
static const char _ssdp_search_template[] PROGMEM =
"M-SEARCH * HTTP/1.1\r\n"
"User-Agent: E:\mypy\dlna.py/0.15\r\n"
"HOST: 239.255.255.250:1900\r\n"
"Accept: */*\r\n"
"MAN: \"ssdp:discover\"\r\n"
"ST: %s\r\n"
"MX: 3\r\n"
"\r\n";
static const char_dlna_action_template[] PROGMEM =
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n"
"<s:Body><u:%s xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\">\r\n"
"<InstanceID>0</InstanceID>\r\n"
"<Speed>1</Speed>\r\n"
"</u:%s>\r\n"
"</s:Body>\r\n"
"</s:Envelope>\r\n";
static const char_dlna_playuri_template[] PROGMEM =
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n"
"<s:Body><u:SetAVTransportURI xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\">\r\n"
"<InstanceID>0</InstanceID>\r\n"
"<CurrentURI>%s</CurrentURI>\r\n"
"<CurrentURIMetaData><DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"><item id="123" parentID="-1" restricted="1"><upnp:storageMedium>UNKNOWN</upnp:storageMedium><upnp:writeStatus>UNKNOWN</upnp:writeStatus><upnp:class>object.item.videoItem</upnp:class><dc:title>....-vip.................</dc:title><dc:creator>youku</dc:creator><res protocolInfo="http-get:*:video/mp4:*;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000">%s</res><yunos os="android" ver="4.5.1.151" name="......" pkg="com.quark.browser" proj_mode="NORMAL_2" yk_vid="16062670667400001" yk_showtitle="NULL" yk_showid="NULL" duration="37245330" startpos="0" definition="NULL" /></item></DIDL-Lite></CurrentURIMetaData>\r\n"
"</u:SetAVTransportURI>\r\n"
"</s:Body>\r\n"
"</s:Envelope>\r\n";
SSDPClass::SSDPClass(){
_port=80;
_pending=false;
}
SSDPClass::~SSDPClass() {
end();
}
bool SSDPClass::begin() {
end();
_server = new UdpContext;
_server->ref();
IPAddress local = WiFi.localIP();
IPAddress mcast(SSDP_MULTICAST_ADDR);
if (igmp_joingroup(local, mcast) != ERR_OK ) {
#ifdef DEBUG_SSDP
DEBUG_SSDP.printf_P(PSTR("SSDP failed to join igmp group\n"));
#endif
return false;
}
if (!_server->listen(IP_ADDR_ANY, SSDP_PORT)) {
return false;
}
_server->setMulticastInterface(local);
_server->setMulticastTTL(2);
_server->onRx(std::bind(&SSDPClass::update, this));
if (!_server->connect(mcast, SSDP_PORT)) {
return false;
}
return true;
}
void SSDPClass::end() {
if(!_server)
return;
_server->disconnect();
IPAddress local = WiFi.localIP();
IPAddress mcast(SSDP_MULTICAST_ADDR);
_server->unref();
_server = 0;
}
void SSDPClass::update() {
if (!_pending && _server->next()) {
uint8_t cursor = 0;
uint8_t cr = 0;
char buffer = {0};
bool location = false;
bool server = false ;
bool uuid= false ;
char ip;
uint8_t ip1;
uint8_t ip2;
uint8_t ip3;
uint8_t ip4;
char ipport;
while (_server->getSize() > 0) {
char c = _server->read();
if(strcasecmp(buffer,"serv") == 0){
cursor=0;
do{
c = _server->read();
}while(c != ' ');
do{
c = _server->read();
buffer = c;
buffer ='\0';
}while( c != '\r' && c != '\n' );
for(int i=0;i<strlen(buffer);i++){
buffer = tolower(buffer);
}
if (strstr(buffer,"dlna") > 0){
server = true;
}
}
if(strcasecmp(buffer,"Loca") == 0){
cursor=0;
do{
c = _server->read();
}while(c != ' ');
do{
c = _server->read();
buffer = c;
buffer ='\0';
}while( c != '\r' && c != '\n' );
int j=7;
int k;
do{
ip = buffer;
ip = '\0';
j++;
}while(buffer !='.');
ip1 = atoi(ip);
j++;
k = j;
do{
ip = buffer;
ip ='\0';
j++;
}while(buffer !='.' );
ip2 = atoi(ip);
j++;
k = j;
do{
ip = buffer;
ip ='\0';
j++;
}while(buffer !='.' );
ip3 = atoi(ip);
j++;
k = j;
do{
ip = buffer;
ip ='\0';
j++;
}while(buffer !=':' );
ip4 = atoi(ip);
j++;
k = j;
do{
ipport = buffer;
ipport ='\0';
j++;
}while(buffer !='/' && j < strlen(buffer) );
_remoteAddr = IPAddress(ip1,ip2,ip3,ip4);
_remotePort = atoi(ipport);
location= true;
}
if(strncmp("USN:",buffer,4)==0){
cursor=0;
do{
c = _server->read();
}while(c != ' ');
do{
c = _server->read();
buffer = c;
buffer ='\0';
}while( c != '\r' && c != '\n');
char fuuid;
fuuid = buffer;
fuuid = buffer;
fuuid = buffer;
fuuid = buffer;
fuuid = '\0';
if (strcasecmp(fuuid,"uuid")==0){
for( int a = 0; a < 60; a =a +1 ){
if (buffer != ':' && buffer != '\r' && buffer != '\n' ){
tuuid =buffer;
}else{
tuuid = '\0';
}
}
uuid=true;
}
};
if(cursor < 4){
buffer = c;
buffer = '\0';
}
if(c=='\r' || c=='\n'){
cursor = 0;
}
if (uuid && server && location){
_pending = true;
_havetv = true;
DEBUG_SSDP.printf("location:%d,%d,%d,%d\r\n",ip1,ip2,ip3,ip4);
DEBUG_SSDP.printf("uuid:%s\r\n",(char*)tuuid);
}
}
//_server->flush();
}
if (_pending) {
while (_server->next())
_server->flush();
}
}
void SSDPClass::http_send(){
DEBUG_SSDP.printf("???");
WiFiClient clients;
if (!clients.connect(_remoteAddr,_remotePort)) { // 判断连接情况
DEBUG_SSDP.print("connection failed/r/n");
return;
}
char bui;
char bu;
int len;
//停止
len = snprintf_P(bui, sizeof(bui),
_dlna_action_template,
"Stop",
"Stop"
);
len = snprintf_P(bu, sizeof(bu),
_dlna_tcpsend_template,
tuuid,
_remoteAddr.toString().c_str(),
_remotePort,
len,
"Stop"
);
clients.print(bu);
clients.print(bui);
//uri
len = snprintf_P(bui, sizeof(bui),
_dlna_playuri_template,
"https://youku.com-t-youku.com/20190325/10676_9a90c151/index.m3u8?dlnaopt=2&tpseq=1",
"https://youku.com-t-youku.com/20190325/10676_9a90c151/index.m3u8?dlnaopt=2&tpseq=1"
);
len = snprintf_P(bu, sizeof(bu),
_dlna_tcpsend_template,
tuuid,
_remoteAddr.toString().c_str(),
_remotePort,
len,
"SetAVTransportURI"
);
clients.print(bu);
clients.print(bui);
//播放
len = snprintf_P(bui, sizeof(bui),
_dlna_action_template,
"Play",
"Play"
);
len = snprintf_P(bu, sizeof(bu),
_dlna_tcpsend_template,
tuuid,
_remoteAddr.toString().c_str(),
_remotePort,
len,
"Play"
);
clients.print(bu);
clients.print(bui);
DEBUG_SSDP.print("运行完了,去看看");
DEBUG_SSDP.print("\r\n");
}
void SSDPClass::send() {
DEBUG_SSDP.print("寻找.....\r\n");
char buffer;
IPAddress ip = WiFi.localIP();
IPAddress remoteAddr;
uint16_t remotePort;
remoteAddr = IPAddress(SSDP_MULTICAST_ADDR);
remotePort = SSDP_PORT;
int len = snprintf_P(buffer, sizeof(buffer),
_ssdp_search_template,
"ssdp:all"
);
_server->append(buffer, len);
_server->send(remoteAddr, remotePort);
len = snprintf_P(buffer, sizeof(buffer),
_ssdp_search_template,
"urn:schemas-upnp-org:device:AVTransport:1"
);
_server->append(buffer, len);
_server->send(remoteAddr, remotePort);
len = snprintf_P(buffer, sizeof(buffer),
_ssdp_search_template,
"urn:schemas-upnp-org:device:MediaRenderer:1"
);
_server->append(buffer, len);
_server->send(remoteAddr, remotePort);
len = snprintf_P(buffer, sizeof(buffer),
_ssdp_search_template,
"urn:schemas-upnp-org:device:MediaServer:1"
);
_server->append(buffer, len);
_server->send(remoteAddr, remotePort);
}
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SSDP)
SSDPClass SSDP;
#endif
这里是ino的源码
#define BLINKER_PRINT Serial
#define BLINKER_WIFI
#define BLINKER_ALIGENIE_LIGHT
#include <Blinker.h>
#include <ESP8266SSDP.h>
char auth[] = "50097bd50d7b";
char ssid[] = "zhzx";
char pswd[] = "119119119";
BlinkerButton Button1("btn-abc");
void button1_callback(const String & state) {
if(SSDP._havetv){
Blinker.print("havetv");
}else{
Blinker.print("non-tv");
}
}
void aligenieColor(const String & color)
{
BLINKER_LOG("need set color: ", color);
if (color == "Red") {
SSDP.http_send();
}
else if (color == "Yellow") {
SSDP.http_send();
}
else if (color == "Blue") {
SSDP.http_send();
}
else if (color == "Green") {
SSDP.http_send();
}
else if (color == "White") {
SSDP.http_send();
}
else if (color == "Black") {
SSDP.http_send();
}
else if (color == "Cyan") {
SSDP.http_send();
}
else if (color == "Purple") {
SSDP.http_send();
}
else if (color == "Orange") {
SSDP.http_send();
}
BlinkerAliGenie.color(color);
BlinkerAliGenie.print();
}
void heartbeat()//心跳包
{
if (!SSDP._havetv){
SSDP.send();
}
}
void setup() {
Serial.begin(115200);
Blinker.begin(auth, ssid, pswd);
BLINKER_DEBUG.stream(Serial);
BLINKER_DEBUG.debugAll();
BlinkerAliGenie.attachColor(aligenieColor);
extern BearSSL::WiFiClientSecure client_mqtt;
client_mqtt.stop();
Blinker.attachHeartbeat(heartbeat);
Button1.attach(button1_callback);
if (WiFi.waitForConnectResult() == WL_CONNECTED) {
SSDP.begin();
}else{
Serial.printf("WiFi Failed\n");
}
}
void loop() {
Blinker.run();
} cpp源代码
#ifndef LWIP_OPEN_SRC
#define LWIP_OPEN_SRC
#endif
#include <functional>
#include "ESP8266SSDP.h"
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h> // http ->tcp
#include "WiFiUdp.h"
#include "debug.h"
#include <WiFiClientSecure.h>
extern "C" {
#include "osapi.h"
#include "ets_sys.h"
#include "user_interface.h"
}
#include "lwip/opt.h"
#include "lwip/udp.h"
#include "lwip/inet.h"
#include "lwip/igmp.h"
#include "lwip/mem.h"
#include "include/UdpContext.h"
#define DEBUG_SSDPSerial
#define SSDP_PORT 1900
#define SSDP_BUFFER_SIZE64
#define SSDP_MULTICAST_ADDR 239, 255, 255, 250
static const char _ssdp_response_template[] PROGMEM =
"HTTP/1.1 200 OK\r\n"
"EXT:\r\n";
static const char _dlna_tcpsend_template[] PROGMEM =
"POST /AVTransport/%s/control.xml HTTP/1.1\r\n"
"HOST: %s:%d\r\n"
"CONTENT-LENGTH: %d\r\n"
"CONTENT-TYPE: text/xml; charset=\"utf-8\"\r\n"
"SOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#%s\"\r\n"
"USER-AGENT: Linux/3.3.0, UPnP/1.0, libupnp/1.6.19\r\n"
"\r\n";
static const char _ssdp_search_template[] PROGMEM =
"M-SEARCH * HTTP/1.1\r\n"
"User-Agent: E:\mypy\dlna.py/0.15\r\n"
"HOST: 239.255.255.250:1900\r\n"
"Accept: */*\r\n"
"MAN: \"ssdp:discover\"\r\n"
"ST: %s\r\n"
"MX: 3\r\n"
"\r\n";
static const char_dlna_action_template[] PROGMEM =
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n"
"<s:Body><u:%s xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\">\r\n"
"<InstanceID>0</InstanceID>\r\n"
"<Speed>1</Speed>\r\n"
"</u:%s>\r\n"
"</s:Body>\r\n"
"</s:Envelope>\r\n";
static const char_dlna_playuri_template[] PROGMEM =
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n"
"<s:Body><u:SetAVTransportURI xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\">\r\n"
"<InstanceID>0</InstanceID>\r\n"
"<CurrentURI>%s</CurrentURI>\r\n"
"<CurrentURIMetaData><DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"><item id="123" parentID="-1" restricted="1"><upnp:storageMedium>UNKNOWN</upnp:storageMedium><upnp:writeStatus>UNKNOWN</upnp:writeStatus><upnp:class>object.item.videoItem</upnp:class><dc:title>....-vip.................</dc:title><dc:creator>youku</dc:creator><res protocolInfo="http-get:*:video/mp4:*;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000">%s</res><yunos os="android" ver="4.5.1.151" name="......" pkg="com.quark.browser" proj_mode="NORMAL_2" yk_vid="16062670667400001" yk_showtitle="NULL" yk_showid="NULL" duration="37245330" startpos="0" definition="NULL" /></item></DIDL-Lite></CurrentURIMetaData>\r\n"
"</u:SetAVTransportURI>\r\n"
"</s:Body>\r\n"
"</s:Envelope>\r\n";
SSDPClass::SSDPClass(){
_port=80;
_pending=false;
}
SSDPClass::~SSDPClass() {
end();
}
bool SSDPClass::begin() {
end();
_server = new UdpContext;
_server->ref();
IPAddress local = WiFi.localIP();
IPAddress mcast(SSDP_MULTICAST_ADDR);
if (igmp_joingroup(local, mcast) != ERR_OK ) {
#ifdef DEBUG_SSDP
DEBUG_SSDP.printf_P(PSTR("SSDP failed to join igmp group\n"));
#endif
return false;
}
if (!_server->listen(IP_ADDR_ANY, SSDP_PORT)) {
return false;
}
_server->setMulticastInterface(local);
_server->setMulticastTTL(2);
_server->onRx(std::bind(&SSDPClass::update, this));
if (!_server->connect(mcast, SSDP_PORT)) {
return false;
}
return true;
}
void SSDPClass::end() {
if(!_server)
return;
_server->disconnect();
IPAddress local = WiFi.localIP();
IPAddress mcast(SSDP_MULTICAST_ADDR);
_server->unref();
_server = 0;
}
void SSDPClass::update() {
if (!_pending && _server->next()) {
uint8_t cursor = 0;
uint8_t cr = 0;
char buffer = {0};
bool location = false;
bool server = false ;
bool uuid= false ;
char ip;
uint8_t ip1;
uint8_t ip2;
uint8_t ip3;
uint8_t ip4;
char ipport;
while (_server->getSize() > 0) {
char c = _server->read();
if(strcasecmp(buffer,"serv") == 0){
cursor=0;
do{
c = _server->read();
}while(c != ' ');
do{
c = _server->read();
buffer = c;
buffer ='\0';
}while( c != '\r' && c != '\n' );
for(int i=0;i<strlen(buffer);i++){
buffer = tolower(buffer);
}
if (strstr(buffer,"dlna") > 0){
server = true;
}
}
if(strcasecmp(buffer,"Loca") == 0){
cursor=0;
do{
c = _server->read();
}while(c != ' ');
do{
c = _server->read();
buffer = c;
buffer ='\0';
}while( c != '\r' && c != '\n' );
int j=7;
int k;
do{
ip = buffer;
ip = '\0';
j++;
}while(buffer !='.');
ip1 = atoi(ip);
j++;
k = j;
do{
ip = buffer;
ip ='\0';
j++;
}while(buffer !='.' );
ip2 = atoi(ip);
j++;
k = j;
do{
ip = buffer;
ip ='\0';
j++;
}while(buffer !='.' );
ip3 = atoi(ip);
j++;
k = j;
do{
ip = buffer;
ip ='\0';
j++;
}while(buffer !=':' );
ip4 = atoi(ip);
j++;
k = j;
do{
ipport = buffer;
ipport ='\0';
j++;
}while(buffer !='/' && j < strlen(buffer) );
_remoteAddr = IPAddress(ip1,ip2,ip3,ip4);
_remotePort = atoi(ipport);
location= true;
}
if(strncmp("USN:",buffer,4)==0){
cursor=0;
do{
c = _server->read();
}while(c != ' ');
do{
c = _server->read();
buffer = c;
buffer ='\0';
}while( c != '\r' && c != '\n');
char fuuid;
fuuid = buffer;
fuuid = buffer;
fuuid = buffer;
fuuid = buffer;
fuuid = '\0';
if (strcasecmp(fuuid,"uuid")==0){
for( int a = 0; a < 60; a =a +1 ){
if (buffer != ':' && buffer != '\r' && buffer != '\n' ){
tuuid =buffer;
}else{
tuuid = '\0';
}
}
uuid=true;
}
};
if(cursor < 4){
buffer = c;
buffer = '\0';
}
if(c=='\r' || c=='\n'){
cursor = 0;
}
if (uuid && server && location){
_pending = true;
_havetv = true;
DEBUG_SSDP.printf("location:%d,%d,%d,%d\r\n",ip1,ip2,ip3,ip4);
DEBUG_SSDP.printf("uuid:%s\r\n",(char*)tuuid);
}
}
//_server->flush();
}
if (_pending) {
while (_server->next())
_server->flush();
}
}
void SSDPClass::http_send(){
DEBUG_SSDP.printf("???");
WiFiClient clients;
if (!clients.connect(_remoteAddr,_remotePort)) { // 判断连接情况
DEBUG_SSDP.print("connection failed/r/n");
return;
}
char bui;
char bu;
int len;
//停止
len = snprintf_P(bui, sizeof(bui),
_dlna_action_template,
"Stop",
"Stop"
);
len = snprintf_P(bu, sizeof(bu),
_dlna_tcpsend_template,
tuuid,
_remoteAddr.toString().c_str(),
_remotePort,
len,
"Stop"
);
clients.print(bu);
clients.print(bui);
//uri
len = snprintf_P(bui, sizeof(bui),
_dlna_playuri_template,
"https://youku.com-t-youku.com/20190325/10676_9a90c151/index.m3u8?dlnaopt=2&tpseq=1",
"https://youku.com-t-youku.com/20190325/10676_9a90c151/index.m3u8?dlnaopt=2&tpseq=1"
);
len = snprintf_P(bu, sizeof(bu),
_dlna_tcpsend_template,
tuuid,
_remoteAddr.toString().c_str(),
_remotePort,
len,
"SetAVTransportURI"
);
clients.print(bu);
clients.print(bui);
//播放
len = snprintf_P(bui, sizeof(bui),
_dlna_action_template,
"Play",
"Play"
);
len = snprintf_P(bu, sizeof(bu),
_dlna_tcpsend_template,
tuuid,
_remoteAddr.toString().c_str(),
_remotePort,
len,
"Play"
);
clients.print(bu);
clients.print(bui);
DEBUG_SSDP.print("运行完了,去看看");
DEBUG_SSDP.print("\r\n");
}
void SSDPClass::send() {
DEBUG_SSDP.print("寻找.....\r\n");
char buffer;
IPAddress ip = WiFi.localIP();
IPAddress remoteAddr;
uint16_t remotePort;
remoteAddr = IPAddress(SSDP_MULTICAST_ADDR);
remotePort = SSDP_PORT;
int len = snprintf_P(buffer, sizeof(buffer),
_ssdp_search_template,
"ssdp:all"
);
_server->append(buffer, len);
_server->send(remoteAddr, remotePort);
len = snprintf_P(buffer, sizeof(buffer),
_ssdp_search_template,
"urn:schemas-upnp-org:device:AVTransport:1"
);
_server->append(buffer, len);
_server->send(remoteAddr, remotePort);
len = snprintf_P(buffer, sizeof(buffer),
_ssdp_search_template,
"urn:schemas-upnp-org:device:MediaRenderer:1"
);
_server->append(buffer, len);
_server->send(remoteAddr, remotePort);
len = snprintf_P(buffer, sizeof(buffer),
_ssdp_search_template,
"urn:schemas-upnp-org:device:MediaServer:1"
);
_server->append(buffer, len);
_server->send(remoteAddr, remotePort);
}
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SSDP)
SSDPClass SSDP;
#endif
赞个,怎不配个图
页:
[1]