Skip to content

Commit 9c64714

Browse files
authored
Merge pull request #448 from adafruit/fix-macos
Fix macos
2 parents d244596 + 5447d66 commit 9c64714

File tree

6 files changed

+57
-85
lines changed

6 files changed

+57
-85
lines changed

boards.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ feather52832.build.f_cpu=64000000
4040
feather52832.build.board=NRF52832_FEATHER
4141
feather52832.build.core=nRF5
4242
feather52832.build.variant=feather_nrf52832
43+
feather52840.build.usb_manufacturer="Adafruit LLC"
44+
feather52840.build.usb_product="Feather nRF52832"
4345
feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52
4446
feather52832.build.ldscript=nrf52832_s132_v6.ld
4547

cores/nRF5/utility/debug.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,53 @@ const char* dbg_err_str(int32_t err_id)
438438
return str;
439439
}
440440

441+
//--------------------------------------------------------------------+
442+
// HCI STATUS
443+
//--------------------------------------------------------------------+
444+
static lookup_entry_t const _strhci_lookup[] =
445+
{
446+
{ .key = BLE_HCI_STATUS_CODE_SUCCESS , .data = "STATUS_CODE_SUCCESS" },
447+
{ .key = BLE_HCI_STATUS_CODE_UNKNOWN_BTLE_COMMAND , .data = "STATUS_CODE_UNKNOWN_BTLE_COMMAND " },
448+
{ .key = BLE_HCI_STATUS_CODE_UNKNOWN_CONNECTION_IDENTIFIER , .data = "STATUS_CODE_UNKNOWN_CONNECTION_IDENTIFIER" },
449+
{ .key = BLE_HCI_AUTHENTICATION_FAILURE , .data = "AUTHENTICATION_FAILURE " },
450+
{ .key = BLE_HCI_STATUS_CODE_PIN_OR_KEY_MISSING , .data = "STATUS_CODE_PIN_OR_KEY_MISSING " },
451+
{ .key = BLE_HCI_MEMORY_CAPACITY_EXCEEDED , .data = "MEMORY_CAPACITY_EXCEEDED " },
452+
{ .key = BLE_HCI_CONNECTION_TIMEOUT , .data = "CONNECTION_TIMEOUT " },
453+
{ .key = BLE_HCI_STATUS_CODE_COMMAND_DISALLOWED , .data = "STATUS_CODE_COMMAND_DISALLOWED " },
454+
{ .key = BLE_HCI_STATUS_CODE_INVALID_BTLE_COMMAND_PARAMETERS , .data = "STATUS_CODE_INVALID_BTLE_COMMAND_PARAMETERS" },
455+
{ .key = BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION , .data = "REMOTE_USER_TERMINATED_CONNECTION" },
456+
{ .key = BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES , .data = "REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES" },
457+
{ .key = BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF , .data = "REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF" },
458+
{ .key = BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION , .data = "LOCAL_HOST_TERMINATED_CONNECTION " },
459+
{ .key = BLE_HCI_UNSUPPORTED_REMOTE_FEATURE , .data = "UNSUPPORTED_REMOTE_FEATURE" },
460+
{ .key = BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS , .data = "STATUS_CODE_INVALID_LMP_PARAMETERS " },
461+
{ .key = BLE_HCI_STATUS_CODE_UNSPECIFIED_ERROR , .data = "STATUS_CODE_UNSPECIFIED_ERROR" },
462+
{ .key = BLE_HCI_STATUS_CODE_LMP_RESPONSE_TIMEOUT , .data = "STATUS_CODE_LMP_RESPONSE_TIMEOUT " },
463+
{ .key = BLE_HCI_STATUS_CODE_LMP_ERROR_TRANSACTION_COLLISION , .data = "STATUS_CODE_LMP_ERROR_TRANSACTION_COLLISION" },
464+
{ .key = BLE_HCI_STATUS_CODE_LMP_PDU_NOT_ALLOWED , .data = "STATUS_CODE_LMP_PDU_NOT_ALLOWED" },
465+
{ .key = BLE_HCI_INSTANT_PASSED , .data = "INSTANT_PASSED " },
466+
{ .key = BLE_HCI_PAIRING_WITH_UNIT_KEY_UNSUPPORTED , .data = "PAIRING_WITH_UNIT_KEY_UNSUPPORTED" },
467+
{ .key = BLE_HCI_DIFFERENT_TRANSACTION_COLLISION , .data = "DIFFERENT_TRANSACTION_COLLISION" },
468+
{ .key = BLE_HCI_PARAMETER_OUT_OF_MANDATORY_RANGE , .data = "PARAMETER_OUT_OF_MANDATORY_RANGE " },
469+
{ .key = BLE_HCI_CONTROLLER_BUSY , .data = "CONTROLLER_BUSY" },
470+
{ .key = BLE_HCI_CONN_INTERVAL_UNACCEPTABLE , .data = "CONN_INTERVAL_UNACCEPTABLE " },
471+
{ .key = BLE_HCI_DIRECTED_ADVERTISER_TIMEOUT , .data = "DIRECTED_ADVERTISER_TIMEOUT" },
472+
{ .key = BLE_HCI_CONN_TERMINATED_DUE_TO_MIC_FAILURE , .data = "CONN_TERMINATED_DUE_TO_MIC_FAILURE " },
473+
{ .key = BLE_HCI_CONN_FAILED_TO_BE_ESTABLISHED , .data = "CONN_FAILED_TO_BE_ESTABLISHED" }
474+
};
475+
476+
lookup_table_t const _strhci_table =
477+
{
478+
.count = arrcount(_strhci_lookup),
479+
.items = _strhci_lookup
480+
};
481+
482+
483+
const char* dbg_hci_str(uint8_t id)
484+
{
485+
return (const char *) lookup_find(&_strhci_table, id);
486+
}
487+
441488
#endif
442489

443490
}

cores/nRF5/utility/debug.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#if CFG_DEBUG
4747
const char* dbg_ble_event_str(uint16_t evt_id);
4848
const char* dbg_err_str(int32_t err_id);
49+
const char* dbg_hci_str(uint8_t id);
4950
#endif
5051

5152
int dbgHeapTotal(void);

libraries/Bluefruit52Lib/examples/Peripheral/image_eink_upload/image_eink_upload.ino renamed to libraries/Bluefruit52Lib/examples/Peripheral/image_eink_transfer/image_eink_transfer.ino

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ uint32_t totalPixel = 0; // received pixel
6161
// pixel line buffer, should be large enough to hold an image width
6262
uint16_t pixel_buf[512];
6363

64-
// Use software timer to schedule bandwidth negotiation a few seconds after connection
65-
SoftwareTimer negoTimer;
66-
6764
// Statistics for speed testing
6865
uint32_t rxStartTime = 0;
6966
uint32_t rxLastTime = 0;
@@ -112,9 +109,6 @@ void setup()
112109

113110
bleuart.setRxOverflowCallback(bleuart_overflow_callback);
114111

115-
// one-shot (non-repeating) 2 seconds timer
116-
negoTimer.begin(2000, negotiate_bandwidth, NULL, false);
117-
118112
// Set up and start advertising
119113
startAdv();
120114

@@ -260,43 +254,8 @@ void bleuart_rx_callback(uint16_t conn_hdl)
260254
}
261255
}
262256

263-
void negotiate_bandwidth(TimerHandle_t xTimer)
264-
{
265-
(void) xTimer;
266-
267-
uint16_t conn_hdl = (uint16_t) ((uint32_t) negoTimer.getID());
268-
BLEConnection* conn = Bluefruit.Connection(conn_hdl);
269-
270-
// Switching from 1 Mb to 2 Mb PHY if needed
271-
if ( conn->connected() )
272-
{
273-
// Requesting to Switching to 2MB PHY, larger data length and bigger MTU
274-
// will increase the throughput on supported central. This should already
275-
// be done with latest Bluefruit app.
276-
//
277-
// However, some Android devices require 2Mb PHY switching must be initiated
278-
// from nRF side
279-
if ( conn->getPHY() == BLE_GAP_PHY_1MBPS )
280-
{
281-
Serial.println("Requesting PHY change from 1 Mb to 2Mb");
282-
conn->requestPHY();
283-
284-
// Data Length and MTU should already be done by Bluefruit app
285-
// conn->requestDataLengthUpdate();
286-
// conn->requestMtuExchange(247);
287-
}
288-
}
289-
}
290-
291257
void connect_callback(uint16_t conn_handle)
292258
{
293-
// Set connection handle as timer ID
294-
// Then schedule negotiation after a few seconds, we should not
295-
// negotiate here since it increases chance to conflict with other
296-
// on-going negotiation from central after connection
297-
negoTimer.setID((void*) conn_handle);
298-
negoTimer.start();
299-
300259
Serial.println("Connected");
301260
Serial.println("Ready to receive new image");
302261
}

libraries/Bluefruit52Lib/examples/Peripheral/image_upload/image_upload.ino renamed to libraries/Bluefruit52Lib/examples/Peripheral/image_transfer/image_transfer.ino

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,26 @@
2626

2727
#if defined(ARDUINO_NRF52840_CIRCUITPLAY)
2828
// Circuit Playground Bluefruit use with TFT GIZMO
29-
#define TFT_BACKLIGHT A3
29+
#define DEVICE_NAME "CPLAY"
3030

3131
#include "Adafruit_ST7789.h"
3232
Adafruit_ST7789 tft = Adafruit_ST7789(&SPI, 0, 1, -1); // CS = 0, DC = 1
3333

3434
#elif defined(ARDUINO_NRF52840_CLUE)
35+
#define DEVICE_NAME "CLUE"
36+
3537
// CLUE use on-board TFT
3638
#include "Adafruit_ST7789.h"
3739
Adafruit_ST7789 tft = Adafruit_ST7789(&SPI1, PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_RST);
3840

3941
#else
42+
#define DEVICE_NAME "Feather"
43+
4044
#define TFT_35_FEATHERWING 1
4145
#define TFT_24_FEATHERWING 2
4246

4347
// [Configurable] For other boards please select which external display to match your hardware setup
44-
#define TFT_IN_USE TFT_35_FEATHERWING
48+
#define TFT_IN_USE TFT_24_FEATHERWING
4549

4650
#if defined(ARDUINO_NRF52832_FEATHER)
4751
// Feather nRF52832 pin map is different from others
@@ -97,9 +101,6 @@ uint32_t totalPixel = 0; // received pixel
97101
// pixel line buffer, should be large enough to hold an image width
98102
uint16_t pixel_buf[512];
99103

100-
// Use software timer to schedule bandwidth negotiation a few seconds after connection
101-
SoftwareTimer negoTimer;
102-
103104
// Statistics for speed testing
104105
uint32_t rxStartTime = 0;
105106
uint32_t rxLastTime = 0;
@@ -173,9 +174,6 @@ void setup()
173174

174175
bleuart.setRxOverflowCallback(bleuart_overflow_callback);
175176

176-
// one-shot (non-repeating) 2 seconds timer
177-
negoTimer.begin(2000, negotiate_bandwidth, NULL, false);
178-
179177
// Set up and start advertising
180178
startAdv();
181179

@@ -296,43 +294,8 @@ void bleuart_rx_callback(uint16_t conn_hdl)
296294
}
297295
}
298296

299-
void negotiate_bandwidth(TimerHandle_t xTimer)
300-
{
301-
(void) xTimer;
302-
303-
uint16_t conn_hdl = (uint16_t) ((uint32_t) negoTimer.getID());
304-
BLEConnection* conn = Bluefruit.Connection(conn_hdl);
305-
306-
// Switching from 1 Mb to 2 Mb PHY if needed
307-
if ( conn->connected() )
308-
{
309-
// Requesting to Switching to 2MB PHY, larger data length and bigger MTU
310-
// will increase the throughput on supported central. This should already
311-
// be done with latest Bluefruit app.
312-
//
313-
// However, some Android devices require 2Mb PHY switching must be initiated
314-
// from nRF side
315-
if ( conn->getPHY() == BLE_GAP_PHY_1MBPS )
316-
{
317-
Serial.println("Requesting PHY change from 1 Mb to 2Mb");
318-
conn->requestPHY();
319-
320-
// Data Length and MTU should already be done by Bluefruit app
321-
// conn->requestDataLengthUpdate();
322-
// conn->requestMtuExchange(247);
323-
}
324-
}
325-
}
326-
327297
void connect_callback(uint16_t conn_handle)
328298
{
329-
// Set connection handle as timer ID
330-
// Then schedule negotiation after a few seconds, we should not
331-
// negotiate here since it increases chance to conflict with other
332-
// on-going negotiation from central after connection
333-
negoTimer.setID((void*) ((uint32_t)conn_handle));
334-
negoTimer.start();
335-
336299
tft.println("Connected");
337300
tft.setTextColor(COLOR_GREEN);
338301
tft.println("Ready to receive new image");

libraries/Bluefruit52Lib/src/bluefruit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
823823
{
824824
ble_gap_evt_disconnected_t const* para = &evt->evt.gap_evt.params.disconnected;
825825

826-
LOG_LV2("GAP", "Disconnect Reason 0x%02X", evt->evt.gap_evt.params.disconnected.reason);
826+
LOG_LV2("GAP", "Disconnect Reason: %s", dbg_hci_str(evt->evt.gap_evt.params.disconnected.reason));
827827

828828
// Turn off Conn LED If not connected at all
829829
if ( !this->connected() ) _setConnLed(false);

0 commit comments

Comments
 (0)