Skip to content

Commit

Permalink
Add ESPR_NO_BLUETOOTH_MESSAGES to not include text versions of Blueto…
Browse files Browse the repository at this point in the history
…oth error messages (just the error number)
  • Loading branch information
gfwilliams committed Sep 8, 2023
1 parent c1826f6 commit 7f4c7c4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
Bangle.js 1: remove OneWire,I2C,SPI as it uses too much flash space to exist alongside UTF8+Tensorflow+JIT on nRF52
ARM: Apply -fmerge-all-constants to the build (saves ~1kb)
Bangle.js: If screen is rotated, also rotate accelerometer and magnetometer values
Microbit1: don't include text versions of Bluetooth error messages (just the error number) to save some memory

2v18 : Fix drawString with setClipRect with 90/270-degree rotation (fix #2343)
Pico/Wifi: Enabled JIT compiler
Expand Down
1 change: 1 addition & 0 deletions README_BuildProcess.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ This is a partial list of definitions that can be added in a `BOARD.py` file's `
* `ESPR_PBF_FONTS` - Enable support for loading and displaying Pebble-style PBF font files with `g.setFontPBF`
* `ESPR_BLUETOOTH_ANCS` - Enable Apple ANCS(notification), AMS and CTS support
* `ESPR_NO_SOFTWARE_SERIAL` - don't build in software serial support
* `ESPR_NO_BLUETOOTH_MESSAGES` - don't include text versions of Bluetooth error messages (just the error number)

These are set automatically when `SAVE_ON_FLASH` is set (see `jsutils.h`)

Expand Down
3 changes: 3 additions & 0 deletions src/jsutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
#define ESPR_NO_TEMPLATE_LITERAL 1
#define ESPR_NO_SOFTWARE_SERIAL 1
#endif
#ifdef SAVE_ON_FLASH_EXTREME
#define ESPR_NO_BLUETOOTH_MESSAGES 1
#endif

#ifndef alloca
#define alloca(x) __builtin_alloca(x)
Expand Down
10 changes: 8 additions & 2 deletions targets/nrf5x/bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ ble_data_t m_scan_buffer = {
/// Checks for error and reports an exception string if there was one, else 0 if no error
JsVar *jsble_get_error_string(uint32_t err_code) {
if (!err_code) return 0;
#ifndef ESPR_NO_BLUETOOTH_MESSAGES
const char *name = 0;
switch (err_code) {
case NRF_ERROR_NO_MEM : name="NO_MEM"; break;
Expand All @@ -279,8 +280,11 @@ JsVar *jsble_get_error_string(uint32_t err_code) {
case BLE_ERROR_NO_TX_PACKETS : name="NO_TX_PACKETS"; break;
#endif
}
if (name) return jsvVarPrintf("ERR 0x%x (%s)", err_code, name);
else return jsvVarPrintf("ERR 0x%x", err_code);
if (name)
return jsvVarPrintf("ERR 0x%x (%s)", err_code, name);
else
#endif // ESPR_NO_BLUETOOTH_MESSAGES
return jsvVarPrintf("ERR 0x%x", err_code);
}

// -----------------------------------------------------------------------------------
Expand Down Expand Up @@ -593,6 +597,7 @@ uint8_t match_request : 1; If 1 requires the application to report
JsVar *o = jsvNewObject();
if (o) {
const char *str=NULL;
#ifndef ESPR_NO_BLUETOOTH_MESSAGES
switch(auth_status->auth_status) {
case BLE_GAP_SEC_STATUS_SUCCESS : str="SUCCESS";break;
case BLE_GAP_SEC_STATUS_TIMEOUT : str="TIMEOUT";break;
Expand All @@ -614,6 +619,7 @@ uint8_t match_request : 1; If 1 requires the application to report
case BLE_GAP_SEC_STATUS_BR_EDR_IN_PROG : str="BR_EDR_IN_PROG";break;
case BLE_GAP_SEC_STATUS_X_TRANS_KEY_DISALLOWED : str="X_TRANS_KEY_DISALLOWED";break;
}
#endif // ESPR_NO_BLUETOOTH_MESSAGES
jsvObjectSetChildAndUnLock(o,"auth_status",str?jsvNewFromString(str):jsvNewFromInteger(auth_status->auth_status));
jsvObjectSetChildAndUnLock(o, "bonded", jsvNewFromBool(auth_status->bonded));
jsvObjectSetChildAndUnLock(o, "lv4", jsvNewFromInteger(auth_status->sm1_levels.lv4));
Expand Down

0 comments on commit 7f4c7c4

Please sign in to comment.