Skip to content

Commit 2a33246

Browse files
authored
Merge branch 'meshcore-dev:dev' into dev
2 parents 15d52a6 + 5f06dc4 commit 2a33246

File tree

29 files changed

+664
-93
lines changed

29 files changed

+664
-93
lines changed

boards/keepteen_lt1.json

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"build": {
3+
"arduino":{
4+
"ldscript": "nrf52840_s140_v6.ld"
5+
},
6+
"core": "nRF5",
7+
"cpu": "cortex-m4",
8+
"extra_flags": "-DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA",
9+
"f_cpu": "64000000L",
10+
"hwids": [
11+
[
12+
"0x239A",
13+
"0x00B3"
14+
],
15+
[
16+
"0x239A",
17+
"0x8029"
18+
],
19+
[
20+
"0x239A",
21+
"0x0029"
22+
],
23+
[
24+
"0x239A",
25+
"0x002A"
26+
],
27+
[
28+
"0x239A",
29+
"0x802A"
30+
]
31+
],
32+
"usb_product": "Keepteen LT1",
33+
"mcu": "nrf52840",
34+
"variant": "Keepteen LT1",
35+
"variants_dir": "variants",
36+
"bsp": {
37+
"name": "adafruit"
38+
},
39+
"softdevice": {
40+
"sd_flags": "-DS140",
41+
"sd_name": "s140",
42+
"sd_version": "6.1.1",
43+
"sd_fwid": "0x00B6"
44+
},
45+
"bootloader": {
46+
"settings_addr": "0xFF000"
47+
}
48+
},
49+
"connectivity": [
50+
"bluetooth"
51+
],
52+
"debug": {
53+
"jlink_device": "nRF52840_xxAA",
54+
"svd_path": "nrf52840.svd",
55+
"openocd_target": "nrf52.cfg"
56+
},
57+
"frameworks": [
58+
"arduino",
59+
"zephyr"
60+
],
61+
"name": "Keepteen LT1",
62+
"upload": {
63+
"maximum_ram_size": 248832,
64+
"maximum_size": 815104,
65+
"speed": 115200,
66+
"protocol": "nrfutil",
67+
"protocols": [
68+
"jlink",
69+
"nrfjprog",
70+
"nrfutil",
71+
"stlink"
72+
],
73+
"use_1200bps_touch": true,
74+
"require_upload_port": true,
75+
"wait_for_upload_port": true
76+
},
77+
"url": "http://www.keepteen.com/",
78+
"vendor": "Keepteen"
79+
}

examples/companion_radio/MyMesh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ void MyMesh::handleCmdFrame(size_t len) {
11281128
uint8_t sf = cmd_frame[i++];
11291129
uint8_t cr = cmd_frame[i++];
11301130

1131-
if (freq >= 300000 && freq <= 2500000 && sf >= 7 && sf <= 12 && cr >= 5 && cr <= 8 && bw >= 7000 &&
1131+
if (freq >= 300000 && freq <= 2500000 && sf >= 5 && sf <= 12 && cr >= 5 && cr <= 8 && bw >= 7000 &&
11321132
bw <= 500000) {
11331133
_prefs.sf = sf;
11341134
_prefs.cr = cr;

examples/simple_repeater/MyMesh.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,8 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
710710
_prefs.gps_enabled = 0;
711711
_prefs.gps_interval = 0;
712712
_prefs.advert_loc_policy = ADVERT_LOC_PREFS;
713+
714+
_prefs.adc_multiplier = 0.0f; // 0.0f means use default board multiplier
713715
}
714716

715717
void MyMesh::begin(FILESYSTEM *fs) {
@@ -733,6 +735,8 @@ void MyMesh::begin(FILESYSTEM *fs) {
733735
updateAdvertTimer();
734736
updateFloodAdvertTimer();
735737

738+
board.setAdcMultiplier(_prefs.adc_multiplier);
739+
736740
#if ENV_INCLUDE_GPS == 1
737741
applyGpsPrefs();
738742
#endif

examples/simple_room_server/MyMesh.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,8 @@ void MyMesh::begin(FILESYSTEM *fs) {
641641
updateAdvertTimer();
642642
updateFloodAdvertTimer();
643643

644+
board.setAdcMultiplier(_prefs.adc_multiplier);
645+
644646
#if ENV_INCLUDE_GPS == 1
645647
applyGpsPrefs();
646648
#endif

examples/simple_sensor/SensorMesh.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,8 @@ void SensorMesh::begin(FILESYSTEM* fs) {
740740
updateAdvertTimer();
741741
updateFloodAdvertTimer();
742742

743+
board.setAdcMultiplier(_prefs.adc_multiplier);
744+
743745
#if ENV_INCLUDE_GPS == 1
744746
applyGpsPrefs();
745747
#endif

src/MeshCore.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ namespace mesh {
4242
class MainBoard {
4343
public:
4444
virtual uint16_t getBattMilliVolts() = 0;
45+
virtual bool setAdcMultiplier(float multiplier) { return false; };
46+
virtual float getAdcMultiplier() const { return 0.0f; }
4547
virtual const char* getManufacturerName() const = 0;
4648
virtual void onBeforeTransmit() { }
4749
virtual void onAfterTransmit() { }

src/helpers/CommonCLI.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ void CommonCLI::loadPrefsInt(FILESYSTEM* fs, const char* filename) {
7070
file.read((uint8_t *)&_prefs->gps_interval, sizeof(_prefs->gps_interval)); // 157
7171
file.read((uint8_t *)&_prefs->advert_loc_policy, sizeof (_prefs->advert_loc_policy)); // 161
7272
file.read((uint8_t *)&_prefs->discovery_mod_timestamp, sizeof(_prefs->discovery_mod_timestamp)); // 162
73-
// 166
73+
file.read((uint8_t *)&_prefs->adc_multiplier, sizeof(_prefs->adc_multiplier)); // 166
74+
// 170
7475

7576
// sanitise bad pref values
7677
_prefs->rx_delay_base = constrain(_prefs->rx_delay_base, 0, 20.0f);
@@ -83,6 +84,7 @@ void CommonCLI::loadPrefsInt(FILESYSTEM* fs, const char* filename) {
8384
_prefs->cr = constrain(_prefs->cr, 5, 8);
8485
_prefs->tx_power_dbm = constrain(_prefs->tx_power_dbm, 1, 30);
8586
_prefs->multi_acks = constrain(_prefs->multi_acks, 0, 1);
87+
_prefs->adc_multiplier = constrain(_prefs->adc_multiplier, 0.0f, 10.0f);
8688

8789
// sanitise bad bridge pref values
8890
_prefs->bridge_enabled = constrain(_prefs->bridge_enabled, 0, 1);
@@ -148,7 +150,8 @@ void CommonCLI::savePrefs(FILESYSTEM* fs) {
148150
file.write((uint8_t *)&_prefs->gps_interval, sizeof(_prefs->gps_interval)); // 157
149151
file.write((uint8_t *)&_prefs->advert_loc_policy, sizeof(_prefs->advert_loc_policy)); // 161
150152
file.write((uint8_t *)&_prefs->discovery_mod_timestamp, sizeof(_prefs->discovery_mod_timestamp)); // 162
151-
// 166
153+
file.write((uint8_t *)&_prefs->adc_multiplier, sizeof(_prefs->adc_multiplier)); // 166
154+
// 170
152155

153156
file.close();
154157
}
@@ -233,7 +236,7 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
233236
uint8_t sf = num > 2 ? atoi(parts[2]) : 0;
234237
uint8_t cr = num > 3 ? atoi(parts[3]) : 0;
235238
int temp_timeout_mins = num > 4 ? atoi(parts[4]) : 0;
236-
if (freq >= 300.0f && freq <= 2500.0f && sf >= 7 && sf <= 12 && cr >= 5 && cr <= 8 && bw >= 7.0f && bw <= 500.0f && temp_timeout_mins > 0) {
239+
if (freq >= 300.0f && freq <= 2500.0f && sf >= 5 && sf <= 12 && cr >= 5 && cr <= 8 && bw >= 7.0f && bw <= 500.0f && temp_timeout_mins > 0) {
237240
_callbacks->applyTempRadioParams(freq, bw, sf, cr, temp_timeout_mins);
238241
sprintf(reply, "OK - temp params for %d mins", temp_timeout_mins);
239242
} else {
@@ -331,6 +334,13 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
331334
} else if (memcmp(config, "bridge.secret", 13) == 0) {
332335
sprintf(reply, "> %s", _prefs->bridge_secret);
333336
#endif
337+
} else if (memcmp(config, "adc.multiplier", 14) == 0) {
338+
float adc_mult = _board->getAdcMultiplier();
339+
if (adc_mult == 0.0f) {
340+
strcpy(reply, "Error: unsupported by this board");
341+
} else {
342+
sprintf(reply, "> %.3f", adc_mult);
343+
}
334344
} else {
335345
sprintf(reply, "??: %s", config);
336346
}
@@ -411,7 +421,7 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
411421
float bw = num > 1 ? atof(parts[1]) : 0.0f;
412422
uint8_t sf = num > 2 ? atoi(parts[2]) : 0;
413423
uint8_t cr = num > 3 ? atoi(parts[3]) : 0;
414-
if (freq >= 300.0f && freq <= 2500.0f && sf >= 7 && sf <= 12 && cr >= 5 && cr <= 8 && bw >= 7.0f && bw <= 500.0f) {
424+
if (freq >= 300.0f && freq <= 2500.0f && sf >= 5 && sf <= 12 && cr >= 5 && cr <= 8 && bw >= 7.0f && bw <= 500.0f) {
415425
_prefs->sf = sf;
416426
_prefs->cr = cr;
417427
_prefs->freq = freq;
@@ -523,6 +533,19 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
523533
savePrefs();
524534
strcpy(reply, "OK");
525535
#endif
536+
} else if (memcmp(config, "adc.multiplier ", 15) == 0) {
537+
_prefs->adc_multiplier = atof(&config[15]);
538+
if (_board->setAdcMultiplier(_prefs->adc_multiplier)) {
539+
savePrefs();
540+
if (_prefs->adc_multiplier == 0.0f) {
541+
strcpy(reply, "OK - using default board multiplier");
542+
} else {
543+
sprintf(reply, "OK - multiplier set to %.3f", _prefs->adc_multiplier);
544+
}
545+
} else {
546+
_prefs->adc_multiplier = 0.0f;
547+
strcpy(reply, "Error: unsupported by this board");
548+
};
526549
} else {
527550
sprintf(reply, "unknown config: %s", config);
528551
}

src/helpers/CommonCLI.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct NodePrefs { // persisted to file
4747
uint32_t gps_interval; // in seconds
4848
uint8_t advert_loc_policy;
4949
uint32_t discovery_mod_timestamp;
50+
float adc_multiplier;
5051
};
5152

5253
class CommonCLICallbacks {

src/helpers/sensors/EnvironmentSensorManager.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,16 @@ bool EnvironmentSensorManager::begin() {
178178
}
179179
#endif
180180

181+
#if ENV_INCLUDE_BME680
182+
if (BME680.begin(TELEM_BME680_ADDRESS, TELEM_WIRE)) {
183+
MESH_DEBUG_PRINTLN("Found BME680 at address: %02X", TELEM_BME680_ADDRESS);
184+
BME680_initialized = true;
185+
} else {
186+
BME680_initialized = false;
187+
MESH_DEBUG_PRINTLN("BME680 was not found at I2C address %02X", TELEM_BME680_ADDRESS);
188+
}
189+
#endif
190+
181191
#if ENV_INCLUDE_BME280
182192
if (BME280.begin(TELEM_BME280_ADDRESS, TELEM_WIRE)) {
183193
MESH_DEBUG_PRINTLN("Found BME280 at address: %02X", TELEM_BME280_ADDRESS);
@@ -301,16 +311,6 @@ bool EnvironmentSensorManager::begin() {
301311
}
302312
#endif
303313

304-
#if ENV_INCLUDE_BME680
305-
if (BME680.begin(TELEM_BME680_ADDRESS, TELEM_WIRE)) {
306-
MESH_DEBUG_PRINTLN("Found BME680 at address: %02X", TELEM_BME680_ADDRESS);
307-
BME680_initialized = true;
308-
} else {
309-
BME680_initialized = false;
310-
MESH_DEBUG_PRINTLN("BME680 was not found at I2C address %02X", TELEM_BME680_ADDRESS);
311-
}
312-
#endif
313-
314314
#if ENV_INCLUDE_BMP085
315315
// First argument is MODE (aka oversampling)
316316
// choose ULTRALOWPOWER
@@ -344,6 +344,19 @@ bool EnvironmentSensorManager::querySensors(uint8_t requester_permissions, Cayen
344344
}
345345
#endif
346346

347+
#if ENV_INCLUDE_BME680
348+
if (BME680_initialized) {
349+
if (BME680.performReading()) {
350+
telemetry.addTemperature(TELEM_CHANNEL_SELF, BME680.temperature);
351+
telemetry.addRelativeHumidity(TELEM_CHANNEL_SELF, BME680.humidity);
352+
telemetry.addBarometricPressure(TELEM_CHANNEL_SELF, BME680.pressure / 100);
353+
telemetry.addAltitude(TELEM_CHANNEL_SELF, 44330.0 * (1.0 - pow((BME680.pressure / 100) / TELEM_BME680_SEALEVELPRESSURE_HPA, 0.1903)));
354+
telemetry.addAnalogInput(next_available_channel, BME680.gas_resistance);
355+
next_available_channel++;
356+
}
357+
}
358+
#endif
359+
347360
#if ENV_INCLUDE_BME280
348361
if (BME280_initialized) {
349362
telemetry.addTemperature(TELEM_CHANNEL_SELF, BME280.readTemperature());
@@ -452,19 +465,6 @@ bool EnvironmentSensorManager::querySensors(uint8_t requester_permissions, Cayen
452465
}
453466
#endif
454467

455-
#if ENV_INCLUDE_BME680
456-
if (BME680_initialized) {
457-
if (BME680.performReading()) {
458-
telemetry.addTemperature(TELEM_CHANNEL_SELF, BME680.temperature);
459-
telemetry.addRelativeHumidity(TELEM_CHANNEL_SELF, BME680.humidity);
460-
telemetry.addBarometricPressure(TELEM_CHANNEL_SELF, BME680.pressure / 100);
461-
telemetry.addAltitude(TELEM_CHANNEL_SELF, 44330.0 * (1.0 - pow((BME680.pressure / 100) / TELEM_BME680_SEALEVELPRESSURE_HPA, 0.1903)));
462-
telemetry.addAnalogInput(next_available_channel, BME680.gas_resistance);
463-
next_available_channel++;
464-
}
465-
}
466-
#endif
467-
468468
#if ENV_INCLUDE_BMP085
469469
if (BMP085_initialized) {
470470
telemetry.addTemperature(TELEM_CHANNEL_SELF, BMP085.readTemperature());
@@ -563,7 +563,7 @@ void EnvironmentSensorManager::initBasicGPS() {
563563
gps_active = false; //Set GPS visibility off until setting is changed
564564
}
565565

566-
// gps code for rak might be moved to MicroNMEALoactionProvider
566+
// gps code for rak might be moved to MicroNMEALoactionProvider
567567
// or make a new location provider ...
568568
#ifdef RAK_WISBLOCK_GPS
569569
void EnvironmentSensorManager::rakGPSInit(){

variants/heltec_t114/platformio.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ build_flags = ${nrf52_base.build_flags}
2929
-D SX126X_RX_BOOSTED_GAIN=1
3030
-D DISPLAY_CLASS=NullDisplayDriver
3131
-D ST7789
32+
-D PIN_GPS_RX=39
33+
-D PIN_GPS_TX=37
34+
-D PIN_GPS_EN=21
35+
-D PIN_GPS_RESET=38
36+
-D PIN_GPS_RESET_ACTIVE=LOW
3237
build_src_filter = ${nrf52_base.build_src_filter}
3338
+<helpers/*.cpp>
3439
+<../variants/heltec_t114>

0 commit comments

Comments
 (0)