iSDIO Library for TOSHIBA FlashAir. include HTTP or HTTPS Client.

Dependencies:   SDFileSystem

Dependents:   FlashAir_Twitter Neon_F303K8_04

Fork of HTTPClient by Donatien Garnier

Committer:
ban4jp
Date:
Mon Dec 15 12:23:22 2014 +0000
Revision:
20:51abf34bcc06
Initial commit.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ban4jp 20:51abf34bcc06 1 /* Arduino Sdio Library
ban4jp 20:51abf34bcc06 2 * Copyright (C) 2014 by Munehiro Doi, Fixstars Corporation
ban4jp 20:51abf34bcc06 3 * All rights reserved.
ban4jp 20:51abf34bcc06 4 * Released under the BSD 2-Clause license.
ban4jp 20:51abf34bcc06 5 * http://flashair-developers.com/documents/license.html
ban4jp 20:51abf34bcc06 6 */
ban4jp 20:51abf34bcc06 7
ban4jp 20:51abf34bcc06 8 #include "iSDIO_helper.h"
ban4jp 20:51abf34bcc06 9
ban4jp 20:51abf34bcc06 10 //------------------------------------------------------------------------------
ban4jp 20:51abf34bcc06 11 /** specific version for string. it adds padding bytes after text data. */
ban4jp 20:51abf34bcc06 12 template <>
ban4jp 20:51abf34bcc06 13 uint8_t* put_T(uint8_t* p, const char* value) {
ban4jp 20:51abf34bcc06 14 while (*value != 0) {
ban4jp 20:51abf34bcc06 15 *p++ = *((uint8_t*)value++);
ban4jp 20:51abf34bcc06 16 }
ban4jp 20:51abf34bcc06 17 return p;
ban4jp 20:51abf34bcc06 18 }
ban4jp 20:51abf34bcc06 19
ban4jp 20:51abf34bcc06 20 template <>
ban4jp 20:51abf34bcc06 21 uint8_t* put_T_arg(uint8_t* p, const char* value) {
ban4jp 20:51abf34bcc06 22 uint8_t* orig = p;
ban4jp 20:51abf34bcc06 23 p += sizeof(uint32_t); // skip length area.
ban4jp 20:51abf34bcc06 24 p = put_T(p, value); // data
ban4jp 20:51abf34bcc06 25 uint32_t len = p - orig - sizeof(uint32_t);
ban4jp 20:51abf34bcc06 26 put_T(orig, len); // write length.
ban4jp 20:51abf34bcc06 27 for (int i = 0; i < ((4 - (len & 3)) & 3); ++i) { // padding
ban4jp 20:51abf34bcc06 28 *p++ = 0;
ban4jp 20:51abf34bcc06 29 }
ban4jp 20:51abf34bcc06 30 return p;
ban4jp 20:51abf34bcc06 31 }
ban4jp 20:51abf34bcc06 32
ban4jp 20:51abf34bcc06 33 uint8_t* put_command_header(uint8_t* p, uint8_t num_commands,
ban4jp 20:51abf34bcc06 34 uint32_t command_bytes) {
ban4jp 20:51abf34bcc06 35 p = put_u8(p, 0x01); // Write Data ID
ban4jp 20:51abf34bcc06 36 p = put_u8(p, num_commands); // Number of commands.
ban4jp 20:51abf34bcc06 37 p = put_u16(p, 0); // reserved.
ban4jp 20:51abf34bcc06 38 p = put_u32(p, command_bytes); // size of command write data.
ban4jp 20:51abf34bcc06 39 p = put_u32(p, 0); // reserved.
ban4jp 20:51abf34bcc06 40 return p;
ban4jp 20:51abf34bcc06 41 }
ban4jp 20:51abf34bcc06 42
ban4jp 20:51abf34bcc06 43 uint8_t* put_command_info_header(uint8_t* p, uint16_t command_id,
ban4jp 20:51abf34bcc06 44 uint32_t sequence_id, uint16_t num_args) {
ban4jp 20:51abf34bcc06 45 p = put_u16(p, 0); // reserved.
ban4jp 20:51abf34bcc06 46 p = put_u16(p, command_id); // iSDIO command id.
ban4jp 20:51abf34bcc06 47 p = put_u32(p, sequence_id); // iSDIO command sequence id.
ban4jp 20:51abf34bcc06 48 p = put_u16(p, num_args); // Number of Arguments.
ban4jp 20:51abf34bcc06 49 p = put_u16(p, 0); // Reserved.
ban4jp 20:51abf34bcc06 50 return p;
ban4jp 20:51abf34bcc06 51 }