Open fabiencomte opened 8 years ago
please see this post.
https://devzone.nordicsemi.com/question/49705/s130-potential-unstability-case/
I'm not totally sure that is due to S130. Does anyone have an idea ?
thanks for pointing us to this discussion. I'm afraid your application is a bit too large for me to review it carefully. Raise this again if no resolution comes about in a few days and I'll try to review.
I rewritten a pure nordic sdk test application and it works... So there s130 looks correct and the bug is probably in mbed lib side.
Envoyé depuis Yahoo Mail pour Android
De:"Rohit Grover" notifications@github.com Date:mar. j sept. PM à 14:12 Objet:Re: [ble-nrf51822] Cross effect when central and device and unexpected disconnections (#46)
thanks for pointing us to this discussion. I'm afraid your application is a bit too large for me to review it carefully. Raise this again if no resolution comes about in a few days and I'll try to review.
— Reply to this email directly or view it on GitHub.
ok. very good. can you please try replacing Nordic SDK APIs with BLE_API in small steps and see where the failure arises?
Hello, i'm late on my project so i will try to do that in... few weeks. I'm moving to Nordic SDK to be on schedule.
That's a pity. The BLE_API is a thin wrapper around the Nordic SDK and should not result in loss of capability. I hope you find time to uncover the particular issue with BLE_API (if any) which prevented you from developing your application--that would be a very helpful contribution to the rest of the community. We look forward to supporting you in your development.
ARM Internal Ref: IOTSFW-1026
This code to a test triangle with 3 boards.
link 1: board A is central, board B is device link 2: board B is central, board C is device link 3: board C is central, board A is device
every time a char is received on serial port of a board, it's reported to the serial ports of the 2 other boards connected.
It works not so bad but depending on connections order, some half links are not working.
For the boards that did first connection as central and second as device, both TX are working. For the boards that did first connection as device and second as central, half TX are working.
After 20 to 30 s, unexpected disconnections are reported.
include "mbed.h"
include "BLE.h"
include "UARTService.h"
include "ble/DiscoveredCharacteristic.h"
include "ble/DiscoveredService.h"
include "UARTService.h"
define SOFT_DEVICE_FATHER_HANDLE 3
define BOARDS_COUNT 3
const Gap::Address_t mac_board_0 = {0xb8, 0xac, 0x4e, 0x8d, 0x8b, 0xeb}; const Gap::Address_t mac_board_1 = {0x9c, 0x43, 0x62, 0x30, 0xaf, 0xd2}; const Gap::Address_t mac_board_2 = {0x5f, 0x1a, 0x9e, 0x6a, 0x63, 0xdd};
// tiny ble board
define LED_GREEN p21
define LED_RED p22
define LED_BLUE p23
define BUTTON_PIN p17
define BATTERY_PIN p1
define MPU6050_SDA p12
define MPU6050_SCL p13
define UART_TX p9
define UART_RX p11
define UART_CTS p8
define UART_RTS p10
DigitalOut led(LED_RED); DigitalOut alivenessLED(LED_GREEN); InterruptIn button(BUTTON_PIN); AnalogIn battery(BATTERY_PIN); Serial pc(UART_TX, UART_RX);
bool mac_equals(const Gap::Address_t mac_1, const Gap::Address_t mac_2) {
if 0
}
int get_board_index(const Gap::Address_t mac) { if (mac_equals(mac, mac_board_0)) { return 0; } if (mac_equals(mac, mac_board_1)) { return 1; } if (mac_equals(mac, mac_board_2)) { return 2; }
}
void periodicCallback(void) { alivenessLED = !alivenessLED; /* do blinky on alivenessLED while we're waiting for BLE events */ }
// Mixed role **** BLE ble; Gap::Address_t my_mac; int my_board_index = -1;
// Device role **** UARTService * uartServicePtr = NULL; const static char DEVICE_NAME[] = "ChangeMe!!"; // change this static const uint16_t uuid16_list[] = {UARTServiceShortUUID}; volatile int central_handle = -1;
// Central role **** Gap::Handle_t connectionHandle = 0xFFFF; DiscoveredCharacteristic uartTXCharacteristic; DiscoveredCharacteristic uartRXCharacteristic; bool foundUartRXCharacteristic = false; volatile int device_handle = -1;
// Device role **** void onReceivedDataFromCentralCallback(const GattWriteCallbackParams *params) { if (uartServicePtr != NULL) { if ((params->handle == uartServicePtr->getTXCharacteristicHandle()) && (params->len >= 1)) { if (params->data[0] != '0') { led = 1; } else { led = 0; }
}
// Central role **** void advertisementCallback(const Gap::AdvertisementCallbackParams_t *params) { // do connections like a triangle int peer_board_index = get_board_index(params->peerAddr);
}
void serviceDiscoveryCallback(const DiscoveredService service) { if (service->getUUID().shortOrLong() == UUID::UUID_TYPE_SHORT) { //pc.printf("S UUID-%x attrs[%u %u]\r\n", service->getUUID().getShortUUID(), service->getStartHandle(), service->getEndHandle()); } else { //pc.printf("S UUID-"); const uint8_t longUUIDBytes = service->getUUID().getBaseUUID(); for (unsigned i = 0; i < UUID::LENGTH_OF_LONG_UUID; i++) { //pc.printf("%02x", longUUIDBytes[i]); } //pc.printf(" attrs[%u %u]\r\n", service->getStartHandle(), service->getEndHandle()); } }
void characteristicDiscoveryCallback(const DiscoveredCharacteristic _characteristicP) { //pc.printf(" C UUID-%x valueAttr[%u] props[%x]\r\n", characteristicP->getUUID().getShortUUID(), characteristicP->getValueHandle(), (uint8t)characteristicP->getProperties().broadcast()); if (characteristicP->getUUID().getShortUUID() == UARTServiceTXCharacteristicShortUUID) { //pc.printf("fit TX 0x%04x\r\n", UARTServiceTXCharacteristicShortUUID); / !ALERT! Alter this filter to suit your device. / uartTXCharacteristic = *characteristicP; } else if (characteristicP->getUUID().getShortUUID() == UARTServiceRXCharacteristicShortUUID) { //pc.printf("fit RX 0x%04x\r\n", UARTServiceRXCharacteristicShortUUID); / !ALERT! Alter this filter to suit your device. / uartRXCharacteristic = characteristicP; foundUartRXCharacteristic = true; } }
void discoveryTerminationCallback(Gap::Handle_t connectionHandle) { pc.printf("terminated SD for handle %u\r\n", connectionHandle); }
void onReceivedDataFromDeviceCallback(const GattHVXCallbackParams *params) { //pc.printf("received HVX callback for handle %u; type %s\r\r\n", params->handle, (params->type == BLE_HVX_NOTIFICATION) ? "notification" : "indication"); if (params->type == BLE_HVX_NOTIFICATION) { if ((params->handle == uartRXCharacteristic.getValueHandle()) && (params->len > 0)) { for (int i = 0; i < params->len; i++) { pc.printf("%c", params->data[i]); }
}
// Mixed role **** void connectionCallback(const Gap::ConnectionCallbackParams_t _params) { if (params->role == Gap::CENTRAL) { devicehandle = params->handle; pc.printf("connected as central (handle = %d)\r\n\r", params->handle); connectionHandle = params->handle; ble.gattClient().onServiceDiscoveryTermination(discoveryTerminationCallback); ble.gattClient().launchServiceDiscovery(params->handle, serviceDiscoveryCallback, characteristicDiscoveryCallback/, 0xa000, 0xa001*/); } else { central_handle = params->handle; pc.printf("connected as device (handle = %d)\r\n\r", params->handle);
}
void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason) { pc.printf("disconnected (handle = %d)\r\n", handle);
}
void serialTxCallback() {
}
int rx_char = -1; void serialRxCallback() {
if (rx_char != -1) { pc.printf("overflow\r\n"); }
}
/* volatile bool gatt_server_is_busy = false;
void gattServerOnDataSent(unsigned count) { gatt_server_is_busy = false; } */
int main(void) { alivenessLED = 0;
}