complete bufferTXD() for bleuart

- reduce default max connection interval from 40 to 30 ms
- finish firmata port
This commit is contained in:
hathach committed 2017-07-28 01:44:51 +07:00
1 parent 2528b45480
commit b8beb424de
8 files changed
+493 -32

No files matched your search

@@ -500,6 +500,7 @@ bool BLECharacteristic::notify(const void* data, uint16_t len)
.p_data = (uint8_t*) u8data,
};
LOG_LV2(CHR, "Notify %d bytes", packet_len);
VERIFY_STATUS( sd_ble_gatts_hvx(Bluefruit.connHandle(), &hvx_params), false );
remaining -= packet_len;
@@ -49,7 +49,7 @@
#define BLE_GAP_CONN_SLAVE_LATENCY 0
#define BLE_GAP_CONN_MIN_INTERVAL_DFLT MS100TO125(20)
#define BLE_GAP_CONN_MAX_INTERVAL_DFLT MS100TO125(40)
#define BLE_GAP_CONN_MAX_INTERVAL_DFLT MS100TO125(30)
// Converts an integer of 1.25ms units to msecs
#define MS100TO125(ms100) (((ms100)*4)/5)
@@ -71,7 +71,7 @@ BLEUart::BLEUart(uint16_t fifo_depth)
{
_rx_cb = NULL;
_tx_buffered = false;
_tx_buffered = 0;
_buffered_th = NULL;
_tx_fifo = NULL;
@@ -114,7 +114,7 @@ void bleuart_txd_buffered_hdlr(TimerHandle_t timer)
// skip if null (unlikely)
if ( !svc->_tx_fifo ) return;
// flush data (send notiication)
// flush tx data
svc->flush_tx_buffered();
}
@@ -144,7 +144,7 @@ void BLEUart::setRxCallback( rx_callback_t fp)
* Note: packet is sent right away if it reach MTU bytes
* @param enable true or false
*/
void BLEUart::bufferTXD(bool enable)
void BLEUart::bufferTXD(uint8_t enable)
{
_tx_buffered = enable;
@@ -206,6 +206,8 @@ void BLEUart::_disconnect_cb(void)
{
xTimerDelete(_buffered_th, 0);
_buffered_th = NULL;
if (_tx_fifo) _tx_fifo->clear();
}
}
@@ -213,8 +215,9 @@ void BLEUart::_connect_cb (void)
{
if ( _tx_buffered)
{
// create buffered timer with interval = connection interval
_buffered_th = xTimerCreate(NULL, (5*ms2tick(Bluefruit.connInterval())) / 4, true, this, bleuart_txd_buffered_hdlr);
// create TXD timer TODO take connInterval into account
// ((5*ms2tick(Bluefruit.connInterval())) / 4) / 2
_buffered_th = xTimerCreate(NULL, ms2tick(10), true, this, bleuart_txd_buffered_hdlr);
}
}
@@ -61,7 +61,7 @@ class BLEUart : public BLEService, public Stream
bool notifyEnabled(void);
void setRxCallback( rx_callback_t fp);
void bufferTXD(bool enable);
void bufferTXD(uint8_t enable);
// Stream API
virtual int read ( void );
@@ -83,10 +83,9 @@ class BLEUart : public BLEService, public Stream
Adafruit_FIFO _rx_fifo;
rx_callback_t _rx_cb;
bool _tx_buffered;
TimerHandle_t _buffered_th;
Adafruit_FIFO* _tx_fifo;
uint8_t _tx_buffered;
TimerHandle_t _buffered_th;
Adafruit_FIFO* _tx_fifo;
bool flush_tx_buffered(void);