PIR grove sensor that sends the sensed data to Thingspeak.com through the wifi module ESP 8266

Dependencies:   mbed

Committer:
skrawool
Date:
Mon Dec 05 16:39:27 2016 +0000
Revision:
0:3954a906acc2
PIR grove sensor that sends the sensed data to thingspeak through the wifi module ESP 8266

Who changed what in which revision?

UserRevisionLine numberNew contents of line
skrawool 0:3954a906acc2 1 /* mbed Microcontroller Library
skrawool 0:3954a906acc2 2 * Copyright (c) 2015 ARM Limited
skrawool 0:3954a906acc2 3 *
skrawool 0:3954a906acc2 4 * Licensed under the Apache License, Version 2.0 (the "License");
skrawool 0:3954a906acc2 5 * you may not use this file except in compliance with the License.
skrawool 0:3954a906acc2 6 * You may obtain a copy of the License at
skrawool 0:3954a906acc2 7 *
skrawool 0:3954a906acc2 8 * http://www.apache.org/licenses/LICENSE-2.0
skrawool 0:3954a906acc2 9 *
skrawool 0:3954a906acc2 10 * Unless required by applicable law or agreed to in writing, software
skrawool 0:3954a906acc2 11 * distributed under the License is distributed on an "AS IS" BASIS,
skrawool 0:3954a906acc2 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
skrawool 0:3954a906acc2 13 * See the License for the specific language governing permissions and
skrawool 0:3954a906acc2 14 * limitations under the License.
skrawool 0:3954a906acc2 15 */
skrawool 0:3954a906acc2 16 #ifndef MBED_TRANSACTION_H
skrawool 0:3954a906acc2 17 #define MBED_TRANSACTION_H
skrawool 0:3954a906acc2 18
skrawool 0:3954a906acc2 19 #include "platform/platform.h"
skrawool 0:3954a906acc2 20 #include "platform/FunctionPointer.h"
skrawool 0:3954a906acc2 21
skrawool 0:3954a906acc2 22 namespace mbed {
skrawool 0:3954a906acc2 23 /** \addtogroup platform */
skrawool 0:3954a906acc2 24 /** @{*/
skrawool 0:3954a906acc2 25
skrawool 0:3954a906acc2 26 /** Transaction structure
skrawool 0:3954a906acc2 27 */
skrawool 0:3954a906acc2 28 typedef struct {
skrawool 0:3954a906acc2 29 void *tx_buffer; /**< Tx buffer */
skrawool 0:3954a906acc2 30 size_t tx_length; /**< Length of Tx buffer*/
skrawool 0:3954a906acc2 31 void *rx_buffer; /**< Rx buffer */
skrawool 0:3954a906acc2 32 size_t rx_length; /**< Length of Rx buffer */
skrawool 0:3954a906acc2 33 uint32_t event; /**< Event for a transaction */
skrawool 0:3954a906acc2 34 event_callback_t callback; /**< User's callback */
skrawool 0:3954a906acc2 35 uint8_t width; /**< Buffer's word width (8, 16, 32, 64) */
skrawool 0:3954a906acc2 36 } transaction_t;
skrawool 0:3954a906acc2 37
skrawool 0:3954a906acc2 38 /** Transaction class defines a transaction.
skrawool 0:3954a906acc2 39 *
skrawool 0:3954a906acc2 40 * @Note Synchronization level: Not protected
skrawool 0:3954a906acc2 41 */
skrawool 0:3954a906acc2 42 template<typename Class>
skrawool 0:3954a906acc2 43 class Transaction {
skrawool 0:3954a906acc2 44 public:
skrawool 0:3954a906acc2 45 Transaction(Class *tpointer, const transaction_t& transaction) : _obj(tpointer), _data(transaction) {
skrawool 0:3954a906acc2 46 }
skrawool 0:3954a906acc2 47
skrawool 0:3954a906acc2 48 Transaction() : _obj(), _data() {
skrawool 0:3954a906acc2 49 }
skrawool 0:3954a906acc2 50
skrawool 0:3954a906acc2 51 ~Transaction() {
skrawool 0:3954a906acc2 52 }
skrawool 0:3954a906acc2 53
skrawool 0:3954a906acc2 54 /** Get object's instance for the transaction
skrawool 0:3954a906acc2 55 *
skrawool 0:3954a906acc2 56 * @return The object which was stored
skrawool 0:3954a906acc2 57 */
skrawool 0:3954a906acc2 58 Class* get_object() {
skrawool 0:3954a906acc2 59 return _obj;
skrawool 0:3954a906acc2 60 }
skrawool 0:3954a906acc2 61
skrawool 0:3954a906acc2 62 /** Get the transaction
skrawool 0:3954a906acc2 63 *
skrawool 0:3954a906acc2 64 * @return The transaction which was stored
skrawool 0:3954a906acc2 65 */
skrawool 0:3954a906acc2 66 transaction_t* get_transaction() {
skrawool 0:3954a906acc2 67 return &_data;
skrawool 0:3954a906acc2 68 }
skrawool 0:3954a906acc2 69
skrawool 0:3954a906acc2 70 private:
skrawool 0:3954a906acc2 71 Class* _obj;
skrawool 0:3954a906acc2 72 transaction_t _data;
skrawool 0:3954a906acc2 73 };
skrawool 0:3954a906acc2 74
skrawool 0:3954a906acc2 75 }
skrawool 0:3954a906acc2 76
skrawool 0:3954a906acc2 77 #endif
skrawool 0:3954a906acc2 78
skrawool 0:3954a906acc2 79 /** @}*/