mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-04-20 19:12:13 +02:00
replace Serial.print with logger
This commit is contained in:
parent
f38dcea1f1
commit
a220b9ecc2
13 changed files with 397 additions and 562 deletions
29
src/SSDP.cpp
29
src/SSDP.cpp
|
|
@ -1,5 +1,6 @@
|
|||
#include <functional>
|
||||
#include <AsyncUDP.h>
|
||||
#include "esp_log.h"
|
||||
#include "Utils.h"
|
||||
#include "ConfigSettings.h"
|
||||
#include "SSDP.h"
|
||||
|
|
@ -12,6 +13,7 @@
|
|||
#define SSDP_MULTICAST_ADDR 239, 255, 255, 250
|
||||
//#define DEBUG_SSDP Serial
|
||||
//#define DEBUG_SSDP_PACKET Serial
|
||||
static const char *TAG = "SSDP";
|
||||
extern ConfigSettings settings;
|
||||
|
||||
static const char _ssdp_uuid_template[] PROGMEM = "C2496952-5610-47E6-A968-2FC1%02X%02X%02X%02X";
|
||||
|
|
@ -193,12 +195,12 @@ bool SSDPClass::begin() {
|
|||
return false;
|
||||
}
|
||||
for(uint8_t i = 0; i < this->m_cdeviceTypes; i++) {
|
||||
Serial.printf("SSDP: %s - %s\n", this->deviceTypes[i].deviceType, this->deviceTypes[i].isActive ? "true" : "false");
|
||||
ESP_LOGI(TAG, "SSDP: %s - %s", this->deviceTypes[i].deviceType, this->deviceTypes[i].isActive ? "true" : "false");
|
||||
}
|
||||
this->isStarted = true;
|
||||
this->_sendByeBye();
|
||||
this->_sendNotify();
|
||||
Serial.println("Connected to SSDP...");
|
||||
ESP_LOGI(TAG, "Connected to SSDP...");
|
||||
return true;
|
||||
}
|
||||
void SSDPClass::end() {
|
||||
|
|
@ -209,7 +211,7 @@ void SSDPClass::end() {
|
|||
if(this->_server.connected()) {
|
||||
this->_sendByeBye();
|
||||
this->_server.close();
|
||||
Serial.println("Disconnected from SSDP...");
|
||||
ESP_LOGI(TAG, "Disconnected from SSDP...");
|
||||
}
|
||||
this->isStarted = false;
|
||||
// Clear out the last notified so if the user starts us up again it will notify
|
||||
|
|
@ -432,7 +434,7 @@ void SSDPClass::_sendResponse(IPAddress addr, uint16_t port, const char *buff) {
|
|||
void SSDPClass::_sendNotify() {
|
||||
for(uint8_t i = 0; i < this->m_cdeviceTypes; i++) {
|
||||
UPNPDeviceType *dev = &this->deviceTypes[i];
|
||||
if(i == 0 && (strlen(dev->deviceType) == 0 || !dev->isActive)) Serial.printf("The device type is empty: %s\n", dev->isActive ? "true" : "false");
|
||||
if(i == 0 && (strlen(dev->deviceType) == 0 || !dev->isActive)) ESP_LOGD(TAG, "The device type is empty: %s", dev->isActive ? "true" : "false");
|
||||
if(strlen(dev->deviceType) > 0 && dev->isActive) {
|
||||
unsigned long elapsed = (millis() - dev->lastNotified);
|
||||
if(!dev->lastNotified || (elapsed * 5) > (this->_interval * 1000)) {
|
||||
|
|
@ -653,28 +655,23 @@ void SSDPClass::_sendQueuedResponses() {
|
|||
}
|
||||
}
|
||||
void SSDPClass::_printPacket(ssdp_packet_t *pkt) {
|
||||
Serial.printf("Rec: %lu\n", pkt->recvd);
|
||||
ESP_LOGD(TAG, "Rec: %lu", pkt->recvd);
|
||||
switch(pkt->method) {
|
||||
case NONE:
|
||||
Serial.println("Method: NONE");
|
||||
ESP_LOGD(TAG, "Method: NONE");
|
||||
break;
|
||||
case SEARCH:
|
||||
Serial.println("Method: SEARCH");
|
||||
ESP_LOGD(TAG, "Method: SEARCH");
|
||||
break;
|
||||
case NOTIFY:
|
||||
Serial.println("Method: NOTIFY");
|
||||
ESP_LOGD(TAG, "Method: NOTIFY");
|
||||
break;
|
||||
default:
|
||||
Serial.println("Method: UNKOWN");
|
||||
ESP_LOGD(TAG, "Method: UNKNOWN");
|
||||
break;
|
||||
}
|
||||
Serial.printf("ST: %s\n", pkt->st);
|
||||
Serial.printf("MAN: %s\n", pkt->man);
|
||||
Serial.printf("AGENT: %s\n", pkt->agent);
|
||||
Serial.printf("HOST: %s\n", pkt->host);
|
||||
Serial.printf("MX: %d\n", pkt->mx);
|
||||
Serial.printf("type: %d\n", pkt->type);
|
||||
Serial.printf("valid: %d\n", pkt->valid);
|
||||
ESP_LOGD(TAG, "ST: %s MAN: %s AGENT: %s HOST: %s MX: %d type: %d valid: %d",
|
||||
pkt->st, pkt->man, pkt->agent, pkt->host, pkt->mx, pkt->type, pkt->valid);
|
||||
}
|
||||
void SSDPClass::_processRequest(AsyncUDPPacket &p) {
|
||||
// This pending BS should probably be for unicast request only but we will play along for now.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue