テスト用
Fork of nRF51822 by
Diff: nRF51GattServer.cpp
- Revision:
- 52:120bd37b9d0d
- Parent:
- 39:d52a28e1fa80
- Child:
- 54:e2294c844c83
- Child:
- 56:a1071b629aa3
--- a/nRF51GattServer.cpp Wed Jul 23 12:01:30 2014 +0100 +++ b/nRF51GattServer.cpp Thu Jul 24 15:46:29 2014 +0100 @@ -194,6 +194,45 @@ return BLE_ERROR_NONE; } +ble_error_t nRF51GattServer::setDeviceName(const uint8_t *deviceName) +{ + ble_gap_conn_sec_mode_t sec_mode; + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); // no security is needed + + if (sd_ble_gap_device_name_set(&sec_mode, deviceName, strlen((const char *)deviceName)) == NRF_SUCCESS) { + return BLE_ERROR_NONE; + } else { + return BLE_ERROR_PARAM_OUT_OF_RANGE; + } +} + +ble_error_t nRF51GattServer::getDeviceName(uint8_t *deviceName, unsigned *lengthP) +{ + if (sd_ble_gap_device_name_get(deviceName, (uint16_t *)lengthP) == NRF_SUCCESS) { + return BLE_ERROR_NONE; + } else { + return BLE_ERROR_PARAM_OUT_OF_RANGE; + } +} + +ble_error_t nRF51GattServer::setAppearance(uint16_t appearance) +{ + if (sd_ble_gap_appearance_set(appearance) == NRF_SUCCESS) { + return BLE_ERROR_NONE; + } else { + return BLE_ERROR_PARAM_OUT_OF_RANGE; + } +} + +ble_error_t nRF51GattServer::getAppearance(uint16_t *appearanceP) +{ + if (sd_ble_gap_appearance_get(appearanceP)) { + return BLE_ERROR_NONE; + } else { + return BLE_ERROR_PARAM_OUT_OF_RANGE; + } +} + /**************************************************************************/ /*! @brief Callback handler for events getting pushed up from the SD