From 0374af511d7efdb856af372f126e66e5a78841d7 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 19 Jul 2015 20:02:00 +0200 Subject: o Applying clang-format to all apps. --- apps/SoilMoisture.cpp | 64 +++++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 38 deletions(-) (limited to 'apps/SoilMoisture.cpp') diff --git a/apps/SoilMoisture.cpp b/apps/SoilMoisture.cpp index fea1ef9..044ba21 100644 --- a/apps/SoilMoisture.cpp +++ b/apps/SoilMoisture.cpp @@ -4,20 +4,10 @@ namespace trygvis { namespace sensor { #define BLUETOOTH_UUID_INITIALIZER \ - { \ - 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, \ - 0x10, 0x00, \ - 0x80, 0x00, \ - 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb \ - }; - -auto trygvis_io_base_uuid = boost::uuids::uuid { - 0x32, 0xd0, 0x00, 0x00, - 0x03, 0x5d, - 0x59, 0xc5, - 0x70, 0xd3, - 0xbc, 0x8e, 0x4a, 0x1f, 0xd8, 0x3f}; + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb }; + +auto trygvis_io_base_uuid = + boost::uuids::uuid{0x32, 0xd0, 0x00, 0x00, 0x03, 0x5d, 0x59, 0xc5, 0x70, 0xd3, 0xbc, 0x8e, 0x4a, 0x1f, 0xd8, 0x3f}; const boost::uuids::uuid soil_moisture_service = makeUuid(trygvis_io_base_uuid, 0x00, 0x10); const boost::uuids::uuid soil_moisture_characteristic = makeUuid(trygvis_io_base_uuid, 0x00, 0x11); @@ -25,41 +15,39 @@ const boost::uuids::uuid soil_moisture_characteristic = makeUuid(trygvis_io_base using namespace trygvis::bluetooth; ByteBuffer createGetSensorCount() { - return ByteBuffer::alloc(100). - write8(static_cast(sm_cmd_code::SM_CMD_GET_SENSOR_COUNT)); + return ByteBuffer::alloc(100) // + .write8(static_cast(sm_cmd_code::SM_CMD_GET_SENSOR_COUNT)); } ByteBuffer createGetValue(uint8_t sensor) { - return ByteBuffer::alloc(100). - write8(static_cast(sm_cmd_code::SM_CMD_GET_VALUE)). - write16le(sensor); + return ByteBuffer::alloc(100) // + .write8(static_cast(sm_cmd_code::SM_CMD_GET_VALUE)) // + .write16le(sensor); } ByteBuffer createSetWarningValue(uint8_t sensor, uint16_t warning_value) { - return ByteBuffer::alloc(100). - write8(static_cast(sm_cmd_code::SM_CMD_SET_WARNING_VALUE)). - write8(sensor). - write16le(warning_value); + return ByteBuffer::alloc(100) + .write8(static_cast(sm_cmd_code::SM_CMD_SET_WARNING_VALUE)) + .write8(sensor) + .write16le(warning_value); } ByteBuffer createSetSensorName(uint8_t sensor, string name) { - return ByteBuffer::alloc(100). - write8(static_cast(sm_cmd_code::SM_CMD_SET_SENSOR_NAME)). - write8(sensor). - write(reinterpret_cast(name.c_str()), name.length()); + return ByteBuffer::alloc(100) + .write8(static_cast(sm_cmd_code::SM_CMD_SET_SENSOR_NAME)) + .write8(sensor) + .write(reinterpret_cast(name.c_str()), name.length()); } ByteBuffer createGetSensorName(uint8_t sensor) { - return ByteBuffer::alloc(100). - write8(static_cast(sm_cmd_code::SM_CMD_GET_SENSOR_NAME)). - write8(sensor); + return ByteBuffer::alloc(100).write8(static_cast(sm_cmd_code::SM_CMD_GET_SENSOR_NAME)).write8(sensor); } ByteBuffer createSetUpdateInterval(uint8_t sensor, uint8_t interval_in_seconds) { - return ByteBuffer::alloc(100). - write8(static_cast(sm_cmd_code::SM_CMD_SET_UPDATE_INTERVAL)). - write8(sensor). - write8(interval_in_seconds); + return ByteBuffer::alloc(100) + .write8(static_cast(sm_cmd_code::SM_CMD_SET_UPDATE_INTERVAL)) + .write8(sensor) + .write8(interval_in_seconds); } SoilMoisture SoilMoisture::create(shared_ptr gatt) { @@ -80,8 +68,8 @@ SoilMoisture SoilMoisture::create(shared_ptr gatt) { return SoilMoisture(gatt, *service, *c); } -SoilMoisture::SoilMoisture(shared_ptr gatt, BluetoothGattService &s, BluetoothGattCharacteristic &c) : - gatt(std::move(gatt)), s(s), c(c) { +SoilMoisture::SoilMoisture(shared_ptr gatt, BluetoothGattService &s, BluetoothGattCharacteristic &c) + : gatt(std::move(gatt)), s(s), c(c) { } ByteBuffer SoilMoisture::writeAndRead(ByteBuffer &requestBytes) { @@ -99,7 +87,8 @@ ByteBuffer SoilMoisture::writeAndRead(ByteBuffer &requestBytes) { uint8_t actualCode = responseBytes.read8(); if (actualCode != expectedCode) { - throw runtime_error("Unexpected response code: " + to_string(actualCode) + ", expected " + to_string(expectedCode)); + throw runtime_error("Unexpected response code: " + to_string(actualCode) + ", expected " + + to_string(expectedCode)); } return responseBytes; @@ -128,6 +117,5 @@ string SoilMoisture::getName(uint8_t sensor) { return string((char *) bytes, (unsigned long) bytesLeft); } - } } -- cgit v1.2.3