This is an example of BLE GATT Client, which receives broadcast data from BLE_Server_BME280 ( a GATT server) , then transfers values up to mbed Device Connector (cloud).

Please refer details about BLEClient_mbedDevConn below. https://github.com/soramame21/BLEClient_mbedDevConn

The location of required BLE GATT server, BLE_Server_BME280, is at here. https://developer.mbed.org/users/edamame22/code/BLE_Server_BME280/

Committer:
Ren Boting
Date:
Tue Sep 05 11:56:13 2017 +0900
Revision:
2:b894b3508057
Parent:
0:29983394c6b6
Update all libraries and reform main.cpp

Who changed what in which revision?

UserRevisionLine numberNew contents of line
edamame22 0:29983394c6b6 1 Unity Test API
edamame22 0:29983394c6b6 2 ==============
edamame22 0:29983394c6b6 3
edamame22 0:29983394c6b6 4 [![Unity Build Status](https://api.travis-ci.org/ThrowTheSwitch/Unity.png?branch=master)](https://travis-ci.org/ThrowTheSwitch/Unity)
edamame22 0:29983394c6b6 5 __Copyright (c) 2007 - 2014 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__
edamame22 0:29983394c6b6 6
edamame22 0:29983394c6b6 7 Running Tests
edamame22 0:29983394c6b6 8 -------------
edamame22 0:29983394c6b6 9
edamame22 0:29983394c6b6 10 RUN_TEST(func, linenum)
edamame22 0:29983394c6b6 11
edamame22 0:29983394c6b6 12 Each Test is run within the macro `RUN_TEST`. This macro performs necessary setup before the test is called and handles cleanup and result tabulation afterwards.
edamame22 0:29983394c6b6 13
edamame22 0:29983394c6b6 14 Ignoring Tests
edamame22 0:29983394c6b6 15 --------------
edamame22 0:29983394c6b6 16
edamame22 0:29983394c6b6 17 There are times when a test is incomplete or not valid for some reason. At these times, TEST_IGNORE can be called. Control will immediately be returned to the caller of the test, and no failures will be returned.
edamame22 0:29983394c6b6 18
edamame22 0:29983394c6b6 19 TEST_IGNORE()
edamame22 0:29983394c6b6 20
edamame22 0:29983394c6b6 21 Ignore this test and return immediately
edamame22 0:29983394c6b6 22
edamame22 0:29983394c6b6 23 TEST_IGNORE_MESSAGE (message)
edamame22 0:29983394c6b6 24
edamame22 0:29983394c6b6 25 Ignore this test and return immediately. Output a message stating why the test was ignored.
edamame22 0:29983394c6b6 26
edamame22 0:29983394c6b6 27 Aborting Tests
edamame22 0:29983394c6b6 28 --------------
edamame22 0:29983394c6b6 29
edamame22 0:29983394c6b6 30 There are times when a test will contain an infinite loop on error conditions, or there may be reason to escape from the test early without executing the rest of the test. A pair of macros support this functionality in Unity. The first `TEST_PROTECT` sets up the feature, and handles emergency abort cases. `TEST_ABORT` can then be used at any time within the tests to return to the last `TEST_PROTECT` call.
edamame22 0:29983394c6b6 31
edamame22 0:29983394c6b6 32 TEST_PROTECT()
edamame22 0:29983394c6b6 33
edamame22 0:29983394c6b6 34 Setup and Catch macro
edamame22 0:29983394c6b6 35
edamame22 0:29983394c6b6 36 TEST_ABORT()
edamame22 0:29983394c6b6 37
edamame22 0:29983394c6b6 38 Abort Test macro
edamame22 0:29983394c6b6 39
edamame22 0:29983394c6b6 40 Example:
edamame22 0:29983394c6b6 41
edamame22 0:29983394c6b6 42 main()
edamame22 0:29983394c6b6 43 {
edamame22 0:29983394c6b6 44 if (TEST_PROTECT() == 0)
edamame22 0:29983394c6b6 45 {
edamame22 0:29983394c6b6 46 MyTest();
edamame22 0:29983394c6b6 47 }
edamame22 0:29983394c6b6 48 }
edamame22 0:29983394c6b6 49
edamame22 0:29983394c6b6 50 If MyTest calls `TEST_ABORT`, program control will immediately return to `TEST_PROTECT` with a non-zero return value.
edamame22 0:29983394c6b6 51
edamame22 0:29983394c6b6 52
edamame22 0:29983394c6b6 53 Unity Assertion Summary
edamame22 0:29983394c6b6 54 =======================
edamame22 0:29983394c6b6 55
edamame22 0:29983394c6b6 56 Basic Validity Tests
edamame22 0:29983394c6b6 57 --------------------
edamame22 0:29983394c6b6 58
edamame22 0:29983394c6b6 59 TEST_ASSERT_TRUE(condition)
edamame22 0:29983394c6b6 60
edamame22 0:29983394c6b6 61 Evaluates whatever code is in condition and fails if it evaluates to false
edamame22 0:29983394c6b6 62
edamame22 0:29983394c6b6 63 TEST_ASSERT_FALSE(condition)
edamame22 0:29983394c6b6 64
edamame22 0:29983394c6b6 65 Evaluates whatever code is in condition and fails if it evaluates to true
edamame22 0:29983394c6b6 66
edamame22 0:29983394c6b6 67 TEST_ASSERT(condition)
edamame22 0:29983394c6b6 68
edamame22 0:29983394c6b6 69 Another way of calling `TEST_ASSERT_TRUE`
edamame22 0:29983394c6b6 70
edamame22 0:29983394c6b6 71 TEST_ASSERT_UNLESS(condition)
edamame22 0:29983394c6b6 72
edamame22 0:29983394c6b6 73 Another way of calling `TEST_ASSERT_FALSE`
edamame22 0:29983394c6b6 74
edamame22 0:29983394c6b6 75 TEST_FAIL()
edamame22 0:29983394c6b6 76 TEST_FAIL_MESSAGE(message)
edamame22 0:29983394c6b6 77
edamame22 0:29983394c6b6 78 This test is automatically marked as a failure. The message is output stating why.
edamame22 0:29983394c6b6 79
edamame22 0:29983394c6b6 80 Numerical Assertions: Integers
edamame22 0:29983394c6b6 81 ------------------------------
edamame22 0:29983394c6b6 82
edamame22 0:29983394c6b6 83 TEST_ASSERT_EQUAL_INT(expected, actual)
edamame22 0:29983394c6b6 84 TEST_ASSERT_EQUAL_INT8(expected, actual)
edamame22 0:29983394c6b6 85 TEST_ASSERT_EQUAL_INT16(expected, actual)
edamame22 0:29983394c6b6 86 TEST_ASSERT_EQUAL_INT32(expected, actual)
edamame22 0:29983394c6b6 87 TEST_ASSERT_EQUAL_INT64(expected, actual)
edamame22 0:29983394c6b6 88
edamame22 0:29983394c6b6 89 Compare two integers for equality and display errors as signed integers. A cast will be performed
edamame22 0:29983394c6b6 90 to your natural integer size so often this can just be used. When you need to specify the exact size,
edamame22 0:29983394c6b6 91 like when comparing arrays, you can use a specific version:
edamame22 0:29983394c6b6 92
edamame22 0:29983394c6b6 93 TEST_ASSERT_EQUAL_UINT(expected, actual)
edamame22 0:29983394c6b6 94 TEST_ASSERT_EQUAL_UINT8(expected, actual)
edamame22 0:29983394c6b6 95 TEST_ASSERT_EQUAL_UINT16(expected, actual)
edamame22 0:29983394c6b6 96 TEST_ASSERT_EQUAL_UINT32(expected, actual)
edamame22 0:29983394c6b6 97 TEST_ASSERT_EQUAL_UINT64(expected, actual)
edamame22 0:29983394c6b6 98
edamame22 0:29983394c6b6 99 Compare two integers for equality and display errors as unsigned integers. Like INT, there are
edamame22 0:29983394c6b6 100 variants for different sizes also.
edamame22 0:29983394c6b6 101
edamame22 0:29983394c6b6 102 TEST_ASSERT_EQUAL_HEX(expected, actual)
edamame22 0:29983394c6b6 103 TEST_ASSERT_EQUAL_HEX8(expected, actual)
edamame22 0:29983394c6b6 104 TEST_ASSERT_EQUAL_HEX16(expected, actual)
edamame22 0:29983394c6b6 105 TEST_ASSERT_EQUAL_HEX32(expected, actual)
edamame22 0:29983394c6b6 106 TEST_ASSERT_EQUAL_HEX64(expected, actual)
edamame22 0:29983394c6b6 107
edamame22 0:29983394c6b6 108 Compares two integers for equality and display errors as hexadecimal. Like the other integer comparisons,
edamame22 0:29983394c6b6 109 you can specify the size... here the size will also effect how many nibbles are shown (for example, `HEX16`
edamame22 0:29983394c6b6 110 will show 4 nibbles).
edamame22 0:29983394c6b6 111
edamame22 0:29983394c6b6 112 _ARRAY
edamame22 0:29983394c6b6 113
edamame22 0:29983394c6b6 114 You can append `_ARRAY` to any of these macros to make an array comparison of that type. Here you will
edamame22 0:29983394c6b6 115 need to care a bit more about the actual size of the value being checked. You will also specify an
edamame22 0:29983394c6b6 116 additional argument which is the number of elements to compare. For example:
edamame22 0:29983394c6b6 117
edamame22 0:29983394c6b6 118 TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, elements)
edamame22 0:29983394c6b6 119
edamame22 0:29983394c6b6 120 TEST_ASSERT_EQUAL(expected, actual)
edamame22 0:29983394c6b6 121
edamame22 0:29983394c6b6 122 Another way of calling TEST_ASSERT_EQUAL_INT
edamame22 0:29983394c6b6 123
edamame22 0:29983394c6b6 124 TEST_ASSERT_INT_WITHIN(delta, expected, actual)
edamame22 0:29983394c6b6 125
edamame22 0:29983394c6b6 126 Asserts that the actual value is within plus or minus delta of the expected value. This also comes in
edamame22 0:29983394c6b6 127 size specific variants.
edamame22 0:29983394c6b6 128
edamame22 0:29983394c6b6 129
edamame22 0:29983394c6b6 130 Numerical Assertions: Bitwise
edamame22 0:29983394c6b6 131 -----------------------------
edamame22 0:29983394c6b6 132
edamame22 0:29983394c6b6 133 TEST_ASSERT_BITS(mask, expected, actual)
edamame22 0:29983394c6b6 134
edamame22 0:29983394c6b6 135 Use an integer mask to specify which bits should be compared between two other integers. High bits in the mask are compared, low bits ignored.
edamame22 0:29983394c6b6 136
edamame22 0:29983394c6b6 137 TEST_ASSERT_BITS_HIGH(mask, actual)
edamame22 0:29983394c6b6 138
edamame22 0:29983394c6b6 139 Use an integer mask to specify which bits should be inspected to determine if they are all set high. High bits in the mask are compared, low bits ignored.
edamame22 0:29983394c6b6 140
edamame22 0:29983394c6b6 141 TEST_ASSERT_BITS_LOW(mask, actual)
edamame22 0:29983394c6b6 142
edamame22 0:29983394c6b6 143 Use an integer mask to specify which bits should be inspected to determine if they are all set low. High bits in the mask are compared, low bits ignored.
edamame22 0:29983394c6b6 144
edamame22 0:29983394c6b6 145 TEST_ASSERT_BIT_HIGH(bit, actual)
edamame22 0:29983394c6b6 146
edamame22 0:29983394c6b6 147 Test a single bit and verify that it is high. The bit is specified 0-31 for a 32-bit integer.
edamame22 0:29983394c6b6 148
edamame22 0:29983394c6b6 149 TEST_ASSERT_BIT_LOW(bit, actual)
edamame22 0:29983394c6b6 150
edamame22 0:29983394c6b6 151 Test a single bit and verify that it is low. The bit is specified 0-31 for a 32-bit integer.
edamame22 0:29983394c6b6 152
edamame22 0:29983394c6b6 153 Numerical Assertions: Floats
edamame22 0:29983394c6b6 154 ----------------------------
edamame22 0:29983394c6b6 155
edamame22 0:29983394c6b6 156 TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual)
edamame22 0:29983394c6b6 157
edamame22 0:29983394c6b6 158 Asserts that the actual value is within plus or minus delta of the expected value.
edamame22 0:29983394c6b6 159
edamame22 0:29983394c6b6 160 TEST_ASSERT_EQUAL_FLOAT(expected, actual)
edamame22 0:29983394c6b6 161 TEST_ASSERT_EQUAL_DOUBLE(expected, actual)
edamame22 0:29983394c6b6 162
edamame22 0:29983394c6b6 163 Asserts that two floating point values are "equal" within a small % delta of the expected value.
edamame22 0:29983394c6b6 164
edamame22 0:29983394c6b6 165 String Assertions
edamame22 0:29983394c6b6 166 -----------------
edamame22 0:29983394c6b6 167
edamame22 0:29983394c6b6 168 TEST_ASSERT_EQUAL_STRING(expected, actual)
edamame22 0:29983394c6b6 169
edamame22 0:29983394c6b6 170 Compare two null-terminate strings. Fail if any character is different or if the lengths are different.
edamame22 0:29983394c6b6 171
edamame22 0:29983394c6b6 172 TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len)
edamame22 0:29983394c6b6 173
edamame22 0:29983394c6b6 174 Compare two strings. Fail if any character is different, stop comparing after len characters.
edamame22 0:29983394c6b6 175
edamame22 0:29983394c6b6 176 TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message)
edamame22 0:29983394c6b6 177
edamame22 0:29983394c6b6 178 Compare two null-terminate strings. Fail if any character is different or if the lengths are different. Output a custom message on failure.
edamame22 0:29983394c6b6 179
edamame22 0:29983394c6b6 180 TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(expected, actual, len, message)
edamame22 0:29983394c6b6 181
edamame22 0:29983394c6b6 182 Compare two strings. Fail if any character is different, stop comparing after len characters. Output a custom message on failure.
edamame22 0:29983394c6b6 183
edamame22 0:29983394c6b6 184 Pointer Assertions
edamame22 0:29983394c6b6 185 ------------------
edamame22 0:29983394c6b6 186
edamame22 0:29983394c6b6 187 Most pointer operations can be performed by simply using the integer comparisons above. However, a couple of special cases are added for clarity.
edamame22 0:29983394c6b6 188
edamame22 0:29983394c6b6 189 TEST_ASSERT_NULL(pointer)
edamame22 0:29983394c6b6 190
edamame22 0:29983394c6b6 191 Fails if the pointer is not equal to NULL
edamame22 0:29983394c6b6 192
edamame22 0:29983394c6b6 193 TEST_ASSERT_NOT_NULL(pointer)
edamame22 0:29983394c6b6 194
edamame22 0:29983394c6b6 195 Fails if the pointer is equal to NULL
edamame22 0:29983394c6b6 196
edamame22 0:29983394c6b6 197 Memory Assertions
edamame22 0:29983394c6b6 198 -----------------
edamame22 0:29983394c6b6 199
edamame22 0:29983394c6b6 200 TEST_ASSERT_EQUAL_MEMORY(expected, actual, len)
edamame22 0:29983394c6b6 201
edamame22 0:29983394c6b6 202 Compare two blocks of memory. This is a good generic assertion for types that can't be coerced into acting like
edamame22 0:29983394c6b6 203 standard types... but since it's a memory compare, you have to be careful that your data types are packed.
edamame22 0:29983394c6b6 204
edamame22 0:29983394c6b6 205 _MESSAGE
edamame22 0:29983394c6b6 206 --------
edamame22 0:29983394c6b6 207
edamame22 0:29983394c6b6 208 you can append _MESSAGE to any of the macros to make them take an additional argument. This argument
edamame22 0:29983394c6b6 209 is a string that will be printed at the end of the failure strings. This is useful for specifying more
edamame22 0:29983394c6b6 210 information about the problem.
edamame22 0:29983394c6b6 211