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.
Dependencies: BLE_API mbed nRF51822
BTDevice.cpp
00001 #include "BTDevice.hpp" 00002 00003 BTDevice::BTDevice() { 00004 this->ctrl = NULL; 00005 } 00006 00007 BTDevice::BTDevice(BLE _ble):ble(_ble){} 00008 00009 BTDevice::~BTDevice() { 00010 delete this->ctrl; 00011 } 00012 00013 void BTDevice::sendMsg(char *buf, uint16_t length) { 00014 ble.updateCharacteristicValue(rxCharacteristic.getValueAttribute().getHandle(), (const uint8_t*)buf, length); 00015 } 00016 00017 int BTDevice::readMsg(uint8_t buf[TXRX_BUF_LEN], uint16_t expectedLen) { 00018 uint16_t bytesRead; 00019 ble.readCharacteristicValue(txCharacteristic.getValueAttribute().getHandle(), buf, &bytesRead); 00020 00021 return (bytesRead == expectedLen)? bytesRead : -1; 00022 } 00023 00024 void BTDevice::attachController(Controller *c) { 00025 this->ctrl = c; 00026 } 00027 00028 void BTDevice::setCtrlRef(float ref) { 00029 this->ctrl->updateRef(ref); 00030 } 00031 00032 void BTDevice::setCtrlParams(ControllerParams &cp) { 00033 this->ctrl->updateParams(cp); 00034 } 00035
Generated on Sun Jul 24 2022 19:55:49 by
1.7.2