NuMaker connection with AWS IoT thru MQTT/HTTPS (Mbed OS 6)

Dependencies:   MQTT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers fetch_host_command.cpp Source File

fetch_host_command.cpp

00001 /* 
00002  * Copyright (c) 2019 Nuvoton Technology Corporation
00003  *
00004  * SPDX-License-Identifier: Apache-2.0
00005  *
00006  * Licensed under the Apache License, Version 2.0 (the "License");
00007  * you may not use this file except in compliance with the License.
00008  * You may obtain a copy of the License at
00009  *
00010  *     http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  * Unless required by applicable law or agreed to in writing, software
00013  * distributed under the License is distributed on an "AS IS" BASIS,
00014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  * See the License for the specific language governing permissions and
00016  * limitations under the License.
00017  */
00018 
00019 #include "mbed.h"
00020 
00021 /* Fetch host command communicating via USB VCOM
00022  *
00023  * WARNING: For mass production, remove this file.
00024  */
00025 
00026 /* Check weak reference/definition at the link:
00027  * http://www.keil.com/support/man/docs/ARMLINK/armlink_pge1362065917715.htm */
00028 
00029 extern "C" {
00030     MBED_USED int fetch_host_command(void);
00031 }
00032 
00033 int fetch_host_command(void)
00034 {
00035     struct pollfd fds[1];
00036 
00037     fds[0].fd = STDIN_FILENO;
00038     fds[0].events = POLLIN;    
00039     int rc = poll(fds, sizeof(fds)/sizeof(fds[0]), 0);
00040     if ((rc > 0) && (fds[0].revents & POLLIN)) {
00041         return getchar();
00042     } else {
00043         return -1;
00044     }
00045 }