WIP. send a large constant string twice a second, in order to test out the transport with something indicative of our required load.
Dependencies: FXOS8700CQ NTPClient azure_umqtt_c iothub_mqtt_transport mbed-rtos mbed wolfSSL Socket lwip-eth lwip-sys lwip
Fork of FXOS8700CQ_To_Azure_IoT by
azure_c_shared_utility/lock_rtx_mbed.cpp@7:0d1a0fe537dc, 2017-01-05 (annotated)
- Committer:
- julianhigginson
- Date:
- Thu Jan 05 23:40:24 2017 +0000
- Revision:
- 7:0d1a0fe537dc
- Parent:
- 3:c0556ff7b8e3
modified dummy message for minimal data transport
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
markrad | 3:c0556ff7b8e3 | 1 | // Copyright (c) Microsoft. All rights reserved. |
markrad | 3:c0556ff7b8e3 | 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
markrad | 3:c0556ff7b8e3 | 3 | |
markrad | 3:c0556ff7b8e3 | 4 | #include <cstdlib> |
markrad | 3:c0556ff7b8e3 | 5 | #ifdef _CRTDBG_MAP_ALLOC |
markrad | 3:c0556ff7b8e3 | 6 | #include <crtdbg.h> |
markrad | 3:c0556ff7b8e3 | 7 | #endif |
markrad | 3:c0556ff7b8e3 | 8 | |
markrad | 3:c0556ff7b8e3 | 9 | #include "azure_c_shared_utility/lock.h" |
markrad | 3:c0556ff7b8e3 | 10 | #include "azure_c_shared_utility/xlogging.h" |
markrad | 3:c0556ff7b8e3 | 11 | #include "rtos.h" |
markrad | 3:c0556ff7b8e3 | 12 | |
markrad | 3:c0556ff7b8e3 | 13 | DEFINE_ENUM_STRINGS(LOCK_RESULT, LOCK_RESULT_VALUES); |
markrad | 3:c0556ff7b8e3 | 14 | |
markrad | 3:c0556ff7b8e3 | 15 | /*Tests_SRS_LOCK_99_002:[ This API on success will return a valid lock handle which should be a non NULL value]*/ |
markrad | 3:c0556ff7b8e3 | 16 | LOCK_HANDLE Lock_Init(void) |
markrad | 3:c0556ff7b8e3 | 17 | { |
markrad | 3:c0556ff7b8e3 | 18 | Mutex* lock_mtx = new Mutex(); |
markrad | 3:c0556ff7b8e3 | 19 | |
markrad | 3:c0556ff7b8e3 | 20 | return (LOCK_HANDLE)lock_mtx; |
markrad | 3:c0556ff7b8e3 | 21 | } |
markrad | 3:c0556ff7b8e3 | 22 | |
markrad | 3:c0556ff7b8e3 | 23 | |
markrad | 3:c0556ff7b8e3 | 24 | LOCK_RESULT Lock(LOCK_HANDLE handle) |
markrad | 3:c0556ff7b8e3 | 25 | { |
markrad | 3:c0556ff7b8e3 | 26 | LOCK_RESULT result; |
markrad | 3:c0556ff7b8e3 | 27 | if (handle == NULL) |
markrad | 3:c0556ff7b8e3 | 28 | { |
markrad | 3:c0556ff7b8e3 | 29 | /*Tests_SRS_LOCK_99_007:[ This API on NULL handle passed returns LOCK_ERROR]*/ |
markrad | 3:c0556ff7b8e3 | 30 | result = LOCK_ERROR; |
markrad | 3:c0556ff7b8e3 | 31 | LogError("(result = %s)", ENUM_TO_STRING(LOCK_RESULT, result)); |
markrad | 3:c0556ff7b8e3 | 32 | } |
markrad | 3:c0556ff7b8e3 | 33 | else |
markrad | 3:c0556ff7b8e3 | 34 | { |
markrad | 3:c0556ff7b8e3 | 35 | Mutex* lock_mtx = (Mutex*)handle; |
markrad | 3:c0556ff7b8e3 | 36 | if (lock_mtx->lock() == osOK) |
markrad | 3:c0556ff7b8e3 | 37 | { |
markrad | 3:c0556ff7b8e3 | 38 | /*Tests_SRS_LOCK_99_005:[ This API on success should return LOCK_OK]*/ |
markrad | 3:c0556ff7b8e3 | 39 | result = LOCK_OK; |
markrad | 3:c0556ff7b8e3 | 40 | } |
markrad | 3:c0556ff7b8e3 | 41 | else |
markrad | 3:c0556ff7b8e3 | 42 | { |
markrad | 3:c0556ff7b8e3 | 43 | /*Tests_SRS_LOCK_99_006:[ This API on error should return LOCK_ERROR]*/ |
markrad | 3:c0556ff7b8e3 | 44 | result = LOCK_ERROR; |
markrad | 3:c0556ff7b8e3 | 45 | LogError("(result = %s)", ENUM_TO_STRING(LOCK_RESULT, result)); |
markrad | 3:c0556ff7b8e3 | 46 | } |
markrad | 3:c0556ff7b8e3 | 47 | } |
markrad | 3:c0556ff7b8e3 | 48 | return result; |
markrad | 3:c0556ff7b8e3 | 49 | } |
markrad | 3:c0556ff7b8e3 | 50 | LOCK_RESULT Unlock(LOCK_HANDLE handle) |
markrad | 3:c0556ff7b8e3 | 51 | { |
markrad | 3:c0556ff7b8e3 | 52 | LOCK_RESULT result; |
markrad | 3:c0556ff7b8e3 | 53 | if (handle == NULL) |
markrad | 3:c0556ff7b8e3 | 54 | { |
markrad | 3:c0556ff7b8e3 | 55 | /*Tests_SRS_LOCK_99_011:[ This API on NULL handle passed returns LOCK_ERROR]*/ |
markrad | 3:c0556ff7b8e3 | 56 | result = LOCK_ERROR; |
markrad | 3:c0556ff7b8e3 | 57 | LogError("(result = %s)", ENUM_TO_STRING(LOCK_RESULT, result)); |
markrad | 3:c0556ff7b8e3 | 58 | } |
markrad | 3:c0556ff7b8e3 | 59 | else |
markrad | 3:c0556ff7b8e3 | 60 | { |
markrad | 3:c0556ff7b8e3 | 61 | Mutex* lock_mtx = (Mutex*)handle; |
markrad | 3:c0556ff7b8e3 | 62 | if (lock_mtx->unlock() == osOK) |
markrad | 3:c0556ff7b8e3 | 63 | { |
markrad | 3:c0556ff7b8e3 | 64 | /*Tests_SRS_LOCK_99_009:[ This API on success should return LOCK_OK]*/ |
markrad | 3:c0556ff7b8e3 | 65 | result = LOCK_OK; |
markrad | 3:c0556ff7b8e3 | 66 | } |
markrad | 3:c0556ff7b8e3 | 67 | else |
markrad | 3:c0556ff7b8e3 | 68 | { |
markrad | 3:c0556ff7b8e3 | 69 | /*Tests_SRS_LOCK_99_010:[ This API on error should return LOCK_ERROR]*/ |
markrad | 3:c0556ff7b8e3 | 70 | result = LOCK_ERROR; |
markrad | 3:c0556ff7b8e3 | 71 | LogError("(result = %s)", ENUM_TO_STRING(LOCK_RESULT, result)); |
markrad | 3:c0556ff7b8e3 | 72 | } |
markrad | 3:c0556ff7b8e3 | 73 | } |
markrad | 3:c0556ff7b8e3 | 74 | return result; |
markrad | 3:c0556ff7b8e3 | 75 | } |
markrad | 3:c0556ff7b8e3 | 76 | |
markrad | 3:c0556ff7b8e3 | 77 | LOCK_RESULT Lock_Deinit(LOCK_HANDLE handle) |
markrad | 3:c0556ff7b8e3 | 78 | { |
markrad | 3:c0556ff7b8e3 | 79 | LOCK_RESULT result=LOCK_OK ; |
markrad | 3:c0556ff7b8e3 | 80 | if (NULL == handle) |
markrad | 3:c0556ff7b8e3 | 81 | { |
markrad | 3:c0556ff7b8e3 | 82 | /*Tests_SRS_LOCK_99_013:[ This API on NULL handle passed returns LOCK_ERROR]*/ |
markrad | 3:c0556ff7b8e3 | 83 | result = LOCK_ERROR; |
markrad | 3:c0556ff7b8e3 | 84 | LogError("(result = %s)", ENUM_TO_STRING(LOCK_RESULT, result)); |
markrad | 3:c0556ff7b8e3 | 85 | } |
markrad | 3:c0556ff7b8e3 | 86 | else |
markrad | 3:c0556ff7b8e3 | 87 | { |
markrad | 3:c0556ff7b8e3 | 88 | /*Tests_SRS_LOCK_99_012:[ This API frees the memory pointed by handle]*/ |
markrad | 3:c0556ff7b8e3 | 89 | Mutex* lock_mtx = (Mutex*)handle; |
markrad | 3:c0556ff7b8e3 | 90 | delete lock_mtx; |
markrad | 3:c0556ff7b8e3 | 91 | } |
markrad | 3:c0556ff7b8e3 | 92 | |
markrad | 3:c0556ff7b8e3 | 93 | return result; |
markrad | 3:c0556ff7b8e3 | 94 | } |