wifi test

Dependencies:   X_NUCLEO_IKS01A2 mbed-http

Committer:
JMF
Date:
Wed Sep 05 14:28:24 2018 +0000
Revision:
0:24d3eb812fd4
Initial commit

Who changed what in which revision?

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