FRDM-K64F, Avnet M14A2A, Grove Shield, to create smart home system. In use with AT&Ts M2x & Flow.

Dependencies:   mbed FXOS8700CQ MODSERIAL

Committer:
jwhammel
Date:
Mon Apr 29 04:24:38 2019 +0000
Revision:
85:0cf65ceb4492
Parent:
84:fc8c9b39723a
We have added an alarm trigger that gets sent to AT&T Flow.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jwhammel 84:fc8c9b39723a 1 /* mbed Microcontroller Library
jwhammel 84:fc8c9b39723a 2 * Copyright (c) 2006-2013 ARM Limited
jwhammel 84:fc8c9b39723a 3 *
jwhammel 84:fc8c9b39723a 4 * Licensed under the Apache License, Version 2.0 (the "License");
jwhammel 84:fc8c9b39723a 5 * you may not use this file except in compliance with the License.
jwhammel 84:fc8c9b39723a 6 * You may obtain a copy of the License at
jwhammel 84:fc8c9b39723a 7 *
jwhammel 84:fc8c9b39723a 8 * http://www.apache.org/licenses/LICENSE-2.0
jwhammel 84:fc8c9b39723a 9 *
jwhammel 84:fc8c9b39723a 10 * Unless required by applicable law or agreed to in writing, software
jwhammel 84:fc8c9b39723a 11 * distributed under the License is distributed on an "AS IS" BASIS,
jwhammel 84:fc8c9b39723a 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
jwhammel 84:fc8c9b39723a 13 * See the License for the specific language governing permissions and
jwhammel 84:fc8c9b39723a 14 * limitations under the License.
jwhammel 84:fc8c9b39723a 15 */
jwhammel 84:fc8c9b39723a 16 #ifndef MBED_FILESYSTEMLIKE_H
jwhammel 84:fc8c9b39723a 17 #define MBED_FILESYSTEMLIKE_H
jwhammel 84:fc8c9b39723a 18
jwhammel 84:fc8c9b39723a 19 #include "platform.h"
jwhammel 84:fc8c9b39723a 20
jwhammel 84:fc8c9b39723a 21 #include "FileBase.h"
jwhammel 84:fc8c9b39723a 22 #include "FileHandle.h"
jwhammel 84:fc8c9b39723a 23 #include "DirHandle.h"
jwhammel 84:fc8c9b39723a 24
jwhammel 84:fc8c9b39723a 25 namespace mbed {
jwhammel 84:fc8c9b39723a 26
jwhammel 84:fc8c9b39723a 27 /** A filesystem-like object is one that can be used to open files
jwhammel 84:fc8c9b39723a 28 * though it by fopen("/name/filename", mode)
jwhammel 84:fc8c9b39723a 29 *
jwhammel 84:fc8c9b39723a 30 * Implementations must define at least open (the default definitions
jwhammel 84:fc8c9b39723a 31 * of the rest of the functions just return error values).
jwhammel 84:fc8c9b39723a 32 */
jwhammel 84:fc8c9b39723a 33 class FileSystemLike : public FileBase {
jwhammel 84:fc8c9b39723a 34
jwhammel 84:fc8c9b39723a 35 public:
jwhammel 84:fc8c9b39723a 36 /** FileSystemLike constructor
jwhammel 84:fc8c9b39723a 37 *
jwhammel 84:fc8c9b39723a 38 * @param name The name to use for the filesystem.
jwhammel 84:fc8c9b39723a 39 */
jwhammel 84:fc8c9b39723a 40 FileSystemLike(const char *name);
jwhammel 84:fc8c9b39723a 41
jwhammel 84:fc8c9b39723a 42 virtual ~FileSystemLike();
jwhammel 84:fc8c9b39723a 43
jwhammel 84:fc8c9b39723a 44 static DirHandle *opendir();
jwhammel 84:fc8c9b39723a 45 friend class BaseDirHandle;
jwhammel 84:fc8c9b39723a 46
jwhammel 84:fc8c9b39723a 47 /** Opens a file from the filesystem
jwhammel 84:fc8c9b39723a 48 *
jwhammel 84:fc8c9b39723a 49 * @param filename The name of the file to open.
jwhammel 84:fc8c9b39723a 50 * @param flags One of O_RDONLY, O_WRONLY, or O_RDWR, OR'd with
jwhammel 84:fc8c9b39723a 51 * zero or more of O_CREAT, O_TRUNC, or O_APPEND.
jwhammel 84:fc8c9b39723a 52 *
jwhammel 84:fc8c9b39723a 53 * @returns
jwhammel 84:fc8c9b39723a 54 * A pointer to a FileHandle object representing the
jwhammel 84:fc8c9b39723a 55 * file on success, or NULL on failure.
jwhammel 84:fc8c9b39723a 56 */
jwhammel 84:fc8c9b39723a 57 virtual FileHandle *open(const char *filename, int flags) = 0;
jwhammel 84:fc8c9b39723a 58
jwhammel 84:fc8c9b39723a 59 /** Remove a file from the filesystem.
jwhammel 84:fc8c9b39723a 60 *
jwhammel 84:fc8c9b39723a 61 * @param filename the name of the file to remove.
jwhammel 84:fc8c9b39723a 62 * @param returns 0 on success, -1 on failure.
jwhammel 84:fc8c9b39723a 63 */
jwhammel 84:fc8c9b39723a 64 virtual int remove(const char *filename) { return -1; };
jwhammel 84:fc8c9b39723a 65
jwhammel 84:fc8c9b39723a 66 /** Rename a file in the filesystem.
jwhammel 84:fc8c9b39723a 67 *
jwhammel 84:fc8c9b39723a 68 * @param oldname the name of the file to rename.
jwhammel 84:fc8c9b39723a 69 * @param newname the name to rename it to.
jwhammel 84:fc8c9b39723a 70 *
jwhammel 84:fc8c9b39723a 71 * @returns
jwhammel 84:fc8c9b39723a 72 * 0 on success,
jwhammel 84:fc8c9b39723a 73 * -1 on failure.
jwhammel 84:fc8c9b39723a 74 */
jwhammel 84:fc8c9b39723a 75 virtual int rename(const char *oldname, const char *newname) { return -1; };
jwhammel 84:fc8c9b39723a 76
jwhammel 84:fc8c9b39723a 77 /** Opens a directory in the filesystem and returns a DirHandle
jwhammel 84:fc8c9b39723a 78 * representing the directory stream.
jwhammel 84:fc8c9b39723a 79 *
jwhammel 84:fc8c9b39723a 80 * @param name The name of the directory to open.
jwhammel 84:fc8c9b39723a 81 *
jwhammel 84:fc8c9b39723a 82 * @returns
jwhammel 84:fc8c9b39723a 83 * A DirHandle representing the directory stream, or
jwhammel 84:fc8c9b39723a 84 * NULL on failure.
jwhammel 84:fc8c9b39723a 85 */
jwhammel 84:fc8c9b39723a 86 virtual DirHandle *opendir(const char *name) { return NULL; };
jwhammel 84:fc8c9b39723a 87
jwhammel 84:fc8c9b39723a 88 /** Creates a directory in the filesystem.
jwhammel 84:fc8c9b39723a 89 *
jwhammel 84:fc8c9b39723a 90 * @param name The name of the directory to create.
jwhammel 84:fc8c9b39723a 91 * @param mode The permissions to create the directory with.
jwhammel 84:fc8c9b39723a 92 *
jwhammel 84:fc8c9b39723a 93 * @returns
jwhammel 84:fc8c9b39723a 94 * 0 on success,
jwhammel 84:fc8c9b39723a 95 * -1 on failure.
jwhammel 84:fc8c9b39723a 96 */
jwhammel 84:fc8c9b39723a 97 virtual int mkdir(const char *name, mode_t mode) { return -1; }
jwhammel 84:fc8c9b39723a 98
jwhammel 84:fc8c9b39723a 99 // TODO other filesystem functions (mkdir, rm, rn, ls etc)
jwhammel 84:fc8c9b39723a 100 };
jwhammel 84:fc8c9b39723a 101
jwhammel 84:fc8c9b39723a 102 } // namespace mbed
jwhammel 84:fc8c9b39723a 103
jwhammel 84:fc8c9b39723a 104 #endif
jwhammel 84:fc8c9b39723a 105