2017-02-27 06:26 AM
Hello,
I've got a problem with this program I can't send a character with an application btle 'Error 507' Displayed on the app.What's the problem?
/* mbed Microcontroller Library
DigitalOut led1(LED1, 1);
const static char DEVICE_NAME[] = 'HRM1'; static const uint16_t uuid16_list[] = {GattService::UUID_HEART_RATE_SERVICE};
static volatile bool triggerSensorPolling = false;
void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params) { (void)params; BLE::Instance().gap().startAdvertising(); restart advertising }
void periodicCallback(void) { led1 = !led1; /* Do blinky on LED1 while we're waiting for BLE events */ /* Note that the periodicCallback() executes in interrupt context, so it is safer to do
void onBleInitError(BLE &ble, ble_error_t error) { (void)ble; (void)error; /* Initialization error handling should go here */ }
void bleInitComplete(BLE::InitializationCompleteCallbackContext *params) { BLE& ble = params->ble; ble_error_t error = params->error;
if (error != BLE_ERROR_NONE) { onBleInitError(ble, error); return; }
if (ble.getInstanceID() != BLE::DEFAULT_INSTANCE) { return; }
ble.gap().onDisconnection(disconnectionCallback);
/* Setup primary service. */ uint8_t hrmCounter = 60; init HRM to 60bps HeartRateService hrService(ble, hrmCounter, HeartRateService::LOCATION_HAND);
/* Setup advertising. */ ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list)); ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::GENERIC_HEART_RATE_SENSOR); ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); ble.gap().setAdvertisingInterval(1000); /* 1000ms */ ble.gap().startAdvertising();
infinite loop while (true) { check for trigger from periodicCallback() if (triggerSensorPolling && ble.getGapState().connected) { triggerSensorPolling = false;
Do blocking calls or whatever is necessary for sensor polling. In our case, we simply update the HRM measurement. hrmCounter++;
60 <= HRM bps <= 100 if (hrmCounter == 100) { hrmCounter = 60; }
update bps hrService.updateHeartRate(hrmCounter); } else { ble.waitForEvent(); low power wait for event
} } } Serial BT(PA_2,PA_3); tx, rxb Serial pc(USBTX, USBRX); int main(void) { pc.baud(115200); BT.baud(115200); Ticker ticker; ticker.attach(periodicCallback, 1); blink LED every second
BLE::Instance().init(bleInitComplete); { while (BT.available() > 0) { read the incoming byte: char incomingByte = BT.readable(); printf('I received:'); BT.putc(incomingByte);
} } }
Thank you for your answers.
Alexandre Patras
#bluetooh #x-nucleo-idb05a1 #nucleo-stm32l476rg #mbed2017-02-28 02:30 AM
Hi Alexandre,
which STM32 Nucleo board are you using in your setup?
And what about the BLE board? Is it the X-NUCLEO-IDB05A1? Please notice that the old X-NUCLEO-IDB04A1 is not recommended any more.
Also, what application are you using on your phone? Is it the STM32 BLE Profiles? For which phone OS?
You may find additional information on the dedicated mbed pages for X-NUCLEO-IDB05A1:
https://developer.mbed.org/components/X-NUCLEO-IDB05A1-Bluetooth-Low-Energy/
Depending on the STM32 Nucleo board you are using, please make sure you check the note about Arduino Connector Compatibility.
Best regards,
Antonio
2017-02-28 02:55 AM
Hi Vilei.Antonio,
I use a Nucleo STM32-L476RG with the bluetooth expansion
the X-NUCLEO-IDB05A1 and i use a Samsung galaxy S4 with this application.
Best regards,
Alexandre
2017-03-02 10:32 AM
Dear Alexandre,
the error code that you get is related to your smartphone app, which is not developed by ST, so I don't know what that error code means.
Anyway, your STM32 code implements the Heart Rate Monitor (HRM) profile, i.e. it simulates sending heart rate information from your device to your phone.
In your app, you're trying to send some arbitrary text to the BLE device (which is not expecting it) and this is probably why you're getting an error.
If you want to test the correct behavior of your board, you can use the STM32 BLE Profiles app:
https://play.google.com/store/apps/details?id=com.stm.bluetoothlevalidation
Hope that helps,
Antonio
2017-03-02 10:58 AM
My objective is to display on a display the temperature and the pressure of a room with the
Nucleo STM32-L476RG in bluetooth communication with
the X-NUCLEO-IDB05A1 using the mbed online software and I don't know how to do it ?
If you can help me,
Alexandre