diff --git a/epicardium/ble/ble_main.c b/epicardium/ble/ble_main.c index 795aaa41d8c51bd8af4e5dd02734747772d372ba..629e9b53cdaead3a339ce4466b2b3b400e4eec9f 100644 --- a/epicardium/ble/ble_main.c +++ b/epicardium/ble/ble_main.c @@ -62,7 +62,9 @@ static const appSlaveCfg_t bleSlaveCfg = /*! configurable parameters for security */ static const appSecCfg_t bleSecCfg = { - .auth = DM_AUTH_MITM_FLAG | DM_AUTH_BOND_FLAG | DM_AUTH_SC_FLAG, /*! Authentication and bonding flags */ + //.auth = DM_AUTH_MITM_FLAG | DM_AUTH_BOND_FLAG | DM_AUTH_SC_FLAG, /*! Authentication and bonding flags */ + .auth = DM_AUTH_MITM_FLAG | DM_AUTH_BOND_FLAG, /*! Authentication and bonding flags */ + //.auth = 0, /*! Authentication and bonding flags */ .iKeyDist = 0, /*! Initiator key distribution flags */ .rKeyDist = DM_KEY_DIST_LTK, /*! Responder key distribution flags */ .oob=FALSE, /*! TRUE if Out-of-band pairing data is present */ @@ -86,11 +88,15 @@ static const appUpdateCfg_t bleUpdateCfg = static const smpCfg_t bleSmpCfg = { .attemptTimeout = 3000, /*! 'Repeated attempts' timeout in msec */ - .ioCap = SMP_IO_DISP_YES_NO, /*! I/O Capability */ + //.ioCap = SMP_IO_DISP_YES_NO, /*! I/O Capability */ + .ioCap = SMP_IO_DISP_ONLY, /*! I/O Capability */ + //.ioCap = SMP_IO_NO_IN_NO_OUT, /*! I/O Capability */ .minKeyLen = 16, /*! Minimum encryption key length */ .maxKeyLen = 16, /*! Maximum encryption key length */ .maxAttempts = 3, /*! Attempts to trigger 'repeated attempts' timeout */ - .auth = DM_AUTH_MITM_FLAG | DM_AUTH_SC_FLAG, /*! Device authentication requirements */ + //.auth = DM_AUTH_MITM_FLAG | DM_AUTH_SC_FLAG, /*! Device authentication requirements */ + .auth = DM_AUTH_MITM_FLAG, /*! Device authentication requirements */ + //.auth = 0, /*! Device authentication requirements */ .maxAttemptTimeout = 64000, /*! Maximum 'Repeated attempts' timeout in msec */ .attemptDecTimeout = 64000, /*! Time msec before attemptExp decreases */ .attemptExp = 2, /*! Exponent to raise attemptTimeout on maxAttempts */ @@ -99,7 +105,8 @@ static const smpCfg_t bleSmpCfg = /*! Configurable parameters for service and characteristic discovery */ static const appDiscCfg_t bleDiscCfg = { - FALSE /*! TRUE to wait for a secure connection before initiating discovery */ + //FALSE /*! TRUE to wait for a secure connection before initiating discovery */ + TRUE /*! TRUE to wait for a secure connection before initiating discovery */ }; /* Configuration structure */ diff --git a/epicardium/ble/epic_att_api.c b/epicardium/ble/epic_att_api.c index 3cd3ebf2be38d7b14ef7a004d96cd2eb297601c1..203bb231c7efbd85603f8edcd53a335d1f2c01f6 100644 --- a/epicardium/ble/epic_att_api.c +++ b/epicardium/ble/epic_att_api.c @@ -23,8 +23,26 @@ static void *dyn_groups[ATTS_DYN_GROUP_COUNT] = {}; static int next_dyn_group = 0; static int next_handle = ATTS_DYN_START_HANDLE; +static void hexdump(uint8_t *data, uint8_t len) +{ + for (int i = 0; i < len; i++) { + printf("%02x ", data[i]); + } + printf("\n"); +} + void ble_epic_att_api_event(attEvt_t *att_event) { + printf("att event handle %d %d\n", + att_event->handle, + att_event->continuing); + printf("att event handle %p %d %p %d\n", + att_event, + sizeof(*att_event), + att_event->pValue, + att_event->valueLen); + hexdump(att_event->pValue, att_event->valueLen); + if (att_event->hdr.event != ATTS_HANDLE_VALUE_CNF || (att_event->handle >= ATTS_DYN_START_HANDLE && att_event->handle < next_handle)) { diff --git a/epicardium/main.c b/epicardium/main.c index f4c7d9d94f3d135acc3d8de757e3143553829a72..2641f2f55e298598be33d712e1bc9ee70797ef35 100644 --- a/epicardium/main.c +++ b/epicardium/main.c @@ -51,7 +51,7 @@ int main(void) &display_screen, 0, 0, 160, 80, GFX_RGB565, version_splash ); - if (strcmp(CARD10_VERSION, "v1.16") != 0) { + if (strcmp(CARD10_VERSION, "v1.17") != 0) { const int off = (160 - (int)strlen(version_buf) * 14) / 2; epic_disp_print(10, 20, "Epicardium", 0xfe20, 0xfe20); epic_disp_print( diff --git a/epicardium/version-splash.png b/epicardium/version-splash.png index c9c8c648f1002a16bf35126b8b7a360a6f2abad5..d2dc8f7dc8222c53d487b78010f02a7186c4ee3d 100644 Binary files a/epicardium/version-splash.png and b/epicardium/version-splash.png differ diff --git a/lib/sdk/Libraries/BTLE/stack/ble-profiles/sources/apps/app/common/app_ui.c b/lib/sdk/Libraries/BTLE/stack/ble-profiles/sources/apps/app/common/app_ui.c index ae7ece902501c1b89672d0ab576684c24b4d0806..964ee566fffad2b1c16c5bbcfaef8502c35a4f25 100644 --- a/lib/sdk/Libraries/BTLE/stack/ble-profiles/sources/apps/app/common/app_ui.c +++ b/lib/sdk/Libraries/BTLE/stack/ble-profiles/sources/apps/app/common/app_ui.c @@ -167,7 +167,7 @@ void AppUiAction(uint8_t event) /*************************************************************************************************/ void AppUiDisplayPasskey(uint32_t passkey) { - APP_TRACE_INFO1(">>> Passkey: %d <<<", passkey); + printf(">>> Passkey: %d <<<", passkey); } /*************************************************************************************************/ diff --git a/pycardium/modules/modbluetooth_card10.c b/pycardium/modules/modbluetooth_card10.c index 932930d8b959c78a0f4bc04ae42f2688de6a71d3..1173eb3227efd19ac6c288a32f040c614b036dca 100644 --- a/pycardium/modules/modbluetooth_card10.c +++ b/pycardium/modules/modbluetooth_card10.c @@ -88,8 +88,31 @@ static void clear_events(void) } while (ret >= 0); } +#if 0 +#if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE +STATIC mp_obj_bluetooth_uuid_t create_mp_uuid(uint16_t uuid16, const uint8_t *uuid128) { + mp_obj_bluetooth_uuid_t result; + if (uuid16 != 0) { + result.data[0] = uuid16 & 0xff; + result.data[1] = (uuid16 >> 8) & 0xff; + result.type = MP_BLUETOOTH_UUID_TYPE_16; + } else { + reverse_128(uuid128, result.data); + result.type = MP_BLUETOOTH_UUID_TYPE_128; + } + return result; +} +#endif +#endif + static void handle_att_event(struct epic_att_event *att_event) { + printf("MP got att event %d,%d,%d,%d\n", + att_event->hdr.event, + att_event->hdr.status, + att_event->handle, + att_event->continuing); + if (att_event->hdr.event == ATTS_HANDLE_VALUE_CNF) { gatts_status_entry_t *e = gatts_status_lookup(GATTS_STATUS, att_event->handle); @@ -353,6 +376,8 @@ static void handle_att_event(struct epic_att_event *att_event) static void handle_dm_event(struct epic_dm_event *dm_event) { struct epic_wsf_header *hdr = (struct epic_wsf_header *)dm_event; + + printf("MP got DM event %d,%d\n", hdr->event, hdr->status); if (hdr->event == DM_CONN_OPEN_IND) { struct epic_hciLeConnCmpl_event *e = (struct epic_hciLeConnCmpl_event *)dm_event; @@ -885,6 +910,7 @@ int mp_bluetooth_gattc_write( mode != MP_BLUETOOTH_WRITE_MODE_NO_RESPONSE) { return MP_EINVAL; } + // create operation pending_gattc_operation_obj_t *op = m_new_obj_var( pending_gattc_operation_obj_t, uint8_t, *value_len ); @@ -894,12 +920,14 @@ int mp_bluetooth_gattc_write( op->mode = mode; op->value_len = *value_len; memcpy(op->value, value, *value_len); + // add operation to list mp_obj_list_append(ATTC_PENDING, MP_OBJ_FROM_PTR(op)); size_t len; mp_obj_t *items; mp_obj_list_get(ATTC_PENDING, &len, &items); + // is list size == 1: execute write if (len == 1) { if (mode == MP_BLUETOOTH_WRITE_MODE_NO_RESPONSE) { err = epic_ble_attc_write_no_rsp(