bfb.h File Reference

BFB transport encapsulation (used for Siemens mobile equipment). More...

`#include <inttypes.h>`

## Data Structures

struct | bfb_frame_t
struct | bfb_data_t

## Macros

#define | BFB_FRAME_CONNECT 0x02 /* ^B */
#define | BFB_FRAME_INTERFACE 0x01 /* ^A */
#define | BFB_FRAME_KEY 0x05 /* ^E */
#define | BFB_FRAME_AT 0x06 /* ^F */
#define | BFB_FRAME_EEPROM 0x14 /* ^N */
#define | BFB_FRAME_DATA 0x16 /* ^P */
#define | BFB_CONNECT_HELLO 0x14 /* ^N */
#define | BFB_CONNECT_HELLO_ACK 0xaa
#define | BFB_KEY_PRESS 0x06 /* ^F */
#define | MAX_PACKET_DATA 32
#define | BFB_DATA_ACK 0x01 /* aka ok */
#define | BFB_DATA_FIRST 0x02 /* first transmission in a row */
#define | BFB_DATA_NEXT 0x03 /* continued transmission */
#define | bfb_write_at(fd, data) bfb_write_packets(fd, BFB_FRAME_AT, (uint8_t *)data, strlen(data))
#define | bfb_write_key(fd, data) bfb_write_subcmd8(fd, BFB_FRAME_KEY, BFB_KEY_PRESS, data)
#define | bfb_send_ack(fd) bfb_send_data(fd, BFB_DATA_ACK, NULL, 0, 0)
#define | bfb_send_first(fd, data, length) bfb_send_data(fd, BFB_DATA_FIRST, data, length, 0)
#define | bfb_send_next(fd, data, length, seq) bfb_send_data(fd, BFB_DATA_NEXT, data, length, seq)

## Typedefs

typedef int | fd_t

## Functions

uint8_t | bfb_checksum (uint8_t *data, int len)
| Returns the whole buffer folded with xor.
int | bfb_write_subcmd (fd_t fd, uint8_t type, uint8_t subtype)
| Send a cmd, subcmd packet, add chk (no parameters).
int | bfb_write_subcmd0 (fd_t fd, uint8_t type, uint8_t subtype)
| Send a cmd, subcmd packet.
int | bfb_write_subcmd8 (fd_t fd, uint8_t type, uint8_t subtype, uint8_t p1)
| Send a cmd, subcmd, data packet.
int | bfb_write_subcmd1 (fd_t fd, uint8_t type, uint8_t subtype, uint16_t p1)
| Send a cmd, subcmd packet, add chk (one word parameter).
int | bfb_write_subcmd2 (fd_t fd, uint8_t type, uint8_t subtype, uint16_t p1, uint16_t p2)
| Send a cmd, subcmd packet, add chk (two word parameter).
int | bfb_write_subcmd3 (fd_t fd, uint8_t type, uint8_t subtype, uint16_t p1, uint16_t p2, uint16_t p3)
| Send a cmd, subcmd packet, add chk (three word parameter).
int | bfb_write_subcmd_lw (fd_t fd, uint8_t type, uint8_t subtype, uint32_t p1, uint16_t p2)
| Send a cmd, subcmd packet, add long, word parameter.
int | bfb_stuff_data (uint8_t *buffer, uint8_t type, uint8_t *data, uint16_t len, uint8_t seq)
| Stuff data frame into serial cable encapsulation.
int | bfb_write_packets (fd_t fd, uint8_t type, uint8_t *buffer, int length)
| Send actual packets.
int | bfb_send_data (fd_t fd, uint8_t type, uint8_t *data, uint16_t length, uint8_t seq)
| Stuff data into packet buffers and send all packets.
bfb_frame_t * | bfb_read_packets (uint8_t *buffer, int *length)
| Retrieve actual packets.
int | bfb_assemble_data (bfb_data_t **data, int *size, int *len, bfb_frame_t *frame)
| Append BFB frame to a data buffer.
int | bfb_check_data (bfb_data_t *data, int len)
| Check if data buffer is complete and valid.

## Detailed Description

BFB transport encapsulation (used for Siemens mobile equipment).

ObexFTP library - language bindings for OBEX file transfer.

Copyright (c) 2002-2007 Christian W. Zuckschwerdt zany@.nosp@m.triq.nosp@m..net

ObexFTP is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with ObexFTP. If not, see http://www.gnu.org/.

## Macro Definition Documentation

## BFB_CONNECT_HELLO

#define BFB_CONNECT_HELLO 0x14 /* ^N */

## BFB_CONNECT_HELLO_ACK

#define BFB_CONNECT_HELLO_ACK 0xaa

## BFB_DATA_ACK

#define BFB_DATA_ACK 0x01 /* aka ok */

## BFB_DATA_FIRST

#define BFB_DATA_FIRST 0x02 /* first transmission in a row */

## BFB_DATA_NEXT

#define BFB_DATA_NEXT 0x03 /* continued transmission */

## BFB_FRAME_AT

#define BFB_FRAME_AT 0x06 /* ^F */

## BFB_FRAME_CONNECT

#define BFB_FRAME_CONNECT 0x02 /* ^B */

## BFB_FRAME_DATA

#define BFB_FRAME_DATA 0x16 /* ^P */

## BFB_FRAME_EEPROM

#define BFB_FRAME_EEPROM 0x14 /* ^N */

## BFB_FRAME_INTERFACE

#define BFB_FRAME_INTERFACE 0x01 /* ^A */

## BFB_FRAME_KEY

#define BFB_FRAME_KEY 0x05 /* ^E */

## BFB_KEY_PRESS

#define BFB_KEY_PRESS 0x06 /* ^F */

## bfb_send_ack

#define bfb_send_ack | ( |  | fd | ) | bfb_send_data(fd, BFB_DATA_ACK, NULL, 0, 0)

## bfb_send_first

#define bfb_send_first | ( |  | fd,
|  |  | data,
|  |  | length
| ) |  | bfb_send_data(fd, BFB_DATA_FIRST, data, length, 0)

## bfb_send_next

#define bfb_send_next | ( |  | fd,
|  |  | data,
|  |  | length,
|  |  | seq
| ) |  | bfb_send_data(fd, BFB_DATA_NEXT, data, length, seq)

## bfb_write_at

#define bfb_write_at | ( |  | fd,
|  |  | data
| ) |  | bfb_write_packets(fd, BFB_FRAME_AT, (uint8_t *)data, strlen(data))

## bfb_write_key

#define bfb_write_key | ( |  | fd,
|  |  | data
| ) |  | bfb_write_subcmd8(fd, BFB_FRAME_KEY, BFB_KEY_PRESS, data)

## MAX_PACKET_DATA

#define MAX_PACKET_DATA 32

## Typedef Documentation

## fd_t

typedef int fd_t

## Function Documentation

## bfb_assemble_data()

int bfb_assemble_data | ( | bfb_data_t ** | data,
|  | int * | size,
|  | int * | len,
|  | bfb_frame_t * | frame
| ) |  |

Append BFB frame to a data buffer.

## bfb_check_data()

int bfb_check_data | ( | bfb_data_t * | data,
|  | int | len
| ) |  |

Check if data buffer is complete and valid.

## bfb_checksum()

uint8_t bfb_checksum | ( | uint8_t * | data,
|  | int | len
| ) |  |

Returns the whole buffer folded with xor.

## bfb_read_packets()

bfb_frame_t * bfb_read_packets | ( | uint8_t * | buffer,
|  | int * | length
| ) |  |

Retrieve actual packets.

## bfb_send_data()

int bfb_send_data | ( | fd_t | fd,
|  | uint8_t | type,
|  | uint8_t * | data,
|  | uint16_t | length,
|  | uint8_t | seq
| ) |  |

Stuff data into packet buffers and send all packets.

## bfb_stuff_data()

int bfb_stuff_data | ( | uint8_t * | buffer,
|  | uint8_t | type,
|  | uint8_t * | data,
|  | uint16_t | len,
|  | uint8_t | seq
| ) |  |

Stuff data frame into serial cable encapsulation.

buffer needs to be of at leaset len+7 size Type 0x01: "prepare" command. Type 0x02: first transmission in a row. Type 0x03: continued transmission. seq needs to be incremented afterwards.

## bfb_write_packets()

int bfb_write_packets | ( | fd_t | fd,
|  | uint8_t | type,
|  | uint8_t * | buffer,
|  | int | length
| ) |  |

Send actual packets.

Patch from Jorge Ventura to handle EAGAIN from write.

## bfb_write_subcmd()

int bfb_write_subcmd | ( | fd_t | fd,
|  | uint8_t | type,
|  | uint8_t | subtype
| ) |  |

Send a cmd, subcmd packet, add chk (no parameters).

## bfb_write_subcmd0()

int bfb_write_subcmd0 | ( | fd_t | fd,
|  | uint8_t | type,
|  | uint8_t | subtype
| ) |  |

Send a cmd, subcmd packet.

## bfb_write_subcmd1()

int bfb_write_subcmd1 | ( | fd_t | fd,
|  | uint8_t | type,
|  | uint8_t | subtype,
|  | uint16_t | p1
| ) |  |

Send a cmd, subcmd packet, add chk (one word parameter).

## bfb_write_subcmd2()

int bfb_write_subcmd2 | ( | fd_t | fd,
|  | uint8_t | type,
|  | uint8_t | subtype,
|  | uint16_t | p1,
|  | uint16_t | p2
| ) |  |

Send a cmd, subcmd packet, add chk (two word parameter).

## bfb_write_subcmd3()

int bfb_write_subcmd3 | ( | fd_t | fd,
|  | uint8_t | type,
|  | uint8_t | subtype,
|  | uint16_t | p1,
|  | uint16_t | p2,
|  | uint16_t | p3
| ) |  |

Send a cmd, subcmd packet, add chk (three word parameter).

## bfb_write_subcmd8()

int bfb_write_subcmd8 | ( | fd_t | fd,
|  | uint8_t | type,
|  | uint8_t | subtype,
|  | uint8_t | p1
| ) |  |

Send a cmd, subcmd, data packet.

## bfb_write_subcmd_lw()

int bfb_write_subcmd_lw | ( | fd_t | fd,
|  | uint8_t | type,
|  | uint8_t | subtype,
|  | uint32_t | p1,
|  | uint16_t | p2
| ) |  |

Send a cmd, subcmd packet, add long, word parameter.