Skip to content

Commit

Permalink
Merge pull request #350 from geeksville/master
Browse files Browse the repository at this point in the history
misc bugfix
  • Loading branch information
geeksville authored Aug 30, 2020
2 parents 2d12a36 + 347484b commit 915427c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bin/version.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@


export VERSION=0.9.3
export VERSION=0.9.5
2 changes: 2 additions & 0 deletions src/esp32/BluetoothSoftwareUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ int update_size_callback(uint16_t conn_handle, uint16_t attr_handle, struct ble_
if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR && updateExpectedSize != 0) {
updateActualSize = 0;
crc.reset();
if (Update.isRunning())
Update.abort();
bool canBegin = Update.begin(updateExpectedSize);
DEBUG_MSG("Setting update size %u, result %d\n", updateExpectedSize, canBegin);
if (!canBegin) {
Expand Down
18 changes: 14 additions & 4 deletions src/mesh/MeshRadio.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@
#define CH_SPACING_CN 2.0f // MHz FIXME, this is just a guess for 470-510
#define NUM_CHANNELS_CN 20

// JP channel settings
#define CH0_JP 920.0f // MHz
#define CH_SPACING_JP 0.5f // MHz FIXME, this is just a guess for 920-925
// JP channel settings (AS1 bandplan)
#define CH0_JP 920.0f // MHz
#define CH_SPACING_JP 0.5f
#define NUM_CHANNELS_JP 10

// TW channel settings (AS2 bandplan 923-925MHz)
#define CH0_TW 923.0f // MHz
#define CH_SPACING_TW 0.2
#define NUM_CHANNELS_TW 10

// FIXME add defs for other regions and use them here
#ifdef HW_VERSION_US
#define CH0 CH0_US
Expand All @@ -49,13 +54,18 @@
#define CH_SPACING CH_SPACING_CN
#define NUM_CHANNELS NUM_CHANNELS_CN
#elif defined(HW_VERSION_JP)
// Also called AS1 bandplan
#define CH0 CH0_JP
#define CH_SPACING CH_SPACING_JP
#define NUM_CHANNELS NUM_CHANNELS_JP
#elif defined(HW_VERSION_TW)
// Also called AS2 bandplan
#define CH0 CH0_TW
#define CH_SPACING CH_SPACING_TW
#define NUM_CHANNELS NUM_CHANNELS_TW
#else
// HW version not set - assume US
#define CH0 CH0_US
#define CH_SPACING CH_SPACING_US
#define NUM_CHANNELS NUM_CHANNELS_US
#endif

4 changes: 2 additions & 2 deletions src/mesh/NodeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const char *getChannelName()
static char buf[32];

uint8_t code = 0;
for (int i = 0; i < sizeof(channelSettings.psk.size); i++)
for (int i = 0; i < channelSettings.psk.size; i++)
code ^= channelSettings.psk.bytes[i];

snprintf(buf, sizeof(buf), "#%s-%c", channelSettings.name, 'A' + (code % 26));
Expand Down Expand Up @@ -121,7 +121,7 @@ void NodeDB::resetRadioConfig()
channelSettings.modem_config = ChannelSettings_ModemConfig_Bw125Cr48Sf4096; // slow and long range

channelSettings.tx_power = 0; // default
memcpy(&channelSettings.psk.bytes, &defaultpsk, sizeof(channelSettings.psk));
memcpy(&channelSettings.psk.bytes, defaultpsk, sizeof(channelSettings.psk));
channelSettings.psk.size = sizeof(defaultpsk);
strcpy(channelSettings.name, "Default");
}
Expand Down
10 changes: 5 additions & 5 deletions src/nimble/BluetoothUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ static void on_sync(void)
int isPrivate = 0;
rc = ble_hs_id_copy_addr(own_addr_type, addr_val, &isPrivate);
assert(rc == 0);
DEBUG_MSG("Addr type %d, Private=%d, Device Address: ", own_addr_type, isPrivate);
DEBUG_MSG("BLE advertisting type=%d, Private=%d, Device Address: ", own_addr_type, isPrivate);
print_addr(addr_val);
DEBUG_MSG("\n");
/* Begin advertising. */
Expand All @@ -357,17 +357,17 @@ void gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg)
break;

case BLE_GATT_REGISTER_OP_CHR:
DEBUG_MSG("registering characteristic %s with "
/* DEBUG_MSG("registering characteristic %s with "
"def_handle=%d val_handle=%d\n",
ble_uuid_to_str(ctxt->chr.chr_def->uuid, buf), ctxt->chr.def_handle, ctxt->chr.val_handle);
ble_uuid_to_str(ctxt->chr.chr_def->uuid, buf), ctxt->chr.def_handle, ctxt->chr.val_handle); */

if (ctxt->chr.chr_def->uuid == &fromnum_uuid.u) {
fromNumValHandle = ctxt->chr.val_handle;
DEBUG_MSG("FromNum handle %d\n", fromNumValHandle);
// DEBUG_MSG("FromNum handle %d\n", fromNumValHandle);
}
if (ctxt->chr.chr_def->uuid == &update_result_uuid.u) {
updateResultHandle = ctxt->chr.val_handle;
DEBUG_MSG("update result handle %d\n", updateResultHandle);
// DEBUG_MSG("update result handle %d\n", updateResultHandle);
}
break;

Expand Down

0 comments on commit 915427c

Please sign in to comment.