MCPcopy Create free account
hub / github.com/BruceDevices/firmware / installAppStoreJS

Function installAppStoreJS

src/core/settings.cpp:1683–1731  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1681
1682#include <HTTPClient.h>
1683void installAppStoreJS() {
1684
1685 if (WiFi.status() != WL_CONNECTED) { wifiConnectMenu(WIFI_STA); }
1686 if (WiFi.status() != WL_CONNECTED) {
1687 displayWarning("WiFi not connected", true);
1688 return;
1689 }
1690
1691 FS *fs;
1692 if (!getFsStorage(fs)) {
1693 log_i("Fail getting filesystem");
1694 return;
1695 }
1696
1697 if (!fs->exists("/BruceJS")) {
1698 if (!fs->mkdir("/BruceJS")) {
1699 displayWarning("Failed to create /BruceJS directory", true);
1700 return;
1701 }
1702 }
1703
1704 if (!fs->exists("/BruceJS/Tools")) {
1705 if (!fs->mkdir("/BruceJS/Tools")) {
1706 displayWarning("Failed to create /BruceJS/Tools directory", true);
1707 return;
1708 }
1709 }
1710
1711 HTTPClient http;
1712 http.begin("http://ghp.iceis.co.uk/service/appstore/");
1713 int httpCode = http.GET();
1714 if (httpCode != 200) {
1715 http.end();
1716 displayWarning("Failed to download App Store", true);
1717 return;
1718 }
1719
1720 File file = fs->open("/BruceJS/Tools/App Store.js", FILE_WRITE);
1721 if (!file) {
1722 displayWarning("Failed to save App Store", true);
1723 return;
1724 }
1725 file.print(http.getString());
1726 http.end();
1727 file.close();
1728
1729 displaySuccess("App Store installed", true);
1730 displaySuccess("Goto JS Interpreter -> Tools -> App Store", true);
1731}
1732#endif

Callers 1

optionsMenuMethod · 0.85

Calls 8

wifiConnectMenuFunction · 0.85
displayWarningFunction · 0.85
getFsStorageFunction · 0.85
displaySuccessFunction · 0.85
closeMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected