Difference between revisions of "Troubleshooting unsorted"

From Larnitech wiki page
Jump to navigation Jump to search
m
m
(21 intermediate revisions by the same user not shown)
Line 9: Line 9:
 
history delete old
 
history delete old
 
</syntaxhighlight>
 
</syntaxhighlight>
This will delete the devices' history.
+
This will delete history of connected devices.
  
 
==Registering email with no verification==
 
==Registering email with no verification==
 
testemail@gmail.com.no-check
 
testemail@gmail.com.no-check
if there is ".no-check" in the email address it will not send email for vefirication
+
if there is ".no-check" in the email address it will not send email for vefirication
  
==Alice== <!--T:3-->
+
==Alice==
 
https://dialogs.yandex.ru/store/skills/f636b340-larnitech
 
https://dialogs.yandex.ru/store/skills/f636b340-larnitech
  
 
==Upload backup from server A to server B==
 
==Upload backup from server A to server B==
# Save backup on A;
+
# Save backup on server A;
 
# Download it;
 
# Download it;
 
# Switch module ID on server B to A's ID;
 
# Switch module ID on server B to A's ID;
Line 26: Line 26:
 
# Switch server mode to 'Gateway';
 
# Switch server mode to 'Gateway';
 
# Upload backup to B and restore it;
 
# Upload backup to B and restore it;
# Switch sn="xxxxxxxx" on B in logic.xml to the sn from p.4
+
# Switch sn="xxxxxxxx" on B in logic.xml to the sn from p.4;
 +
# Switch back server mode to 'Default'
  
==Узнать пароль от LT_Setup==
+
==Find out password from LT_Setup==
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
sqlite3 /home/settings/db/larnitech.db
 
sqlite3 /home/settings/db/larnitech.db
 
select * from accounts;
 
select * from accounts;
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
==Control valve-heating from script==
 +
<syntaxhighlight lang="C">
 +
sprintf(strCommand, "%03d:%03d0ts:%d",ID, SID, setpoint);
 +
strCommand[7]=0;
 +
setStatus(1000:102, &strCommand);
 +
</syntaxhighlight>
 +
 +
==Bluetooth==
 +
# Connect the module.
 +
# Find item in logic with type="json".
 +
# Add sub-type="btunreg" json item.
 +
# Turn on "Edit mode" in the app.
 +
# Connect BT device from menu-> setup-> Bluetooth.
 +
 +
==No modules in lt_setup after reset to factory defaults via web on the new (3.xx) lt_setup==
 +
'''You need to be very carefully. If any errors in the file system - it will not boot and you will need to send the device to repair!'''<br>
 +
Send command <code>bootrw</code>, then <code>bootro</code>.<br>
 +
Edit /boot/config.txt with data from another server, where all works correctly.
 +
 +
==How to add http-API2 converter==
 +
# Create folder /home/html/api_v2.
 +
# Put the file (index.php) into the folder.
 +
# Enable API in LTsetup
 +
# Request example: <nowiki>http://192.168.67.154/api_v2/?{"request":"status-get","addr":"395:14","API-KEY":"08283242722612433"}</nowiki>
 +
<div class="mw-collapsible mw-collapsed" style="width:800px">
 +
<center>'''index.php'''</center>
 +
<div class="mw-collapsible-content">
 +
<syntaxhighlight lang="php">
 +
<?php
 +
 +
function api_send($sock, $req) {
 +
    $r = '-JSON-'.$req;
 +
    return fwrite($sock, pack('I', strlen($r)) . $r);
 +
}
 +
 +
function api_recv($sock) {
 +
    $s = fread($sock, 4);
 +
    $size = unpack("I", $s)[1];
 +
    $data = fread($sock, $size);
 +
    if (strpos($data, '"error"')) {
 +
die(substr($data, 7));
 +
    }
 +
    return substr($data, 7);
 +
}
 +
 +
$headers = apache_request_headers();
 +
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
 +
    $post = file_get_contents('php://input');
 +
} else {
 +
    $post = urldecode($_SERVER['QUERY_STRING']);
 +
}
 +
 +
if (!isset($headers['API-KEY'])) { // API key not found in header, Checking request
 +
    $req = json_decode($post, true);
 +
    if (!isset($req['API-KEY'])) die('No API-KEY provided');
 +
    $key = $req['API-KEY'];
 +
    unset($req['API-KEY']);
 +
    $post = json_encode($req);
 +
} else $key = $headers['API-KEY'];
 +
 +
$sock = stream_socket_client('unix:///tmp/sh.socket', $errno, $errst);
 +
$auth_req = '{"request": "authorize","key": "'.$key.'"}';
 +
api_send($sock, $auth_req);
 +
api_recv($sock);
 +
api_send($sock, $post);
 +
echo api_recv($sock);
 +
fclose($sock);
 +
</syntaxhighlight>
 +
</div>
 +
</div>

Revision as of 07:36, 14 February 2022

Disk usage error

Check what folder is full:

cd /storage
du -h -d 1

If folder is /storage/history, then write in screen:

history delete old

This will delete history of connected devices.

Registering email with no verification

testemail@gmail.com.no-check if there is ".no-check" in the email address it will not send email for vefirication

Alice

https://dialogs.yandex.ru/store/skills/f636b340-larnitech

Upload backup from server A to server B

  1. Save backup on server A;
  2. Download it;
  3. Switch module ID on server B to A's ID;
  4. Copy and save somewhere B server's sn from logic->hw;
  5. Install needed plugins;
  6. Switch server mode to 'Gateway';
  7. Upload backup to B and restore it;
  8. Switch sn="xxxxxxxx" on B in logic.xml to the sn from p.4;
  9. Switch back server mode to 'Default'

Find out password from LT_Setup

sqlite3 /home/settings/db/larnitech.db
select * from accounts;

Control valve-heating from script

sprintf(strCommand, "%03d:%03d0ts:%d",ID, SID, setpoint);
strCommand[7]=0;
setStatus(1000:102, &strCommand);

Bluetooth

  1. Connect the module.
  2. Find item in logic with type="json".
  3. Add sub-type="btunreg" json item.
  4. Turn on "Edit mode" in the app.
  5. Connect BT device from menu-> setup-> Bluetooth.

No modules in lt_setup after reset to factory defaults via web on the new (3.xx) lt_setup

You need to be very carefully. If any errors in the file system - it will not boot and you will need to send the device to repair!
Send command bootrw, then bootro.
Edit /boot/config.txt with data from another server, where all works correctly.

How to add http-API2 converter

  1. Create folder /home/html/api_v2.
  2. Put the file (index.php) into the folder.
  3. Enable API in LTsetup
  4. Request example: http://192.168.67.154/api_v2/?{"request":"status-get","addr":"395:14","API-KEY":"08283242722612433"}
index.php
<?php

function api_send($sock, $req) {
    $r = '-JSON-'.$req;
    return fwrite($sock, pack('I', strlen($r)) . $r);
}

function api_recv($sock) {
    $s = fread($sock, 4);
    $size = unpack("I", $s)[1];
    $data = fread($sock, $size);
    if (strpos($data, '"error"')) {
	die(substr($data, 7));
    }
    return substr($data, 7);
}

$headers = apache_request_headers();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $post = file_get_contents('php://input');
} else {
    $post = urldecode($_SERVER['QUERY_STRING']);
}

if (!isset($headers['API-KEY'])) { // API key not found in header, Checking request
    $req = json_decode($post, true);
    if (!isset($req['API-KEY'])) die('No API-KEY provided');
    $key = $req['API-KEY'];
    unset($req['API-KEY']);
    $post = json_encode($req);
} else $key = $headers['API-KEY'];

$sock = stream_socket_client('unix:///tmp/sh.socket', $errno, $errst);
$auth_req = '{"request": "authorize","key": "'.$key.'"}';
api_send($sock, $auth_req);
api_recv($sock);
api_send($sock, $post);
echo api_recv($sock);
fclose($sock);