BLE lib
Fork of Nucleo_BLE_BlueNRG by
Diff: btle/src/btle.cpp
- Revision:
- 4:c8ed8022e996
- Parent:
- 3:89230b3e003b
- Child:
- 5:beb2c7544ce4
--- a/btle/src/btle.cpp Tue Jan 20 12:11:36 2015 +0000 +++ b/btle/src/btle.cpp Sat Jan 31 12:22:24 2015 +0000 @@ -47,6 +47,8 @@ } #endif +// Pas Beau du tout +extern int8_t ctrl_byte; static void btle_handler(/*ble_evt_t * p_ble_evt*/); void HCI_Input(tHciDataPacket * hciReadPacket); @@ -190,6 +192,8 @@ if(hci_pckt->type != HCI_EVENT_PKT) return; + DEBUG("-->HCI Event %d\n\r", event_pckt->evt); + switch(event_pckt->evt){ case EVT_DISCONN_COMPLETE: @@ -239,12 +243,12 @@ evt_gatt_attr_modified *evt = (evt_gatt_attr_modified*)blue_evt->data; DEBUG("EVT_BLUE_GATT_ATTRIBUTE_MODIFIED\n\r"); //DEBUG("CharHandle 0x%x, length: 0x%x, Data: 0x%x\n\r",evt->attr_handle, evt->data_length, (uint16_t)evt->att_data[0]); - DEBUG("CharHandle %d, length: %d, Data: %d\n\r",evt->attr_handle, evt->data_length, (uint16_t)evt->att_data[0]); + DEBUG(" CharHandle %d, length: %d, Data: %d\n\r",evt->attr_handle, evt->data_length, (uint16_t)evt->att_data[0]); //Extract the GattCharacteristic from p_characteristics[] and find the properties mask GattCharacteristic *p_char = BlueNRGGattServer::getInstance().getCharacteristicFromHandle(evt->attr_handle); if(p_char!=NULL) { - DEBUG("getProperties 0x%x\n\r",p_char->getProperties()); + DEBUG(" getProperties 0x%x\n\r",p_char->getProperties()); if((p_char->getProperties() & (GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE))) { @@ -260,18 +264,22 @@ } //Check is attr handle property is WRITEABLE, if yes, generate GATT_EVENT_DATA_WRITTEN Event - if((p_char->getProperties() & - (GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE| - GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE))) { + + // if(( p_char->getProperties() & + // (GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE| + // GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE))) { + // DEBUG(" BLE WRITABLE !\n\r"); // Copy the Data to the Buffer if ((p_char->getValueAttribute().getValuePtr() != NULL) && (p_char->getValueAttribute().getInitialLength() >= evt->data_length)) { - uint8_t *dst, *src; + uint8_t *dst, *src; + DEBUG("--> Copy SRC to DST\n\r"); dst= p_char->getValueAttribute().getValuePtr(); src = evt->att_data; for(int i=0;i<evt->data_length;i++) dst[i]=src[i]; + // ---Pas Beau du tout + ctrl_byte = dst[0]; } - BlueNRGGattServer::getInstance().handleEvent(GattServerEvents::GATT_EVENT_DATA_WRITTEN, evt->attr_handle); //Write the actual Data to the Attr Handle? (uint8_1[])evt->att_data contains the data @@ -279,7 +287,7 @@ BlueNRGGattServer::getInstance().updateValue(p_char->getValueAttribute().getHandle(), p_char->getValueAttribute().getValuePtr(), p_char->getValueAttribute().getInitialLength(), false /* localOnly */); } - } + // } } } break;