Skip to content

Commit 7fcd64d

Browse files
committed
Merge branch 'master' of github.com:domoticz/domoticz
2 parents 0c4d288 + a1d9cf1 commit 7fcd64d

File tree

6 files changed

+108
-3
lines changed

6 files changed

+108
-3
lines changed

hardware/BleBox.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,50 @@ namespace http {
766766
pHardware->RemoveAllNodes();
767767
}
768768

769+
void CWebServer::Cmd_BleBoxAutoSearchingNodes(WebEmSession & session, const request& req, Json::Value &root)
770+
{
771+
if (session.rights != 2)
772+
{
773+
session.reply_status = reply::forbidden;
774+
return; //Only admin user allowed
775+
}
776+
777+
std::string hwid = request::findValue(&req, "idx");
778+
std::string ipmask = request::findValue(&req, "ipmask");
779+
if (
780+
(hwid == "") ||
781+
(ipmask == "")
782+
)
783+
return;
784+
CDomoticzHardwareBase *pBaseHardware = m_mainworker.GetHardwareByIDType(hwid, HTYPE_BleBox);
785+
if (pBaseHardware == NULL)
786+
return;
787+
BleBox *pHardware = reinterpret_cast<BleBox*>(pBaseHardware);
788+
789+
root["status"] = "OK";
790+
root["title"] = "BleBoxAutoSearchingNodes";
791+
/* pHardware->xyz();*/ // TODO
792+
}
793+
794+
void CWebServer::Cmd_BleBoxUpdateFirmware(WebEmSession & session, const request& req, Json::Value &root)
795+
{
796+
if (session.rights != 2)
797+
{
798+
session.reply_status = reply::forbidden;
799+
return; //Only admin user allowed
800+
}
801+
802+
std::string hwid = request::findValue(&req, "idx");
803+
CDomoticzHardwareBase *pBaseHardware = m_mainworker.GetHardwareByIDType(hwid, HTYPE_BleBox);
804+
if (pBaseHardware == NULL)
805+
return;
806+
BleBox *pHardware = reinterpret_cast<BleBox*>(pBaseHardware);
807+
808+
root["status"] = "OK";
809+
root["title"] = "BleBoxUpdateFirmware";
810+
pHardware->UpdateFirmware();
811+
}
812+
769813
}
770814
}
771815

@@ -926,3 +970,12 @@ void BleBox::ReloadNodes()
926970
LoadNodes();
927971
}
928972

973+
void BleBox::UpdateFirmware()
974+
{
975+
std::map<const std::string, const int>::const_iterator itt;
976+
for (itt = m_devices.begin(); itt != m_devices.end(); ++itt)
977+
{
978+
Json::Value root = SendCommand(itt->first, "/api/ota/update");
979+
}
980+
}
981+

hardware/BleBox.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class BleBox : public CDomoticzHardwareBase
3131
void RemoveAllNodes();
3232
void SetSettings(const int pollIntervalsec);
3333
void Restart();
34+
void UpdateFirmware();
3435

3536
private:
3637
volatile bool m_stoprequested;

main/WebServer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,8 @@ namespace http {
405405
RegisterCommandCode("bleboxupdatenode", boost::bind(&CWebServer::Cmd_BleBoxUpdateNode, this, _1, _2, _3));
406406
RegisterCommandCode("bleboxremovenode", boost::bind(&CWebServer::Cmd_BleBoxRemoveNode, this, _1, _2, _3));
407407
RegisterCommandCode("bleboxclearnodes", boost::bind(&CWebServer::Cmd_BleBoxClearNodes, this, _1, _2, _3));
408+
RegisterCommandCode("bleboxautosearchingnodes", boost::bind(&CWebServer::Cmd_BleBoxAutoSearchingNodes, this, _1, _2, _3));
409+
RegisterCommandCode("bleboxupdatefirmware", boost::bind(&CWebServer::Cmd_BleBoxUpdateFirmware, this, _1, _2, _3));
408410

409411
RegisterCommandCode("lmssetmode", boost::bind(&CWebServer::Cmd_LMSSetMode, this, _1, _2, _3));
410412
RegisterCommandCode("lmsgetnodes", boost::bind(&CWebServer::Cmd_LMSGetNodes, this, _1, _2, _3));

main/WebServer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,9 @@ class CWebServer : public session_store, public boost::enable_shared_from_this<C
258258
void Cmd_BleBoxUpdateNode(WebEmSession & session, const request& req, Json::Value &root);
259259
void Cmd_BleBoxRemoveNode(WebEmSession & session, const request& req, Json::Value &root);
260260
void Cmd_BleBoxClearNodes(WebEmSession & session, const request& req, Json::Value &root);
261-
261+
void Cmd_BleBoxAutoSearchingNodes(WebEmSession & session, const request& req, Json::Value &root);
262+
void Cmd_BleBoxUpdateFirmware(WebEmSession & session, const request& req, Json::Value &root);
263+
262264
void Cmd_GetTimerPlans(WebEmSession & session, const request& req, Json::Value &root);
263265
void Cmd_AddTimerPlan(WebEmSession & session, const request& req, Json::Value &root);
264266
void Cmd_UpdateTimerPlan(WebEmSession & session, const request& req, Json::Value &root);

www/app/HardwareController.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2884,6 +2884,41 @@ define(['app'], function (app) {
28842884
});
28852885
}
28862886

2887+
BleBoxAutoSearchingNodes = function () {
2888+
2889+
var ipmask = $("#hardwarecontent #bleboxsettingstable #ipmask").val();
2890+
if (ipmask == "") {
2891+
ShowNotify($.t('Please enter a mask!'), 2500, true);
2892+
return;
2893+
}
2894+
2895+
$.ajax({
2896+
url: "json.htm?type=command&param=bleboxautosearchingnodes" +
2897+
"&idx=" + $.devIdx +
2898+
"&ipmask=" + ipmask,
2899+
async: false,
2900+
dataType: 'json',
2901+
success: function (data) {
2902+
RefreshBleBoxNodeTable();
2903+
}
2904+
});
2905+
}
2906+
2907+
BleBoxUpdateFirmware = function () {
2908+
2909+
ShowNotify($.t('Please wait. Updating ....!'), 2500, true);
2910+
2911+
$.ajax({
2912+
url: "json.htm?type=command&param=bleboxupdatefirmware" +
2913+
"&idx=" + $.devIdx,
2914+
async: false,
2915+
dataType: 'json',
2916+
success: function (data) {
2917+
RefreshBleBoxNodeTable();
2918+
}
2919+
});
2920+
}
2921+
28872922
BleBoxUpdateNode = function (nodeid) {
28882923
if ($('#updelclr #nodedelete').attr("class") == "btnstyle3-dis") {
28892924
return;
@@ -3016,6 +3051,7 @@ define(['app'], function (app) {
30163051

30173052
$("#hardwarecontent #bleboxsettingstable #pollinterval").val(Mode1);
30183053
$("#hardwarecontent #bleboxsettingstable #pingtimeout").val(Mode2);
3054+
$("#hardwarecontent #bleboxsettingstable #ipmask").val("192.168.1.*");
30193055

30203056
var oTable = $('#bleboxnodestable').dataTable({
30213057
"sDom": '<"H"lfrC>t<"F"ip>',
@@ -5201,7 +5237,7 @@ define(['app'], function (app) {
52015237
$("#hardwarecontent #divhttppoller").hide();
52025238
if (text.indexOf("Open Weather Map") >= 0)
52035239
{
5204-
$("#hardwarecontent #hardwareparamsunderground #location").val("lat=53.40&lon=14.58");
5240+
$("#hardwarecontent #hardwareparamsunderground #location").val(data["Password"]);
52055241
}
52065242
}
52075243
else if (text.indexOf("Philips Hue") >= 0)

www/views/hardware.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,14 @@ <h1 data-i18n="Settings">Settings</h1>
632632
<td></td>
633633
<td><a class="btn-danger sub-tabs-apply" onclick="SetBleBoxSettings();" data-i18n="Apply Settings">Apply Settings</a></td>
634634
</tr>
635+
<tr>
636+
<td align="left" style="width:110px">
637+
<a align="left" class="btnstyle3" id="autosearching" data-i18n="AutoSearching" onclick="BleBoxAutoSearchingNodes();">Auto Searching on:</a>
638+
</td>
639+
<td>
640+
<input type="text" id="ipmask" style="width: 120px; padding: .2em;" class="text ui-widget-content ui-corner-all" />
641+
</td>
642+
</tr>
635643
</table>
636644
<div class="page-header-small">
637645
<table border="0" cellpadding="0" cellspacing="0" width="100%">
@@ -657,7 +665,10 @@ <h1 data-i18n="Nodes">Nodes</h1>
657665
<tr>
658666
<td>
659667
<a class="btnstyle3-dis" id="nodeupdate" data-i18n="Update">Update</a>&nbsp;&nbsp;&nbsp;
660-
<a class="btnstyle3-dis" id="nodedelete" data-i18n="Delete">Delete</a>
668+
<a class="btnstyle3-dis" id="nodedelete" data-i18n="Delete">Delete</a>&nbsp;&nbsp;&nbsp;
669+
</td>
670+
<td align="right" style="width:200px">
671+
<a align="left" class="btnstyle3" id="updatefirmware" data-i18n="Update devices firmware" onclick="BleBoxUpdateFirmware();">Update devices firmware</a>
661672
</td>
662673
<td align="right">
663674
<a class="btnstyle3" id="nodelistrefresh" data-i18n="Clear" onclick="BleBoxClearNodes();">Clear</a>

0 commit comments

Comments
 (0)