| 525 | } |
| 526 | |
| 527 | void DDPServer::handleQuery(const DDPHeader& header, uint8_t* payload, uint16_t payloadSize) |
| 528 | { |
| 529 | DDPPacket ddpReply; |
| 530 | String ddpReplyPayload; |
| 531 | |
| 532 | (void)payload; |
| 533 | (void)payloadSize; |
| 534 | |
| 535 | /* Prepare reply in general */ |
| 536 | setVersion(ddpReply.header, PROTOCOL_VERSION); |
| 537 | setReplyFlag(ddpReply.header); |
| 538 | setPushFlag(ddpReply.header); |
| 539 | ddpReply.header.detail.id = header.detail.id; |
| 540 | |
| 541 | /* Discovery? */ |
| 542 | if (DDP_ID_JSON_STATUS == header.detail.id) |
| 543 | { |
| 544 | ddpReplyPayload = "{\"status\":{"; |
| 545 | |
| 546 | ddpReplyPayload += "\"man\":\"" + m_deviceManufacturer + "\","; |
| 547 | ddpReplyPayload += "\"mod\":\"" + m_deviceModel + "\","; |
| 548 | ddpReplyPayload += "\"ver\":\"" + m_deviceVersion + "\","; |
| 549 | ddpReplyPayload += "\"mac\":\"" + m_deviceMac + "\","; |
| 550 | ddpReplyPayload += "\"push\":false,"; |
| 551 | ddpReplyPayload += "\"ntp\":false"; |
| 552 | |
| 553 | ddpReplyPayload += "}}"; |
| 554 | |
| 555 | setPayloadSize(ddpReply.header, ddpReplyPayload.length()); |
| 556 | ddpReply.data = reinterpret_cast<const uint8_t*>(ddpReplyPayload.c_str()); |
| 557 | } |
| 558 | /* Query not supported. */ |
| 559 | else |
| 560 | { |
| 561 | /* Nothing to do, because offset and length are already 0. */ |
| 562 | ; |
| 563 | } |
| 564 | |
| 565 | (void)send(ddpReply); |
| 566 | } |
| 567 | |
| 568 | void DDPServer::handleData(const DDPHeader& header, uint8_t* payload, uint16_t payloadSize) |
| 569 | { |