Merge pull request #2741 from tannewt/fix_packetbuffer_server

Fix PacketBuffer server support
crypto-aes
Scott Shawcroft 3 years ago committed by GitHub
commit cbe9512691
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      locale/ID.po
  2. 7
      locale/circuitpython.pot
  3. 7
      locale/de_DE.po
  4. 7
      locale/en_US.po
  5. 7
      locale/en_x_pirate.po
  6. 7
      locale/es.po
  7. 7
      locale/fil.po
  8. 7
      locale/fr.po
  9. 7
      locale/it_IT.po
  10. 7
      locale/ko.po
  11. 7
      locale/pl.po
  12. 7
      locale/pt_BR.po
  13. 7
      locale/zh_Latn_pinyin.po
  14. 3
      ports/nrf/common-hal/_bleio/Connection.c
  15. 14
      ports/nrf/common-hal/_bleio/PacketBuffer.c
  16. 7
      shared-bindings/_bleio/PacketBuffer.c

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-20 17:57-0500\n"
"POT-Creation-Date: 2020-03-30 17:03-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -398,6 +398,11 @@ msgstr ""
msgid "Buffer too large and unable to allocate"
msgstr ""
#: shared-bindings/_bleio/PacketBuffer.c
#, c-format
msgid "Buffer too short by %d bytes"
msgstr ""
#: ports/atmel-samd/common-hal/displayio/ParallelBus.c
#: ports/nrf/common-hal/displayio/ParallelBus.c
#, fuzzy, c-format

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-20 17:57-0500\n"
"POT-Creation-Date: 2020-03-30 17:03-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -394,6 +394,11 @@ msgstr ""
msgid "Buffer too large and unable to allocate"
msgstr ""
#: shared-bindings/_bleio/PacketBuffer.c
#, c-format
msgid "Buffer too short by %d bytes"
msgstr ""
#: ports/atmel-samd/common-hal/displayio/ParallelBus.c
#: ports/nrf/common-hal/displayio/ParallelBus.c
#, c-format

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-20 17:57-0500\n"
"POT-Creation-Date: 2020-03-30 17:03-0700\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: Pascal Deneaux\n"
"Language-Team: Sebastian Plamauer, Pascal Deneaux\n"
@ -398,6 +398,11 @@ msgstr "Der Puffer muss eine Mindestenslänge von 1 haben"
msgid "Buffer too large and unable to allocate"
msgstr ""
#: shared-bindings/_bleio/PacketBuffer.c
#, c-format
msgid "Buffer too short by %d bytes"
msgstr ""
#: ports/atmel-samd/common-hal/displayio/ParallelBus.c
#: ports/nrf/common-hal/displayio/ParallelBus.c
#, c-format

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-20 17:57-0500\n"
"POT-Creation-Date: 2020-03-30 17:03-0700\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -394,6 +394,11 @@ msgstr ""
msgid "Buffer too large and unable to allocate"
msgstr ""
#: shared-bindings/_bleio/PacketBuffer.c
#, c-format
msgid "Buffer too short by %d bytes"
msgstr ""
#: ports/atmel-samd/common-hal/displayio/ParallelBus.c
#: ports/nrf/common-hal/displayio/ParallelBus.c
#, c-format

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-20 17:57-0500\n"
"POT-Creation-Date: 2020-03-30 17:03-0700\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: @sommersoft, @MrCertainly\n"
@ -398,6 +398,11 @@ msgstr ""
msgid "Buffer too large and unable to allocate"
msgstr ""
#: shared-bindings/_bleio/PacketBuffer.c
#, c-format
msgid "Buffer too short by %d bytes"
msgstr ""
#: ports/atmel-samd/common-hal/displayio/ParallelBus.c
#: ports/nrf/common-hal/displayio/ParallelBus.c
#, c-format

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-20 17:57-0500\n"
"POT-Creation-Date: 2020-03-30 17:03-0700\n"
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -400,6 +400,11 @@ msgstr "Buffer debe ser de longitud 1 como minimo"
msgid "Buffer too large and unable to allocate"
msgstr ""
#: shared-bindings/_bleio/PacketBuffer.c
#, c-format
msgid "Buffer too short by %d bytes"
msgstr ""
#: ports/atmel-samd/common-hal/displayio/ParallelBus.c
#: ports/nrf/common-hal/displayio/ParallelBus.c
#, c-format

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-20 17:57-0500\n"
"POT-Creation-Date: 2020-03-30 17:03-0700\n"
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
@ -400,6 +400,11 @@ msgstr "Buffer dapat ay hindi baba sa 1 na haba"
msgid "Buffer too large and unable to allocate"
msgstr ""
#: shared-bindings/_bleio/PacketBuffer.c
#, c-format
msgid "Buffer too short by %d bytes"
msgstr ""
#: ports/atmel-samd/common-hal/displayio/ParallelBus.c
#: ports/nrf/common-hal/displayio/ParallelBus.c
#, fuzzy, c-format

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-20 17:57-0500\n"
"POT-Creation-Date: 2020-03-30 17:03-0700\n"
"PO-Revision-Date: 2019-04-14 20:05+0100\n"
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
"Language-Team: fr\n"
@ -404,6 +404,11 @@ msgstr "Le tampon doit être de longueur au moins 1"
msgid "Buffer too large and unable to allocate"
msgstr ""
#: shared-bindings/_bleio/PacketBuffer.c
#, c-format
msgid "Buffer too short by %d bytes"
msgstr ""
#: ports/atmel-samd/common-hal/displayio/ParallelBus.c
#: ports/nrf/common-hal/displayio/ParallelBus.c
#, fuzzy, c-format

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-20 17:57-0500\n"
"POT-Creation-Date: 2020-03-30 17:03-0700\n"
"PO-Revision-Date: 2018-10-02 16:27+0200\n"
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
"Language-Team: \n"
@ -400,6 +400,11 @@ msgstr "Il buffer deve essere lungo almeno 1"
msgid "Buffer too large and unable to allocate"
msgstr ""
#: shared-bindings/_bleio/PacketBuffer.c
#, c-format
msgid "Buffer too short by %d bytes"
msgstr ""
#: ports/atmel-samd/common-hal/displayio/ParallelBus.c
#: ports/nrf/common-hal/displayio/ParallelBus.c
#, fuzzy, c-format

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-20 17:57-0500\n"
"POT-Creation-Date: 2020-03-30 17:03-0700\n"
"PO-Revision-Date: 2019-05-06 14:22-0700\n"
"Last-Translator: \n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -398,6 +398,11 @@ msgstr "잘못된 크기의 버퍼. >1 여야합니다"
msgid "Buffer too large and unable to allocate"
msgstr ""
#: shared-bindings/_bleio/PacketBuffer.c
#, c-format
msgid "Buffer too short by %d bytes"
msgstr ""
#: ports/atmel-samd/common-hal/displayio/ParallelBus.c
#: ports/nrf/common-hal/displayio/ParallelBus.c
#, c-format

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-20 17:57-0500\n"
"POT-Creation-Date: 2020-03-30 17:03-0700\n"
"PO-Revision-Date: 2019-03-19 18:37-0700\n"
"Last-Translator: Radomir Dopieralski <circuitpython@sheep.art.pl>\n"
"Language-Team: pl\n"
@ -397,6 +397,11 @@ msgstr "Bufor musi mieć długość 1 lub więcej"
msgid "Buffer too large and unable to allocate"
msgstr ""
#: shared-bindings/_bleio/PacketBuffer.c
#, c-format
msgid "Buffer too short by %d bytes"
msgstr ""
#: ports/atmel-samd/common-hal/displayio/ParallelBus.c
#: ports/nrf/common-hal/displayio/ParallelBus.c
#, c-format

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-20 17:57-0500\n"
"POT-Creation-Date: 2020-03-30 17:03-0700\n"
"PO-Revision-Date: 2018-10-02 21:14-0000\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -397,6 +397,11 @@ msgstr ""
msgid "Buffer too large and unable to allocate"
msgstr ""
#: shared-bindings/_bleio/PacketBuffer.c
#, c-format
msgid "Buffer too short by %d bytes"
msgstr ""
#: ports/atmel-samd/common-hal/displayio/ParallelBus.c
#: ports/nrf/common-hal/displayio/ParallelBus.c
#, fuzzy, c-format

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: circuitpython-cn\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-20 17:57-0500\n"
"POT-Creation-Date: 2020-03-30 17:03-0700\n"
"PO-Revision-Date: 2019-04-13 10:10-0700\n"
"Last-Translator: hexthat\n"
"Language-Team: Chinese Hanyu Pinyin\n"
@ -403,6 +403,11 @@ msgstr "Huǎnchōng qū bìxū zhìshǎo chángdù 1"
msgid "Buffer too large and unable to allocate"
msgstr "huǎn chōng qū tài dà , wú fǎ fēn pèi"
#: shared-bindings/_bleio/PacketBuffer.c
#, c-format
msgid "Buffer too short by %d bytes"
msgstr ""
#: ports/atmel-samd/common-hal/displayio/ParallelBus.c
#: ports/nrf/common-hal/displayio/ParallelBus.c
#, c-format

@ -162,7 +162,8 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) {
self->do_bond_cccds = true;
self->do_bond_cccds_request_time = supervisor_ticks_ms64();
}
break;
// Return false so other handlers get this event as well.
return false;
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
sd_ble_gatts_sys_attr_set(self->conn_handle, NULL, 0, 0);

@ -148,6 +148,7 @@ STATIC bool packet_buffer_on_ble_server_evt(ble_evt_t *ble_evt, void *param) {
// A client wrote to this server characteristic.
ble_gatts_evt_write_t *evt_write = &ble_evt->evt.gatts_evt.params.write;
// Event handle must match the handle for my characteristic.
if (evt_write->handle == self->characteristic->handle) {
if (self->conn_handle == BLE_CONN_HANDLE_INVALID) {
@ -156,8 +157,7 @@ STATIC bool packet_buffer_on_ble_server_evt(ble_evt_t *ble_evt, void *param) {
return false;
}
write_to_ringbuf(self, evt_write->data, evt_write->len);
} else if (evt_write->handle == self->characteristic->cccd_handle &&
self->conn_handle == BLE_CONN_HANDLE_INVALID) {
} else if (evt_write->handle == self->characteristic->cccd_handle) {
uint16_t cccd = *((uint16_t*) evt_write->data);
if (cccd & BLE_GATT_HVX_NOTIFICATION) {
self->conn_handle = conn_handle;
@ -167,6 +167,11 @@ STATIC bool packet_buffer_on_ble_server_evt(ble_evt_t *ble_evt, void *param) {
}
break;
}
case BLE_GAP_EVT_DISCONNECTED: {
if (self->conn_handle == conn_handle) {
self->conn_handle = BLE_CONN_HANDLE_INVALID;
}
}
case BLE_GATTS_EVT_HVN_TX_COMPLETE: {
queue_next_write(self);
}
@ -192,6 +197,8 @@ void common_hal_bleio_packet_buffer_construct(
incoming = outgoing;
outgoing = temp;
self->conn_handle = bleio_connection_get_conn_handle(MP_OBJ_TO_PTR(self->characteristic->service->connection));
} else {
self->conn_handle = BLE_CONN_HANDLE_INVALID;
}
if (incoming) {
@ -255,8 +262,7 @@ int common_hal_bleio_packet_buffer_readinto(bleio_packet_buffer_obj_t *self, uin
sd_nvic_critical_region_enter(&is_nested_critical_region);
if (packet_length > len) {
// TODO: raise an exception.
packet_length = len;
return len - packet_length;
}
ringbuf_get_n(&self->ringbuf, data, packet_length);

@ -109,7 +109,12 @@ STATIC mp_obj_t bleio_packet_buffer_readinto(mp_obj_t self_in, mp_obj_t buffer_o
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(buffer_obj, &bufinfo, MP_BUFFER_WRITE);
return MP_OBJ_NEW_SMALL_INT(common_hal_bleio_packet_buffer_readinto(self, bufinfo.buf, bufinfo.len));
int size = common_hal_bleio_packet_buffer_readinto(self, bufinfo.buf, bufinfo.len);
if (size < 0) {
mp_raise_ValueError_varg(translate("Buffer too short by %d bytes"), size * -1);
}
return MP_OBJ_NEW_SMALL_INT(size);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_packet_buffer_readinto_obj, bleio_packet_buffer_readinto);

Loading…
Cancel
Save