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) 2006-2013 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_DIRHANDLE_H
skrawool 0:3954a906acc2 17 #define MBED_DIRHANDLE_H
skrawool 0:3954a906acc2 18
skrawool 0:3954a906acc2 19 #if defined(__ARMCC_VERSION) || defined(__ICCARM__)
skrawool 0:3954a906acc2 20 # define NAME_MAX 255
skrawool 0:3954a906acc2 21 typedef int mode_t;
skrawool 0:3954a906acc2 22
skrawool 0:3954a906acc2 23 #else
skrawool 0:3954a906acc2 24 # include <sys/syslimits.h>
skrawool 0:3954a906acc2 25 #endif
skrawool 0:3954a906acc2 26
skrawool 0:3954a906acc2 27 #include "FileHandle.h"
skrawool 0:3954a906acc2 28
skrawool 0:3954a906acc2 29 struct dirent {
skrawool 0:3954a906acc2 30 char d_name[NAME_MAX+1];
skrawool 0:3954a906acc2 31 };
skrawool 0:3954a906acc2 32
skrawool 0:3954a906acc2 33 namespace mbed {
skrawool 0:3954a906acc2 34 /** \addtogroup drivers */
skrawool 0:3954a906acc2 35 /** @{*/
skrawool 0:3954a906acc2 36
skrawool 0:3954a906acc2 37 /** Represents a directory stream. Objects of this type are returned
skrawool 0:3954a906acc2 38 * by a FileSystemLike's opendir method. Implementations must define
skrawool 0:3954a906acc2 39 * at least closedir, readdir and rewinddir.
skrawool 0:3954a906acc2 40 *
skrawool 0:3954a906acc2 41 * If a FileSystemLike class defines the opendir method, then the
skrawool 0:3954a906acc2 42 * directories of an object of that type can be accessed by
skrawool 0:3954a906acc2 43 * DIR *d = opendir("/example/directory") (or opendir("/example")
skrawool 0:3954a906acc2 44 * to open the root of the filesystem), and then using readdir(d) etc.
skrawool 0:3954a906acc2 45 *
skrawool 0:3954a906acc2 46 * The root directory is considered to contain all FileLike and
skrawool 0:3954a906acc2 47 * FileSystemLike objects, so the DIR* returned by opendir("/") will
skrawool 0:3954a906acc2 48 * reflect this.
skrawool 0:3954a906acc2 49 *
skrawool 0:3954a906acc2 50 * @Note Synchronization level: Set by subclass
skrawool 0:3954a906acc2 51 */
skrawool 0:3954a906acc2 52 class DirHandle {
skrawool 0:3954a906acc2 53
skrawool 0:3954a906acc2 54 public:
skrawool 0:3954a906acc2 55 /** Closes the directory.
skrawool 0:3954a906acc2 56 *
skrawool 0:3954a906acc2 57 * @returns
skrawool 0:3954a906acc2 58 * 0 on success,
skrawool 0:3954a906acc2 59 * -1 on error.
skrawool 0:3954a906acc2 60 */
skrawool 0:3954a906acc2 61 virtual int closedir()=0;
skrawool 0:3954a906acc2 62
skrawool 0:3954a906acc2 63 /** Return the directory entry at the current position, and
skrawool 0:3954a906acc2 64 * advances the position to the next entry.
skrawool 0:3954a906acc2 65 *
skrawool 0:3954a906acc2 66 * @returns
skrawool 0:3954a906acc2 67 * A pointer to a dirent structure representing the
skrawool 0:3954a906acc2 68 * directory entry at the current position, or NULL on reaching
skrawool 0:3954a906acc2 69 * end of directory or error.
skrawool 0:3954a906acc2 70 */
skrawool 0:3954a906acc2 71 virtual struct dirent *readdir()=0;
skrawool 0:3954a906acc2 72
skrawool 0:3954a906acc2 73 /** Resets the position to the beginning of the directory.
skrawool 0:3954a906acc2 74 */
skrawool 0:3954a906acc2 75 virtual void rewinddir()=0;
skrawool 0:3954a906acc2 76
skrawool 0:3954a906acc2 77 /** Returns the current position of the DirHandle.
skrawool 0:3954a906acc2 78 *
skrawool 0:3954a906acc2 79 * @returns
skrawool 0:3954a906acc2 80 * the current position,
skrawool 0:3954a906acc2 81 * -1 on error.
skrawool 0:3954a906acc2 82 */
skrawool 0:3954a906acc2 83 virtual off_t telldir() { return -1; }
skrawool 0:3954a906acc2 84
skrawool 0:3954a906acc2 85 /** Sets the position of the DirHandle.
skrawool 0:3954a906acc2 86 *
skrawool 0:3954a906acc2 87 * @param location The location to seek to. Must be a value returned by telldir.
skrawool 0:3954a906acc2 88 */
skrawool 0:3954a906acc2 89 virtual void seekdir(off_t location) { (void)location;}
skrawool 0:3954a906acc2 90
skrawool 0:3954a906acc2 91 virtual ~DirHandle() {}
skrawool 0:3954a906acc2 92
skrawool 0:3954a906acc2 93 protected:
skrawool 0:3954a906acc2 94
skrawool 0:3954a906acc2 95 /** Acquire exclusive access to this object.
skrawool 0:3954a906acc2 96 */
skrawool 0:3954a906acc2 97 virtual void lock() {
skrawool 0:3954a906acc2 98 // Stub
skrawool 0:3954a906acc2 99 }
skrawool 0:3954a906acc2 100
skrawool 0:3954a906acc2 101 /** Release exclusive access to this object.
skrawool 0:3954a906acc2 102 */
skrawool 0:3954a906acc2 103 virtual void unlock() {
skrawool 0:3954a906acc2 104 // Stub
skrawool 0:3954a906acc2 105 }
skrawool 0:3954a906acc2 106 };
skrawool 0:3954a906acc2 107
skrawool 0:3954a906acc2 108 } // namespace mbed
skrawool 0:3954a906acc2 109
skrawool 0:3954a906acc2 110 typedef mbed::DirHandle DIR;
skrawool 0:3954a906acc2 111
skrawool 0:3954a906acc2 112 extern "C" {
skrawool 0:3954a906acc2 113 DIR *opendir(const char*);
skrawool 0:3954a906acc2 114 struct dirent *readdir(DIR *);
skrawool 0:3954a906acc2 115 int closedir(DIR*);
skrawool 0:3954a906acc2 116 void rewinddir(DIR*);
skrawool 0:3954a906acc2 117 long telldir(DIR*);
skrawool 0:3954a906acc2 118 void seekdir(DIR*, long);
skrawool 0:3954a906acc2 119 int mkdir(const char *name, mode_t n);
skrawool 0:3954a906acc2 120 };
skrawool 0:3954a906acc2 121
skrawool 0:3954a906acc2 122 #endif /* MBED_DIRHANDLE_H */
skrawool 0:3954a906acc2 123
skrawool 0:3954a906acc2 124 /** @}*/