HTTP Set Channel Mode - FujiNetWIFI/fujinet-firmware GitHub Wiki

N: SIO Command HTTP Set Channel Mode ($4D) ['M']

This is a command for Devices $71-$78 - The N: Device (see SIO-Commands-for-Device-IDs-$71-to-$78).

Description

Changes the channel mode on an HTTP connection. This is used so that you can change the behavior of the GET, PUT, and STATUS commands to retrieve and send different types of information required for a complete HTTP transaction, such as headers, and POST data.

There are four modes which can be selected, depending on the value of AUX2:

AUX2 Description
0 BODY
1 COLLECT HEADERS
2 GET HEADERS
3 SET HEADERS
4 SET POST DATA

AUX2 = BODY

Use this mode to retrieve the BODY of an HTTP document in READ. This causes the HTTP transaction to occur.

With this mode:

  • STATUS returns the number of bytes still to be read in the HTTP BODY.
  • READ will return the specified number of bytes from the HTTP BODY. This causes the HTTTP transaction to occur.
  • WRITE will write the specified number of bytes to the BODY (PUT mode only)

AUX2 = COLLECT HEADERS

Use this mode as the first step in retrieving headers from an HTTP response. Each header requested is written one line at a time, terminated by an ATASCII EOL ($9B). The FujiNet will retrieve exactly the headers written in this mode, in the order in which they are written.

With this mode:

  • STATUS does not return anything meaningful, as it is a write only mode.
  • READ returns a WRITE MODE ONLY error, as it is a write only mode
  • WRITE will write the specified number of bytes to the COLLECT HEADERS routine. It is expected that each header be written, one at a time, terminated by a $9B. Do not write multiple ATASCII EOL terminated lines in one WRITE.

AUX2 = GET HEADERS

Causes the FujiNet to retrieve the HTTP headers, and send each one, one line at a time, over the channel. This causes the HTTP transaction to occur.

With this mode:

  • STATUS returns the number of bytes for the next header value, including the ATASCII EOL.
  • READ returns the number of bytes requested of the next header value. This causes the HTTP transaction to occur. It is expected that this match the value from STATUS.
  • WRITE will return a READ ONLY ERROR, as this is a read-only mode.

AUX2 = SET HEADERS

This mode changes channel behavior so that each WRITE sends a header key, and value in HTTP format, to be sent along with the HTTP transaction.

Set Header format

Key: Value<EOL>
  • Key is the name of the header
  • Value is the value to assign to the header key.

e.g.

Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l

Important

The single white space after Key: is mandatory.

With this mode:

  • STATUS does not return meaningful data, as it is a write-only mode.
  • READ returns a WRITE ONLY error, as this is a write-only mode.
  • WRITE will write the specified # of bytes as a header. The header must be in the format above. With one space after the Key:

Set POST Data

This mode, when used with POST, will cause any WRITE to the channel to be collected as data to be sent when the HTTP transaction is performed. Doing a READ in GET Header or BODY will cause the HTTP transaction to occur, and any POST data to be sent.

With this mode:

  • STATUS does not return meaningful data, as it is a write-only mode.
  • READ returns a WRITE ONLY error, as this is a write-only mode.
  • WRITE will write the specified # of bytes as post data.

Parameters

DCB Value
DDEVIC $71
DUNIT $01 - $04
DCOMND $4D 'M'
DSTATS $00
DBUF NULL
DTIMLO $0F
DBYT 0
DAUX1 N: AUX1 Values
DAUX2 New Channel mode

Examples

CC65

/**
 * Set HTTP Channel mode.
 */
void sio_http_channel_mode(unsigned char new_mode)
{
  OS.vprced=ih;
  PIA.pactl |= 1;
  // Establish connection
  OS.dcb.ddevic=0x71;
  OS.dcb.dunit=1;
  OS.dcb.dcomnd='M';
  OS.dcb.dstats=0x00;
  OS.dcb.dbuf=NULL;
  OS.dcb.dtimlo=0x0f;
  OS.dcb.dbyt=0;
  OS.dcb.daux2=new_mode;
  siov();
}

See Also

Put other related command links here.

⚠️ **GitHub.com Fallback** ⚠️