Artur Tynecki | 0efd318 | 2022-12-05 20:18:32 +0100 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright (c) 2022 Project CHIP Authors |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | /** |
| 19 | * @file |
| 20 | * Source implementation of an input / output stream for Open IoT SDK platform. |
| 21 | */ |
| 22 | |
| 23 | #include <stdio.h> |
| 24 | #include <stdlib.h> |
| 25 | #include <sys/unistd.h> |
| 26 | |
| 27 | #include <lib/shell/streamer.h> |
| 28 | |
| 29 | namespace chip { |
| 30 | namespace Shell { |
| 31 | |
| 32 | int streamer_openiotsdk_init(streamer_t * streamer) |
| 33 | { |
| 34 | (void) streamer; |
| 35 | return 0; |
| 36 | } |
| 37 | |
| 38 | ssize_t streamer_openiotsdk_read(streamer_t * streamer, char * buf, size_t len) |
| 39 | { |
| 40 | (void) streamer; |
| 41 | return read(STDIN_FILENO, buf, len); |
| 42 | } |
| 43 | |
| 44 | ssize_t streamer_openiotsdk_write(streamer_t * streamer, const char * buf, size_t len) |
| 45 | { |
| 46 | (void) streamer; |
| 47 | return write(STDOUT_FILENO, buf, len); |
| 48 | } |
| 49 | |
| 50 | static streamer_t streamer_openiotsdk = { |
| 51 | .init_cb = streamer_openiotsdk_init, |
| 52 | .read_cb = streamer_openiotsdk_read, |
| 53 | .write_cb = streamer_openiotsdk_write, |
| 54 | }; |
| 55 | |
| 56 | streamer_t * streamer_get() |
| 57 | { |
| 58 | return &streamer_openiotsdk; |
| 59 | } |
| 60 | |
| 61 | } // namespace Shell |
| 62 | } // namespace chip |