Skip to content

Commit fc541bd

Browse files
authored
Merge pull request #511 from oltaco/wio-tracker-l1
Seeed Wio Tracker L1: initial support
2 parents e8b1f31 + 78cd655 commit fc541bd

File tree

8 files changed

+659
-0
lines changed

8 files changed

+659
-0
lines changed

boards/seeed-wio-tracker-l1.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"build": {
3+
"arduino": {
4+
"ldscript": "nrf52840_s140_v7.ld"
5+
},
6+
"core": "nRF5",
7+
"cpu": "cortex-m4",
8+
"extra_flags": "-DARDUINO_SEEED_WIO_TRACKER_L1 -DNRF52840_XXAA -DSEEED_WIO_TRACKER_L1 ",
9+
"f_cpu": "64000000L",
10+
"hwids": [
11+
[ "0x2886", "0x1667" ],
12+
[ "0x2886", "0x1668" ]
13+
],
14+
"mcu": "nrf52840",
15+
"variant": "Seeed_Wio_Tracker_L1",
16+
"softdevice": {
17+
"sd_flags": "-DS140",
18+
"sd_name": "s140",
19+
"sd_version": "7.3.0",
20+
"sd_fwid": "0x0123"
21+
},
22+
"bsp": {
23+
"name": "adafruit"
24+
},
25+
"bootloader": {
26+
"settings_addr": "0xFF000"
27+
},
28+
"usb_product": "Seeed Wio Tracker L1"
29+
},
30+
"connectivity": [
31+
"bluetooth"
32+
],
33+
"debug": {
34+
"jlink_device": "nRF52840_xxAA",
35+
"openocd_target": "nrf52.cfg",
36+
"svd_path": "nrf52840.svd"
37+
},
38+
"frameworks": [
39+
"arduino"
40+
],
41+
"name": "Seeed Wio Tracker L1",
42+
"upload": {
43+
"maximum_ram_size": 248832,
44+
"maximum_size": 815104,
45+
"protocol": "nrfutil",
46+
"speed": 115200,
47+
"protocols": [
48+
"jlink",
49+
"nrfjprog",
50+
"nrfutil",
51+
"cmsis-dap",
52+
"sam-ba",
53+
"blackmagic"
54+
],
55+
"use_1200bps_touch": true,
56+
"require_upload_port": true,
57+
"wait_for_upload_port": true
58+
},
59+
"url": "https://wiki.seeedstudio.com/wio_tracker_l1_node/",
60+
"vendor": "Seeed Studio"
61+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#include <Arduino.h>
2+
#include "WioTrackerL1Board.h"
3+
4+
#include <bluefruit.h>
5+
#include <Wire.h>
6+
7+
static BLEDfu bledfu;
8+
9+
static void connect_callback(uint16_t conn_handle) {
10+
(void)conn_handle;
11+
MESH_DEBUG_PRINTLN("BLE client connected");
12+
}
13+
14+
static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
15+
(void)conn_handle;
16+
(void)reason;
17+
18+
MESH_DEBUG_PRINTLN("BLE client disconnected");
19+
}
20+
21+
void WioTrackerL1Board::begin() {
22+
// for future use, sub-classes SHOULD call this from their begin()
23+
startup_reason = BD_STARTUP_NORMAL;
24+
btn_prev_state = HIGH;
25+
26+
pinMode(PIN_VBAT_READ, INPUT); // VBAT ADC input
27+
// Set all button pins to INPUT_PULLUP
28+
pinMode(PIN_BUTTON1, INPUT_PULLUP);
29+
pinMode(PIN_BUTTON2, INPUT_PULLUP);
30+
pinMode(PIN_BUTTON3, INPUT_PULLUP);
31+
pinMode(PIN_BUTTON4, INPUT_PULLUP);
32+
pinMode(PIN_BUTTON5, INPUT_PULLUP);
33+
pinMode(PIN_BUTTON6, INPUT_PULLUP);
34+
35+
36+
#if defined(PIN_WIRE_SDA) && defined(PIN_WIRE_SCL)
37+
Wire.setPins(PIN_WIRE_SDA, PIN_WIRE_SCL);
38+
#endif
39+
40+
Wire.begin();
41+
42+
#ifdef P_LORA_TX_LED
43+
pinMode(P_LORA_TX_LED, OUTPUT);
44+
digitalWrite(P_LORA_TX_LED, LOW);
45+
#endif
46+
47+
delay(10); // give sx1262 some time to power up
48+
}
49+
50+
bool WioTrackerL1Board::startOTAUpdate(const char* id, char reply[]) {
51+
// Config the peripheral connection with maximum bandwidth
52+
// more SRAM required by SoftDevice
53+
// Note: All config***() function must be called before begin()
54+
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
55+
Bluefruit.configPrphConn(92, BLE_GAP_EVENT_LENGTH_MIN, 16, 16);
56+
57+
Bluefruit.begin(1, 0);
58+
// Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
59+
Bluefruit.setTxPower(4);
60+
// Set the BLE device name
61+
Bluefruit.setName("WioTrackerL1 OTA");
62+
63+
Bluefruit.Periph.setConnectCallback(connect_callback);
64+
Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
65+
66+
// To be consistent OTA DFU should be added first if it exists
67+
bledfu.begin();
68+
69+
// Set up and start advertising
70+
// Advertising packet
71+
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
72+
Bluefruit.Advertising.addTxPower();
73+
Bluefruit.Advertising.addName();
74+
75+
/* Start Advertising
76+
- Enable auto advertising if disconnected
77+
- Interval: fast mode = 20 ms, slow mode = 152.5 ms
78+
- Timeout for fast mode is 30 seconds
79+
- Start(timeout) with timeout = 0 will advertise forever (until connected)
80+
81+
For recommended advertising interval
82+
https://developer.apple.com/library/content/qa/qa1931/_index.html
83+
*/
84+
Bluefruit.Advertising.restartOnDisconnect(true);
85+
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
86+
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
87+
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
88+
89+
uint8_t mac_addr[6];
90+
memset(mac_addr, 0, sizeof(mac_addr));
91+
Bluefruit.getAddr(mac_addr);
92+
sprintf(reply, "OK - mac: %02X:%02X:%02X:%02X:%02X:%02X",
93+
mac_addr[5], mac_addr[4], mac_addr[3], mac_addr[2], mac_addr[1], mac_addr[0]);
94+
95+
return true;
96+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#pragma once
2+
3+
#include <MeshCore.h>
4+
#include <Arduino.h>
5+
6+
class WioTrackerL1Board : public mesh::MainBoard {
7+
protected:
8+
uint8_t startup_reason;
9+
uint8_t btn_prev_state;
10+
11+
public:
12+
void begin();
13+
uint8_t getStartupReason() const override { return startup_reason; }
14+
15+
#if defined(P_LORA_TX_LED)
16+
void onBeforeTransmit() override {
17+
digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on
18+
}
19+
void onAfterTransmit() override {
20+
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
21+
}
22+
#endif
23+
24+
uint16_t getBattMilliVolts() override {
25+
int adcvalue = 0;
26+
analogReadResolution(12);
27+
analogReference(AR_INTERNAL);
28+
delay(10);
29+
adcvalue = analogRead(PIN_VBAT_READ);
30+
return (adcvalue * ADC_MULTIPLIER * AREF_VOLTAGE) / 4.096;
31+
}
32+
33+
const char* getManufacturerName() const override {
34+
return "Seeed Wio Tracker L1";
35+
}
36+
37+
void reboot() override {
38+
NVIC_SystemReset();
39+
}
40+
41+
bool startOTAUpdate(const char* id, char reply[]) override;
42+
};
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
[WioTrackerL1]
2+
extends = nrf52_base
3+
board = seeed-wio-tracker-l1
4+
board_build.ldscript = boards/nrf52840_s140_v7.ld
5+
build_flags = ${nrf52_base.build_flags}
6+
-I lib/nrf52/s140_nrf52_7.3.0_API/include
7+
-I lib/nrf52/s140_nrf52_7.3.0_API/include/nrf52
8+
-I variants/wio-tracker-l1
9+
-D WIO_TRACKER_L1
10+
-D RADIO_CLASS=CustomSX1262
11+
-D WRAPPER_CLASS=CustomSX1262Wrapper
12+
-D LORA_TX_POWER=22
13+
-D SX126X_CURRENT_LIMIT=140
14+
-D SX126X_RX_BOOSTED_GAIN=1
15+
-D PIN_OLED_RESET=-1
16+
; -D MESH_DEBUG=1
17+
build_src_filter = ${nrf52_base.build_src_filter}
18+
+<WioTrackerL1Board.cpp>
19+
+<../variants/wio-tracker-l1>
20+
+<helpers/ui/SH1106Display.cpp>
21+
+<helpers/sensors>
22+
lib_deps= ${nrf52_base.lib_deps}
23+
adafruit/Adafruit SH110X @ ^2.1.13
24+
adafruit/Adafruit GFX Library @ ^1.12.1
25+
stevemarple/MicroNMEA @ ^2.0.6
26+
27+
[env:WioTrackerL1_Repeater]
28+
extends = WioTrackerL1
29+
build_src_filter = ${WioTrackerL1.build_src_filter}
30+
+<../examples/simple_repeater>
31+
build_flags =
32+
${WioTrackerL1.build_flags}
33+
-D ADVERT_NAME='"WioTrackerL1 Repeater"'
34+
-D ADMIN_PASSWORD='"password"'
35+
-D MAX_NEIGHBOURS=8
36+
-D DISPLAY_CLASS=SH1106Display
37+
; -D MESH_PACKET_LOGGING=1
38+
; -D MESH_DEBUG=1
39+
lib_deps = ${WioTrackerL1.lib_deps}
40+
adafruit/RTClib @ ^2.1.3
41+
42+
[env:WioTrackerL1_room_server]
43+
extends = WioTrackerL1
44+
build_src_filter = ${WioTrackerL1.build_src_filter}
45+
+<../examples/simple_room_server>
46+
build_flags = ${WioTrackerL1.build_flags}
47+
-D ADVERT_NAME='"WioTrackerL1 Room"'
48+
-D ADMIN_PASSWORD='"password"'
49+
-D ROOM_PASSWORD='"hello"'
50+
-D DISPLAY_CLASS=SH1106Display
51+
; -D MESH_PACKET_LOGGING=1
52+
; -D MESH_DEBUG=1
53+
lib_deps = ${WioTrackerL1.lib_deps}
54+
adafruit/RTClib @ ^2.1.3
55+
56+
[env:WioTrackerL1_companion_radio_usb]
57+
extends = WioTrackerL1
58+
build_flags = ${WioTrackerL1.build_flags}
59+
-D MAX_CONTACTS=100
60+
-D MAX_GROUP_CHANNELS=8
61+
-D DISPLAY_CLASS=SH1106Display
62+
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
63+
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
64+
build_src_filter = ${WioTrackerL1.build_src_filter}
65+
+<../examples/companion_radio>
66+
+<helpers/ui/SH1106Display.cpp>
67+
+<helpers/ui/buzzer.cpp>
68+
lib_deps = ${WioTrackerL1.lib_deps}
69+
adafruit/RTClib @ ^2.1.3
70+
densaugeo/base64 @ ~1.4.0
71+
end2endzone/NonBlockingRTTTL@^1.3.0
72+
73+
[env:WioTrackerL1_companion_radio_ble]
74+
extends = WioTrackerL1
75+
build_flags = ${WioTrackerL1.build_flags}
76+
-D MAX_CONTACTS=100
77+
-D MAX_GROUP_CHANNELS=8
78+
-D BLE_PIN_CODE=123456
79+
-D BLE_DEBUG_LOGGING=1
80+
-D OFFLINE_QUEUE_SIZE=256
81+
-D DISPLAY_CLASS=SH1106Display
82+
; -D MESH_PACKET_LOGGING=1
83+
-D MESH_DEBUG=1
84+
-D PIN_BUZZER=12
85+
build_src_filter = ${WioTrackerL1.build_src_filter}
86+
+<helpers/nrf52/SerialBLEInterface.cpp>
87+
+<../examples/companion_radio>
88+
+<helpers/ui/buzzer.cpp>
89+
lib_deps = ${WioTrackerL1.lib_deps}
90+
adafruit/RTClib @ ^2.1.3
91+
densaugeo/base64 @ ~1.4.0
92+
end2endzone/NonBlockingRTTTL@^1.3.0

0 commit comments

Comments
 (0)