Skip to content

Commit e6812ab

Browse files
committed
raytac dongle only has 1 led populated
1 parent 77e7f7c commit e6812ab

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

boards.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,8 @@ mdbt50qrx.build.f_cpu=64000000
525525
mdbt50qrx.build.board=MDBT50Q_RX
526526
mdbt50qrx.build.core=nRF5
527527
mdbt50qrx.build.variant=raytac_mdbt50q_rx
528-
mdbt50qrx.build.usb_manufacturer="Raytac Corporation"
529-
mdbt50qrx.build.usb_product="Raytac MDBT50Q - RX"
528+
mdbt50qrx.build.usb_manufacturer="Raytac"
529+
mdbt50qrx.build.usb_product="nRF52840 Dongle"
530530
mdbt50qrx.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
531531
mdbt50qrx.build.ldscript=nrf52840_s140_v6.ld
532532
mdbt50qrx.build.vid=0x239A

libraries/Bluefruit52Lib/examples/Peripheral/nrf_blinky/nrf_blinky.ino

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void setup()
130130
lsbLED.setPermission(SECMODE_OPEN, SECMODE_OPEN);
131131
lsbLED.setFixedLen(1);
132132
lsbLED.begin();
133-
lsbLED.write8(0x00); // led = off
133+
lsbLED.write8(0x01); // led = on when connected
134134

135135
lsbLED.setWriteCallback(led_write_callback);
136136

@@ -167,23 +167,30 @@ void startAdv(void)
167167
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
168168
}
169169

170-
void led_write_callback(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len)
170+
void setLED(bool on)
171171
{
172-
(void) conn_hdl;
173-
(void) chr;
174-
(void) len; // len should be 1
175-
176172
// data = 1 -> LED = On
177173
// data = 0 -> LED = Off
178-
digitalWrite(LED_BUILTIN, data[0] ? LED_STATE_ON : (1-LED_STATE_ON));
174+
digitalWrite(LED_BUILTIN, on ? LED_STATE_ON : (1-LED_STATE_ON));
179175

180176
#ifdef PIN_NEOPIXEL
181-
uint32_t c = neopixel.Color(0x00, 0x00, data[0] ? 0x20 : 0x00);
177+
uint32_t c = neopixel.Color(0x00, 0x00, on ? 0x20 : 0x00);
182178
neopixel.fill(c, 0, NEOPIXEL_NUM);
183179
neopixel.show();
184180
#endif
185181
}
186182

183+
void led_write_callback(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len)
184+
{
185+
(void) conn_hdl;
186+
(void) chr;
187+
(void) len; // len should be 1
188+
189+
// data = 1 -> LED = On
190+
// data = 0 -> LED = Off
191+
setLED(data[0]);
192+
}
193+
187194
void loop()
188195
{
189196
delay(10); // poll button every 10 ms
@@ -212,6 +219,9 @@ void connect_callback(uint16_t conn_handle)
212219
{
213220
(void) conn_handle;
214221

222+
setLED(true);
223+
lsbLED.write8(0x01);
224+
215225
connection_count++;
216226
Serial.print("Connection count: ");
217227
Serial.println(connection_count);
@@ -234,6 +244,9 @@ void disconnect_callback(uint16_t conn_handle, uint8_t reason)
234244
(void) conn_handle;
235245
(void) reason;
236246

247+
setLED(false);
248+
lsbLED.write8(0x00);
249+
237250
Serial.println();
238251
Serial.print("Disconnected, reason = 0x"); Serial.println(reason, HEX);
239252

variants/raytac_mdbt50q_rx/variant.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ extern "C"
4444

4545
// LEDs
4646
#define PIN_LED1 (0)
47-
#define PIN_LED2 (1)
47+
#define PIN_LED2 (1) // LED2 is not populated by default
4848

4949
#define LED_BUILTIN PIN_LED1
50-
#define LED_CONN PIN_LED2
50+
#define LED_CONN PIN_LED1
5151

5252
#define LED_RED PIN_LED1
53-
#define LED_BLUE PIN_LED2
53+
#define LED_BLUE PIN_LED1
5454

5555
#define LED_STATE_ON 0 // State when LED is litted
5656

0 commit comments

Comments
 (0)