blob: ae0e9d824aebb968610bffba9c0ec6a722cd8b1b [file] [log] [blame]
Artur Tynecki0efd3182022-12-05 20:18:32 +01001/*
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
29namespace chip {
30namespace Shell {
31
32int streamer_openiotsdk_init(streamer_t * streamer)
33{
34 (void) streamer;
35 return 0;
36}
37
38ssize_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
44ssize_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
50static streamer_t streamer_openiotsdk = {
51 .init_cb = streamer_openiotsdk_init,
52 .read_cb = streamer_openiotsdk_read,
53 .write_cb = streamer_openiotsdk_write,
54};
55
56streamer_t * streamer_get()
57{
58 return &streamer_openiotsdk;
59}
60
61} // namespace Shell
62} // namespace chip