OneNet_IoT_demo for ASC platform

Dependencies:   Common_lib ESP8266 EdpKit_lib cJSON_lib driver_mbed_HP20x driver_mbed_TH02 wifi_example

Fork of mbed-os-example-esp8266 by ESP8266

Committer:
sarahmarshy
Date:
Thu Jan 12 22:05:15 2017 +0000
Revision:
1:b4a718e62e0b
Parent:
0:b887535f68bf
Update esp8266-driver

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sarahmarshy 1:b4a718e62e0b 1 /*
sarahmarshy 1:b4a718e62e0b 2 * Copyright (c) 2014-2015 ARM Limited. All rights reserved.
sarahmarshy 1:b4a718e62e0b 3 * SPDX-License-Identifier: Apache-2.0
sarahmarshy 1:b4a718e62e0b 4 * Licensed under the Apache License, Version 2.0 (the License); you may
sarahmarshy 1:b4a718e62e0b 5 * not use this file except in compliance with the License.
sarahmarshy 1:b4a718e62e0b 6 * You may obtain a copy of the License at
sarahmarshy 1:b4a718e62e0b 7 *
sarahmarshy 1:b4a718e62e0b 8 * http://www.apache.org/licenses/LICENSE-2.0
sarahmarshy 1:b4a718e62e0b 9 *
sarahmarshy 1:b4a718e62e0b 10 * Unless required by applicable law or agreed to in writing, software
sarahmarshy 1:b4a718e62e0b 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
sarahmarshy 1:b4a718e62e0b 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sarahmarshy 1:b4a718e62e0b 13 * See the License for the specific language governing permissions and
sarahmarshy 1:b4a718e62e0b 14 * limitations under the License.
sarahmarshy 1:b4a718e62e0b 15 */
sarahmarshy 1:b4a718e62e0b 16
sarahmarshy 1:b4a718e62e0b 17 #include <stdarg.h>
sarahmarshy 1:b4a718e62e0b 18 #include <stdint.h>
sarahmarshy 1:b4a718e62e0b 19 #include <stdio.h>
sarahmarshy 1:b4a718e62e0b 20 #include <string.h>
sarahmarshy 1:b4a718e62e0b 21
sarahmarshy 1:b4a718e62e0b 22 #include "mbed_error.h"
sarahmarshy 1:b4a718e62e0b 23
sarahmarshy 1:b4a718e62e0b 24 size_t BufferedSerialThunk(void *buf_serial, const void *s, size_t length);
sarahmarshy 1:b4a718e62e0b 25
sarahmarshy 1:b4a718e62e0b 26 int BufferedPrintfC(void *stream, int size, const char* format, va_list arg)
sarahmarshy 1:b4a718e62e0b 27 {
sarahmarshy 1:b4a718e62e0b 28 int r;
sarahmarshy 1:b4a718e62e0b 29 char buffer[512];
sarahmarshy 1:b4a718e62e0b 30 if (size >= 512) {
sarahmarshy 1:b4a718e62e0b 31 return -1;
sarahmarshy 1:b4a718e62e0b 32 }
sarahmarshy 1:b4a718e62e0b 33 memset(buffer, 0, size);
sarahmarshy 1:b4a718e62e0b 34 r = vsprintf(buffer, format, arg);
sarahmarshy 1:b4a718e62e0b 35 // this may not hit the heap but should alert the user anyways
sarahmarshy 1:b4a718e62e0b 36 if(r > (int32_t) size) {
sarahmarshy 1:b4a718e62e0b 37 error("%s %d buffer overwrite (max_buf_size: %d exceeded: %d)!\r\n", __FILE__, __LINE__, size, r);
sarahmarshy 1:b4a718e62e0b 38 return 0;
sarahmarshy 1:b4a718e62e0b 39 }
sarahmarshy 1:b4a718e62e0b 40 if ( r > 0 ) {
sarahmarshy 1:b4a718e62e0b 41 BufferedSerialThunk(stream, buffer, r);
sarahmarshy 1:b4a718e62e0b 42 }
sarahmarshy 1:b4a718e62e0b 43 return r;
sarahmarshy 1:b4a718e62e0b 44 }