| 751 | } |
| 752 | |
| 753 | bool DisplayManager_::generateNotification(uint8_t source, const char *json) |
| 754 | { |
| 755 | // source: 0=MQTT, 1=HTTP |
| 756 | DynamicJsonDocument doc(6144); |
| 757 | DeserializationError error = deserializeJson(doc, json); |
| 758 | if (error) |
| 759 | { |
| 760 | DEBUG_PRINTLN(error.c_str()); |
| 761 | doc.clear(); |
| 762 | return false; |
| 763 | } |
| 764 | |
| 765 | Notification newNotification; |
| 766 | |
| 767 | newNotification.progress = doc.containsKey("progress") ? doc["progress"].as<int>() : -1; |
| 768 | |
| 769 | if (doc.containsKey("progressC")) |
| 770 | { |
| 771 | auto progressC = doc["progressC"]; |
| 772 | newNotification.pColor = getColorFromJsonVariant(progressC, 0x00FF00); |
| 773 | } |
| 774 | else |
| 775 | { |
| 776 | newNotification.pColor = 0x00FF00; |
| 777 | } |
| 778 | |
| 779 | if (doc.containsKey("progressBC")) |
| 780 | { |
| 781 | auto progressBC = doc["progressBC"]; |
| 782 | newNotification.pbColor = getColorFromJsonVariant(progressBC, 0xFFFFFF); |
| 783 | } |
| 784 | else |
| 785 | { |
| 786 | newNotification.pbColor = 0xFFFFFF; |
| 787 | } |
| 788 | |
| 789 | if (doc.containsKey("background")) |
| 790 | { |
| 791 | auto background = doc["background"]; |
| 792 | newNotification.background = getColorFromJsonVariant(background, 0); |
| 793 | } |
| 794 | else |
| 795 | { |
| 796 | newNotification.background = 0x000000; |
| 797 | } |
| 798 | |
| 799 | if (doc.containsKey("draw")) |
| 800 | { |
| 801 | newNotification.drawInstructions = doc["draw"].as<String>(); |
| 802 | } |
| 803 | else |
| 804 | { |
| 805 | newNotification.drawInstructions = ""; |
| 806 | } |
| 807 | |
| 808 | if (doc.containsKey("effect")) |
| 809 | { |
| 810 | newNotification.effect = getEffectIndex(doc["effect"].as<String>()); |
no test coverage detected