Skip to content

Commit

Permalink
新版本app仅支持从mdns获取设备信息
Browse files Browse the repository at this point in the history
  • Loading branch information
matteriot committed Oct 18, 2019
1 parent abb4f15 commit bc8e43b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
4 changes: 3 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@
platform = espressif8266
board = d1
framework = arduino

upload_speed = 921600
lib_deps =
[email protected]
33 changes: 13 additions & 20 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,24 +159,6 @@ void handleCurrentLEDStatus(){
",\"code\":0,\"message\":\"success\"}";
server.send(200, "application/json", message);
}
// 设备信息
void handleDeviceInfo(){
String message;
message = "{\n";
message += "\"name\":\""+deviceName +"\",\n";
message += "\"model\":\"com.iotserv.devices.phicomm_dc1\",\n";
message += "\"mac\":\""+WiFi.macAddress()+"\",\n";
message += "\"id\":\""+String(ESP.getFlashChipId())+"\",\n";
message += "\"ui-support\":[\"web\",\"native\"],\n";
message += "\"ui-first\":\"native\",\n";
message += "\"author\":\"Farry\",\n";
message += "\"email\":\"[email protected]\",\n";
message += "\"home-page\":\"https://github.com/iotdevice\",\n";
message += "\"firmware-respository\":\"https://github.com/iotdevice/phicomm_dc1\",\n";
message += "\"firmware-version\":\""+version+"\"\n";
message +="}";
server.send(200, "application/json", message);
}

// 页面或者api没有找到
void handleNotFound(){
Expand Down Expand Up @@ -248,12 +230,23 @@ void setup(void){
// Serial.println("MDNS responder started");
}

MDNS.addService("iotdevice", "tcp", httpPort);
MDNS.addServiceTxt("iotdevice", "tcp", "name", deviceName);
MDNS.addServiceTxt("iotdevice", "tcp", "model", "com.iotserv.devices.phicomm_dc1");
MDNS.addServiceTxt("iotdevice", "tcp", "mac", WiFi.macAddress());
MDNS.addServiceTxt("iotdevice", "tcp", "id", ESP.getSketchMD5());
MDNS.addServiceTxt("iotdevice", "tcp", "ui-support", "web,native");
MDNS.addServiceTxt("iotdevice", "tcp", "ui-first", "native");
MDNS.addServiceTxt("iotdevice", "tcp", "author", "Farry");
MDNS.addServiceTxt("iotdevice", "tcp", "email", "[email protected]");
MDNS.addServiceTxt("iotdevice", "tcp", "home-page", "https://github.com/iotdevice");
MDNS.addServiceTxt("iotdevice", "tcp", "firmware-respository", "https://github.com/iotdevice/phicomm_dc1");
MDNS.addServiceTxt("iotdevice", "tcp", "firmware-version", version);

server.on("/", handleRoot);
server.on("/switch", handleSwitchStatusChange);
server.on("/rename", handleDeviceRename);
server.on("/status", handleCurrentLEDStatus);
// about this device
server.on("/info", handleDeviceInfo);

server.on("/cse7766", handleCSE7766);

Expand Down

0 comments on commit bc8e43b

Please sign in to comment.