Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: libnsdl_m0 BLE_API Base64 nRF51822 SplitterAssembler
Revision 35:71eb3663ecbd, committed 2015-09-04
- Comitter:
- ansond
- Date:
- Fri Sep 04 21:04:08 2015 +0000
- Parent:
- 34:7b4560f7c3c7
- Child:
- 36:aa73681951ad
- Child:
- 37:64cab752e428
- Commit message:
- update for android 5.x. A wait() call is necessary for 5.x prior to write().
Changed in this revision
--- a/bt_network/BleUartRPC/Dispatcher.cpp Mon Jul 27 03:00:13 2015 +0000
+++ b/bt_network/BleUartRPC/Dispatcher.cpp Fri Sep 04 21:04:08 2015 +0000
@@ -93,19 +93,28 @@
}
// return the length
+ //DBG("dispatcher(): sent %d bytes\r\n",length);
return length;
}
else if (send_ack) {
- // just send and ack as we received something...
+ // just send and ack as we received something...
+ //DBG("dispatcher(): sending ACK...\r\n");
return this->uart_write((uint8_t *)"ACK\n",4);
}
else {
// nothing to send
+ //DBG("dispatcher(): nothing to send()...\r\n");
return 0;
}
}
int Dispatcher::uart_write(uint8_t *data,int data_length) {
+ // 9/4/15: Android 5.x appears to have some sort of poor-mans DDoS detector in its BLE stack so we have to slow things down a bit..
+ #ifdef ANDROID_BLE_DELAY
+ wait_ms(ANDROID_BLE_DELAY_MS);
+ #endif
+
+ // OK... now write to UART...
return this->m_uart.write(data,data_length);
}
--- a/bt_network/BleUartRPC/Dispatcher.h Mon Jul 27 03:00:13 2015 +0000
+++ b/bt_network/BleUartRPC/Dispatcher.h Fri Sep 04 21:04:08 2015 +0000
@@ -35,6 +35,10 @@
// This is aligned with the value of DEF_FRAGMENT_LENGTH in SplitterAssembler.h and is also the max UART MTU for BLE
#define UART_SEGMENT_LENGTH 20 // BLE: max UART MTU (will trigger send immediately...)
+ // 9/4/15: Android 5.x appears to have some sort of poor-mans DDoS detector in its BLE stack so we have to slow things down a bit..
+ #define ANDROID_BLE_DELAY true // true to enable slow down, false to disable
+ #define ANDROID_BLE_DELAY_MS 500 // delay time (in ms), if enabled, to allow android 5.x to catch up...
+
class Dispatcher {
public:
/**
--- a/bt_network/BleUartRPC/UartRPC.cpp Mon Jul 27 03:00:13 2015 +0000
+++ b/bt_network/BleUartRPC/UartRPC.cpp Fri Sep 04 21:04:08 2015 +0000
@@ -204,7 +204,9 @@
}
// accumulate to dispatch locally...
- bool UartRPC::accumulate(uint8_t *buffer,int buffer_length) {
+ bool UartRPC::accumulate(uint8_t *buffer,int buffer_length) {
+ //DBG("UartRPC:: accumulating... [%s] length=%d bytes...\r\n",buffer,buffer_length);
+
// add to the accumulator
this->m_recv_accumulator.add(buffer,buffer_length);
--- a/bt_network/BleUartRPC/UartRPCFunctions.cpp Mon Jul 27 03:00:13 2015 +0000
+++ b/bt_network/BleUartRPC/UartRPCFunctions.cpp Fri Sep 04 21:04:08 2015 +0000
@@ -42,13 +42,14 @@
{
uint8_t response[2];
memset(response,0,2);
+ //DBG("ble_rpc_open_udp_socket: UDP Socket open() dispatching...\r\n");
if (__rpc->dispatch(SOCKET_OPEN_FN,(void *)cb,response,2,"%s %d",ip_address,port) > 0) {
- //DBG("ble_rpc_open_udp_socket: dispatched successfully. Waiting on status...\r\n");
+ //DBG("ble_rpc_open_udp_socket: UDP Socket open() dispatched SUCCESSFULLY\r\n");
return true;
}
// failure
- DBG("ble_rpc_open_udp_socket: dispatch() failed\r\n");
+ //DBG("ble_rpc_open_udp_socket: UDP Socket open() dispatch failed\r\n");
return false;
}
@@ -56,13 +57,14 @@
{
uint8_t response[2];
memset(response,0,2);
+ //DBG("ble_rpc_open_udp_socket: UDP Socket close() dispatched successfully. Waiting on response...\r\n");
if (__rpc->dispatch(SOCKET_CLOSE_FN,NULL,response,2,"%s","loc") > 0) {
- DBG("ble_rpc_close_udp_socket: success...\r\n");
+ //DBG("ble_rpc_close_udp_socket: UDP Socket close() dispatched SUCCESSFULLY\r\n");
return true;
}
// failure
- DBG("ble_rpc_close_udp_socket: dispatch() failed\r\n");
+ //DBG("ble_rpc_close_udp_socket: UDP Socket close() dispatch failed\r\n");
return false;
}
--- a/network_stubs/network_stubs.cpp Mon Jul 27 03:00:13 2015 +0000
+++ b/network_stubs/network_stubs.cpp Fri Sep 04 21:04:08 2015 +0000
@@ -93,6 +93,12 @@
}
}
+// BLE Timeout callback
+void ble_timeout_callback(void)
+{
+ DBG("BLE TIMEOUT OCCURED\r\n");
+}
+
// BLE Init
void ble_init(void)
{
@@ -101,6 +107,7 @@
ble.init();
ble.onDisconnection(ble_disconnect_callback);
ble.onConnection(ble_connect_callback);
+ ble.onTimeout(ble_timeout_callback);
}
// BLE Begin Advertising