trunk fmt
This commit is contained in:
+1
-1
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "../variants/rak2560/RAK9154Sensor.h"
|
||||||
#include "PowerStatus.h"
|
#include "PowerStatus.h"
|
||||||
#include "concurrency/OSThread.h"
|
#include "concurrency/OSThread.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "../variants/rak2560/RAK9154Sensor.h"
|
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#include <esp_adc_cal.h>
|
#include <esp_adc_cal.h>
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
#include "../modules/Telemetry/Sensor/TelemetrySensor.h"
|
#include "../modules/Telemetry/Sensor/TelemetrySensor.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
#include <RAK-OneWireSerial.h>
|
|
||||||
#include "concurrency/Periodic.h"
|
#include "concurrency/Periodic.h"
|
||||||
|
#include <RAK-OneWireSerial.h>
|
||||||
|
|
||||||
using namespace concurrency;
|
using namespace concurrency;
|
||||||
|
|
||||||
@@ -27,8 +27,7 @@ static uint8_t provision = 0;
|
|||||||
|
|
||||||
static void onewire_evt(const uint8_t pid, const uint8_t sid, const SNHUBAPI_EVT_E eid, uint8_t *msg, uint16_t len)
|
static void onewire_evt(const uint8_t pid, const uint8_t sid, const SNHUBAPI_EVT_E eid, uint8_t *msg, uint16_t len)
|
||||||
{
|
{
|
||||||
switch (eid)
|
switch (eid) {
|
||||||
{
|
|
||||||
case SNHUBAPI_EVT_RECV_REQ:
|
case SNHUBAPI_EVT_RECV_REQ:
|
||||||
case SNHUBAPI_EVT_RECV_RSP:
|
case SNHUBAPI_EVT_RECV_RSP:
|
||||||
break;
|
break;
|
||||||
@@ -62,12 +61,10 @@ static void onewire_evt(const uint8_t pid, const uint8_t sid, const SNHUBAPI_EVT
|
|||||||
// LOG_INFO("%02x,", msg[i]);
|
// LOG_INFO("%02x,", msg[i]);
|
||||||
// }
|
// }
|
||||||
// LOG_INFO("\r\n");
|
// LOG_INFO("\r\n");
|
||||||
switch (msg[0])
|
switch (msg[0]) {
|
||||||
{
|
|
||||||
case RAK_IPSO_CAPACITY:
|
case RAK_IPSO_CAPACITY:
|
||||||
dc_prec = msg[1];
|
dc_prec = msg[1];
|
||||||
if (dc_prec > 100)
|
if (dc_prec > 100) {
|
||||||
{
|
|
||||||
dc_prec = 100;
|
dc_prec = 100;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -92,12 +89,10 @@ static void onewire_evt(const uint8_t pid, const uint8_t sid, const SNHUBAPI_EVT
|
|||||||
// }
|
// }
|
||||||
// LOG_INFO("\r\n");
|
// LOG_INFO("\r\n");
|
||||||
|
|
||||||
switch (msg[0])
|
switch (msg[0]) {
|
||||||
{
|
|
||||||
case RAK_IPSO_CAPACITY:
|
case RAK_IPSO_CAPACITY:
|
||||||
dc_prec = msg[1];
|
dc_prec = msg[1];
|
||||||
if (dc_prec > 100)
|
if (dc_prec > 100) {
|
||||||
{
|
|
||||||
dc_prec = 100;
|
dc_prec = 100;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -129,21 +124,18 @@ static void onewire_evt(const uint8_t pid, const uint8_t sid, const SNHUBAPI_EVT
|
|||||||
|
|
||||||
static int32_t onewireHandle()
|
static int32_t onewireHandle()
|
||||||
{
|
{
|
||||||
if (provision != 0)
|
if (provision != 0) {
|
||||||
{
|
|
||||||
RakSNHub_Protocl_API.get.data(provision);
|
RakSNHub_Protocl_API.get.data(provision);
|
||||||
provision = 0;
|
provision = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (mySerial.available())
|
while (mySerial.available()) {
|
||||||
{
|
|
||||||
char a = mySerial.read();
|
char a = mySerial.read();
|
||||||
buff[bufflen++] = a;
|
buff[bufflen++] = a;
|
||||||
delay(2); // continue data, timeout=2ms
|
delay(2); // continue data, timeout=2ms
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bufflen != 0)
|
if (bufflen != 0) {
|
||||||
{
|
|
||||||
RakSNHub_Protocl_API.process((uint8_t *)buff, bufflen);
|
RakSNHub_Protocl_API.process((uint8_t *)buff, bufflen);
|
||||||
bufflen = 0;
|
bufflen = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
import sys
|
|
||||||
import struct
|
import struct
|
||||||
|
import sys
|
||||||
|
|
||||||
Import("env")
|
Import("env")
|
||||||
|
|
||||||
|
|
||||||
# Parse input and create UF2 file
|
# Parse input and create UF2 file
|
||||||
def create_uf2(source, target, env):
|
def create_uf2(source, target, env):
|
||||||
# source_hex = target[0].get_abspath()
|
# source_hex = target[0].get_abspath()
|
||||||
source_hex = target[0].get_string(False)
|
source_hex = target[0].get_string(False)
|
||||||
source_hex = '.\\'+source_hex
|
source_hex = ".\\" + source_hex
|
||||||
print("#########################################################")
|
print("#########################################################")
|
||||||
print("Create UF2 from " + source_hex)
|
print("Create UF2 from " + source_hex)
|
||||||
print("#########################################################")
|
print("#########################################################")
|
||||||
@@ -16,7 +17,7 @@ def create_uf2(source, target, env):
|
|||||||
target = target + ".uf2"
|
target = target + ".uf2"
|
||||||
# print("Target: " + target)
|
# print("Target: " + target)
|
||||||
|
|
||||||
with open(source_hex, mode='rb') as f:
|
with open(source_hex, mode="rb") as f:
|
||||||
inpbuf = f.read()
|
inpbuf = f.read()
|
||||||
|
|
||||||
outbuf = convert_from_hex_to_uf2(inpbuf.decode("utf-8"))
|
outbuf = convert_from_hex_to_uf2(inpbuf.decode("utf-8"))
|
||||||
@@ -48,9 +49,17 @@ class Block:
|
|||||||
flags = 0x0
|
flags = 0x0
|
||||||
if familyid:
|
if familyid:
|
||||||
flags |= 0x2000
|
flags |= 0x2000
|
||||||
hd = struct.pack("<IIIIIIII",
|
hd = struct.pack(
|
||||||
UF2_MAGIC_START0, UF2_MAGIC_START1,
|
"<IIIIIIII",
|
||||||
flags, self.addr, 256, blockno, numblocks, familyid)
|
UF2_MAGIC_START0,
|
||||||
|
UF2_MAGIC_START1,
|
||||||
|
flags,
|
||||||
|
self.addr,
|
||||||
|
256,
|
||||||
|
blockno,
|
||||||
|
numblocks,
|
||||||
|
familyid,
|
||||||
|
)
|
||||||
hd += self.bytes[0:256]
|
hd += self.bytes[0:256]
|
||||||
while len(hd) < 512 - 4:
|
while len(hd) < 512 - 4:
|
||||||
hd += b"\x00"
|
hd += b"\x00"
|
||||||
@@ -70,7 +79,7 @@ def convert_from_hex_to_uf2(buf):
|
|||||||
upper = 0
|
upper = 0
|
||||||
currblock = None
|
currblock = None
|
||||||
blocks = []
|
blocks = []
|
||||||
for line in buf.split('\n'):
|
for line in buf.split("\n"):
|
||||||
if line[0] != ":":
|
if line[0] != ":":
|
||||||
continue
|
continue
|
||||||
i = 1
|
i = 1
|
||||||
@@ -83,7 +92,7 @@ def convert_from_hex_to_uf2(buf):
|
|||||||
upper = ((rec[4] << 8) | rec[5]) << 16
|
upper = ((rec[4] << 8) | rec[5]) << 16
|
||||||
elif tp == 2:
|
elif tp == 2:
|
||||||
upper = ((rec[4] << 8) | rec[5]) << 4
|
upper = ((rec[4] << 8) | rec[5]) << 4
|
||||||
assert (upper & 0xffff) == 0
|
assert (upper & 0xFFFF) == 0
|
||||||
elif tp == 1:
|
elif tp == 1:
|
||||||
break
|
break
|
||||||
elif tp == 0:
|
elif tp == 0:
|
||||||
@@ -92,10 +101,10 @@ def convert_from_hex_to_uf2(buf):
|
|||||||
appstartaddr = addr
|
appstartaddr = addr
|
||||||
i = 4
|
i = 4
|
||||||
while i < len(rec) - 1:
|
while i < len(rec) - 1:
|
||||||
if not currblock or currblock.addr & ~0xff != addr & ~0xff:
|
if not currblock or currblock.addr & ~0xFF != addr & ~0xFF:
|
||||||
currblock = Block(addr & ~0xff)
|
currblock = Block(addr & ~0xFF)
|
||||||
blocks.append(currblock)
|
blocks.append(currblock)
|
||||||
currblock.bytes[addr & 0xff] = rec[i]
|
currblock.bytes[addr & 0xFF] = rec[i]
|
||||||
addr += 1
|
addr += 1
|
||||||
i += 1
|
i += 1
|
||||||
numblocks = len(blocks)
|
numblocks = len(blocks)
|
||||||
|
|||||||
@@ -34,8 +34,7 @@
|
|||||||
#include "WVariant.h"
|
#include "WVariant.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C" {
|
||||||
{
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
// Number of pins defined in PinDescription array
|
// Number of pins defined in PinDescription array
|
||||||
|
|||||||
Reference in New Issue
Block a user