add set default name

This commit is contained in:
pvvx 2024-02-06 10:46:28 +03:00
parent f47d7540fe
commit ed6e678176
8 changed files with 6165 additions and 6142 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -189,10 +189,14 @@ int cmd_parser(uint8_t * obuf, uint8_t * ibuf, uint32_t len) {
olen = MAC_LEN + 1;
} else if (cmd == CMD_ID_DNAME) {
if (len > 1 && len < B_MAX_ADV_LEN - 2) {
len--;
memcpy(&gapRole_ScanRspData[2], &ibuf[1], len);
flash_write_cfg(&gapRole_ScanRspData[2], EEP_ID_DVN, len);
set_dev_name();
if(ibuf[1] == 0)
set_def_name();
else {
len--;
memcpy(&gapRole_ScanRspData[2], &ibuf[1], len);
flash_write_cfg(&gapRole_ScanRspData[2], EEP_ID_DVN, len);
set_dev_name();
}
}
olen = gapRole_ScanRspData[0];
memcpy(&obuf[1], &gapRole_ScanRspData[2], olen - 1);

View file

@ -1400,8 +1400,7 @@ function customBlkParse(value) {
addLog(s); // UpdCmf();
} else if(blkId == 0x01 && len >= 1) {
devnm.name = new TextDecoder("utf-8").decode(value.buffer.slice(1));
//if($("dev_name"))
// $("dev_name").value = dnm.name;
$("inpDevName").value = devnm.name;
addLog("Имя устройства: '"+devnm.name+"'");
} else if(blkId == 0x10 && len > 6) {
let mac = new Uint8Array(6);
@ -1644,6 +1643,31 @@ function setTrgCfg() {
}
}
function getDevName() {
if(cmdCharacteristic != null) {
cmdCharacteristic.writeValue(new Uint8Array([0x01])).catch(error => { console.log(error); addLog("getDevName() error!"); });
}
}
function setDevName(flg) {
if(cmdCharacteristic != null) {
if(flg != 0) {
let eltxt = $("inpDevName").value;
let len = eltxt.length;
if(len > 1 && len < 20) {
let blk = new Uint8Array(1 + len);
blk[0] = 0x01;
blk.set((new TextEncoder()).encode(eltxt), 1);
console.log(blk);
cmdCharacteristic.writeValue(blk).catch(error => { console.log(error); addLog("setDevName() error!"); });
} else
addLog("Имя устройства должно быть от 1 до 19 символов!");
} else
cmdCharacteristic.writeValue(new Uint8Array([0x01, 0])).catch(error => { console.log(error); addLog("setDevName() error!"); });
}
}
function readFile(file) {
var reader = new FileReader();
@ -1918,20 +1942,6 @@ function ShowGrf(temp, humi) {
</tr>
</table>
<br>
<!--
Поправочные коэффициенты:
Температуры: <input size="8" type="text" id="inputTempK" maxlength="8">
Влажности:
<br>
Коррекция смещения:
Температуры: <input size="8" type="text" id="inputTempZ" maxlength="8">
Влажности: <input size="8" type="text" id="inputHumZ" maxlength="8">
<br>
Параметры I2C<br>
Vendor: <input size="4" type="text" id="inputI2CVen" maxlength="4">
Model: <input size="4" type="text" id="inputI2CMod" maxlength="4">
Address: <input size="2" type="text" id="inputI2CAddr" maxlength="2">
<br> -->
<button type="button"id="btnGetSens" onclick="getSensCfg()">Прочитать</button>
<button type="button"id="btnSetSens" onclick="setSensCfg()">Записать</button><br>
<hr>
@ -1947,10 +1957,10 @@ function ShowGrf(temp, humi) {
<table id="tbTrigger" disabled="true">
<tr>
<td>Триггер: </td>
<td>Температура: <input size="4" type="text" id="inputTempThr" maxlength="8" title="Температура переключения"> °C, </td>
<td>Влажность: <input size="4" type="text" id="inputHumiThr" maxlength="8" title="Влажность переключения"> %RH, </td>
<td>Гистерезис: <input size="4" type="text" id="inputTempHsr" maxlength="8" title="Гистерезис температуры"> °C</td>
<td><input size="4" type="text" id="inputHumiHsr" maxlength="8" title="Гистерезис влажности"> %RH, </td>
<td>Температура: <input size="4" type="text" id="inputTempThr" maxlength="8" title="Порог температуры"> °C, </td>
<td>Влажность: <input size="4" type="text" id="inputHumiThr" maxlength="8" title="Порог влажности"> %RH, </td>
<td>Гистерезис: <input size="4" type="text" id="inputTempHsr" maxlength="8" title="Гистерезис температуры, если =0 - обработка отключена, если отрицательный - выход включен при температуре менее заданной (нагреватель)"> °C</td>
<td><input size="4" type="text" id="inputHumiHsr" maxlength="8" title="Гистерезис влажности, если =0 - обработка отключена, если отрицательный - выход включен при влажности менее заданной (увлажнитель)"> %RH, </td>
<td>Инверсия вывода <input type="checkbox" id="chbInvOut"></td>
<td>
</tr>
@ -2004,10 +2014,18 @@ function ShowGrf(temp, humi) {
<hr>
<table>
<tr>
<!--- <td style="width:100px;">MAC:</td> --->
<td><button type="button" id="btnGetDevMAC" onclick="getDevMAC()" style="width:120px;">Прочитать MAC</button></td>
<td><button type="button" id="btnGetDevMAC" onclick="getDevMAC()">Прочитать MAC</button></td>
<td><input type="text" id="inpDevMAC" value="?" maxlength="16"></td>
<td><button type="button" id="btnSetDevMAC" onclick="setDevMAC()" style="width:120px;">Записать MAC</button></td>
<td><button type="button" id="btnSetDevMAC" onclick="setDevMAC()">Записать MAC</button></td>
</tr>
</table>
<hr>
<table>
<tr>
<td><button type="button" id="btnGetDevName" onclick="getDevName()">Прочитать имя устройства</button></td>
<td><input type="text" id="inpDevName" value="" maxlength="19"></td>
<td><button type="button" id="btnSetDevMAC" onclick="setDevName(1)">Записать имя устройства</button></td>
<td><button type="button" id="btnSetDevMAC" onclick="setDevName(0)">Установить имя устройства по молчанию</button></td>
</tr>
</table>
</div>