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.
Dependents: Hello_BLE F446RE-BLE
Fork of X_NUCLEO_IDB0XA1 by
Revision 3:9c4c13795643, committed 2014-07-21
- Comitter:
- mridup
- Date:
- Mon Jul 21 14:10:22 2014 +0000
- Parent:
- 2:a2b623661316
- Child:
- 4:fa5b5693c1b5
- Commit message:
- Advertising working with setAdvertisingData (DEVICE NAME). Hard-coded implementation.
Changed in this revision
--- a/BlueNRGGap.cpp Mon Jul 21 08:28:47 2014 +0000
+++ b/BlueNRGGap.cpp Mon Jul 21 14:10:22 2014 +0000
@@ -17,6 +17,8 @@
#include "BlueNRGDevice.h"
#include "mbed.h"
+//Local Variables
+const uint8_t *device_name;
/**************************************************************************/
/*!
@@ -67,7 +69,13 @@
return BLE_ERROR_PARAM_OUT_OF_RANGE;
}
-
+ //set the advData here in some local variable so that startAdvertising can use it.
+ if (advData.getPayloadLen() > 0) {
+ const uint8_t *payload = advData.getPayload();
+ device_name = advData.getPayload();
+ }
+
+
return BLE_ERROR_NONE;
}
@@ -127,7 +135,9 @@
tBleStatus ret;
- const char local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME,'B','l','u','e','N','R','G'};
+ //const char local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME,'B','l','u','e','N','R','G'};
+ const char local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME,device_name[5],device_name[6],device_name[7],device_name[8], device_name[9],
+ device_name[10], device_name[11], device_name[12]};
/* disable scan response */
hci_le_set_scan_resp_data(0,NULL);
@@ -137,7 +147,7 @@
/*LINK_LAYER.H DESCRIBES THE ADVERTISING TYPES*/
ret = aci_gap_set_discoverable(params.getAdvertisingType(), params.getInterval(), 0, PUBLIC_ADDR, NO_WHITE_LIST_USE,
- 8, local_name, 0, NULL, 0, 0);
+ 9 /*Length of the local_name[] array*/, local_name, 0, NULL, 0, 0);
return BLE_ERROR_NONE;
--- a/BlueNRGGap.h Mon Jul 21 08:28:47 2014 +0000
+++ b/BlueNRGGap.h Mon Jul 21 14:10:22 2014 +0000
@@ -57,9 +57,12 @@
tBleStatus ret;
//const char local_name[];// = {AD_TYPE_COMPLETE_LOCAL_NAME,'B','l','u','e','N','R','G'};
+ //Local Variables
+ //uint8_t *device_name;
BlueNRGGap() {
m_connectionHandle = BLE_CONN_HANDLE_INVALID;
//local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME,'B','l','u','e','N','R','G'};
+
}
BlueNRGGap(BlueNRGGap const &);
--- a/btle/src/btle.cpp Mon Jul 21 08:28:47 2014 +0000
+++ b/btle/src/btle.cpp Mon Jul 21 14:10:22 2014 +0000
@@ -35,7 +35,6 @@
#include <stdio.h>
#include <string.h>
#include <stm32l0xx_bluenrg_shield_bsp.h>
-//#include "sensor_service.h"
#include "role_type.h"
#include "debug.h"
@@ -151,14 +150,57 @@
extern "C" {
#endif
-extern void HCI_Event_CB(void *ptr) {
- int a=3;
- int b=5;
+extern void HCI_Event_CB(void *pckt) {
+
+ hci_uart_pckt *hci_pckt = (hci_uart_pckt*)pckt;
+ hci_event_pckt *event_pckt = (hci_event_pckt*)hci_pckt->data;
- int sum = a+b;
+ if(hci_pckt->type != HCI_EVENT_PKT)
+ return;
+
+ switch(event_pckt->evt){
+
+ case EVT_DISCONN_COMPLETE:
+ {
+ //GAP_DisconnectionComplete_CB();
+ }
+ break;
+
+ case EVT_LE_META_EVENT:
+ {
+ evt_le_meta_event *evt = (evt_le_meta_event *)event_pckt->data;
+
+ switch(evt->subevent){
+ case EVT_LE_CONN_COMPLETE:
+ {
+ //evt_le_connection_complete *cc = (void *)evt->data;
+ //GAP_ConnectionComplete_CB(cc->peer_bdaddr, cc->handle);
+ }
+ break;
+ }
+ }
+ break;
+
+ case EVT_VENDOR:
+ {
+ evt_blue_aci *blue_evt = (evt_blue_aci*)event_pckt->data;
+ switch(blue_evt->ecode){
+
+ case EVT_BLUE_GATT_READ_PERMIT_REQ:
+ {
+ //evt_gatt_read_permit_req *pr = (void*)blue_evt->data;
+ //Read_Request_CB(pr->attr_handle);
+ }
+ break;
+ }
+ }
+ break;
+ }
return ;
- }
+}
+
+
#ifdef __cplusplus
}
#endif
\ No newline at end of file
