Skip to content

Commit

Permalink
Update timeouts and RSSI threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
vshymanskyy committed May 16, 2024
1 parent 269adcf commit d21ad5b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
10 changes: 6 additions & 4 deletions BlynkNCP.jidl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"module": "Blynk.NCP",
"@version": "0.6.2",
"@version": "0.6.4",
"@author": "Volodymyr Shymanskyy",
"@license": "Apache-2.0",
"@output_dir": "./src/idl",
Expand Down Expand Up @@ -194,8 +194,9 @@
"returns": "Bool"
},
"otaUpdatePrefetch": {
"returns": "UInt8",
"@timeout": 30000
"@doc": "Prefetch the firmware file, to reduce the risk of download failure",
"@timeout": 30000,
"returns": "UInt8"
},

"factoryReset": {
Expand All @@ -211,7 +212,7 @@
"returns": "UInt8"
},
"factoryTestWiFi": {
"@timeout": 15000,
"@timeout": 30000,
"args": [
{ "ssid": "String" },
{ "pass": "String" },
Expand Down Expand Up @@ -298,6 +299,7 @@
"args": [ { "event": "UInt8" } ]
},
"otaUpdateAvailable": {
"@timeout": 5000,
"args": [
{ "filename": "String" },
{ "filesize": "UInt32" },
Expand Down
2 changes: 1 addition & 1 deletion docs/Factory Testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Perform a connection to the specified WiFi 2.4 Ghz hotspot.
**Returns:** `RpcFactoryTestStatus`
- `RPC_FACTORY_TEST_INVALID_ARGS` - call is incorrect
- `RPC_FACTORY_TEST_WIFI_FAIL` - cannot connect
- `RPC_FACTORY_TEST_LOW_RSSI` - RSSI is **less than -70 dBm**
- `RPC_FACTORY_TEST_LOW_RSSI` - RSSI is **less than -85 dBm**
- `RPC_FACTORY_TEST_OK` - all is OK

## `rpc_blynk_factoryTestConnect()`
Expand Down
6 changes: 4 additions & 2 deletions src/idl/rpc_shim_blynk.h
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,9 @@ bool rpc_blynk_otaUpdateGetSHA256(rpc_buffer_t* digest) {
return _rpc_ret_val;
}


/*
* Prefetch the firmware file, to reduce the risk of download failure
*/
static inline
uint8_t rpc_blynk_otaUpdatePrefetch(void) {
RpcStatus _rpc_res;
Expand Down Expand Up @@ -787,7 +789,7 @@ uint8_t rpc_blynk_factoryTestWiFi(const char* ssid, const char* pass, int16_t* r
/* Wait response */
MessageBuffer _rsp_buff;
MessageBuffer_init(&_rsp_buff, NULL, 0);
_rpc_res = rpc_wait_result(_rpc_seq, &_rsp_buff, 15000);
_rpc_res = rpc_wait_result(_rpc_seq, &_rsp_buff, 30000);
if (_rpc_res == RPC_STATUS_OK) {
/* Deserialize outputs */
MessageBuffer_readInt16(&_rsp_buff, rssi);
Expand Down
2 changes: 1 addition & 1 deletion src/idl/rpc_shim_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ bool rpc_client_otaUpdateAvailable(const char* filename, uint32_t filesize, cons
/* Wait response */
MessageBuffer _rsp_buff;
MessageBuffer_init(&_rsp_buff, NULL, 0);
_rpc_res = rpc_wait_result(_rpc_seq, &_rsp_buff, RPC_TIMEOUT_DEFAULT);
_rpc_res = rpc_wait_result(_rpc_seq, &_rsp_buff, 5000);
if (_rpc_res == RPC_STATUS_OK) {
/* Deserialize outputs */
MessageBuffer_readBool(&_rsp_buff, &_rpc_ret_val);
Expand Down
7 changes: 6 additions & 1 deletion test/ncptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
ncptool.py /dev/ttyUSB0 --initRGB 15 12 13 0
ncptool.py /dev/ttyUSB0 --setLedBrightness 128
ncptool.py /dev/ttyUSB0 --reboot
ncptool.py /dev/ttyUSB0 --factoryTestWiFi SSID PASS
"""

import sys
import asyncio
import aioserial
import struct
Expand Down Expand Up @@ -364,12 +366,15 @@ async def rpc_blynk_factoryTestWiFi(ssid, password):
req = MessageBuffer()
req.write_cstring(ssid)
req.write_cstring(password)
rsp = await rpcInvoke(RpcUID.BLYNK_FACTORYTESTWIFI, req, 15000)
rsp = await rpcInvoke(RpcUID.BLYNK_FACTORYTESTWIFI, req, 30000)
rssi = rsp.read_int16()
retval = FactoryTestStatus(rsp.read_uint8())
print(f"Status: {retval.name}")
print(f"RSSI: {rssi}dBm")

if not retval == FactoryTestStatus.FACTORY_TEST_OK:
sys.exit(1)

async def rpc_blynk_factoryTestWiFiAP(channel):
req = MessageBuffer()
req.write_uint16(channel)
Expand Down

0 comments on commit d21ad5b

Please sign in to comment.