Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

6LoWPAN over BLE (RFC7668)

6LoWPAN over BLE (RFC7668)
[NETIFs]

This file implements a RFC7668 implementation for 6LoWPAN over Bluetooth Low Energy. More...

Functions

void ble_addr_to_eui64 (uint8_t *dst, const uint8_t *src, int public_addr)
 convert BT address to EUI64 addr
void eui64_to_ble_addr (uint8_t *dst, const uint8_t *src)
 convert EUI64 address to Bluetooth MAC addr
err_t rfc7668_set_context (u8_t idx, const ip6_addr_t *context)
 Set context id IPv6 address.
err_t rfc7668_output (struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr)
 Compress outgoing IPv6 packet and pass it on to netif->linkoutput.
err_t rfc7668_input (struct pbuf *p, struct netif *netif)
 Process a received raw payload from an L2CAP channel.
err_t rfc7668_if_init (struct netif *netif)
 Initialize the netif.

Detailed Description

This file implements a RFC7668 implementation for 6LoWPAN over Bluetooth Low Energy.

The specification is very similar to 6LoWPAN, so most of the code is re-used. Compared to 6LoWPAN, much functionality is already implemented in lower BLE layers (fragmenting, session management,...).

Usage:

  • add this netif
    • don't add IPv4 addresses (no IPv4 support in RFC7668), pass 'NULL','NULL','NULL'
    • use the BLE to EUI64 conversation util to create an IPv6 link-local address from the BLE MAC (ble_addr_to_eui64)
    • input function: rfc7668_input
  • set the link output function, which transmits output data to an established L2CAP channel
  • If data arrives (HCI event "L2CAP_DATA_PACKET"):
    • allocate a PBUF_RAW buffer
    • let the pbuf struct point to the incoming data or copy it to the buffer
    • call netif->input

Function Documentation

void ble_addr_to_eui64 ( uint8_t *  dst,
const uint8_t *  src,
int  public_addr 
)

convert BT address to EUI64 addr

This method converts a Bluetooth MAC address to an EUI64 address, which is used within IPv6 communication

Parameters:
dstIPv6 destination space
srcBLE MAC address source
public_addrIf the LWIP_RFC7668_LINUX_WORKAROUND_PUBLIC_ADDRESS option is set, bit 0x02 will be set if param=0 (no public addr); cleared otherwise
See also:
LWIP_RFC7668_LINUX_WORKAROUND_PUBLIC_ADDRESS

Definition at line 110 of file lwip_lowpan6_ble.c.

void eui64_to_ble_addr ( uint8_t *  dst,
const uint8_t *  src 
)

convert EUI64 address to Bluetooth MAC addr

This method converts an EUI64 address to a Bluetooth MAC address,

Parameters:
dstBLE MAC address destination
srcIPv6 source

Definition at line 139 of file lwip_lowpan6_ble.c.

err_t rfc7668_if_init ( struct netif netif )

Initialize the netif.

No flags are used (broadcast not possible, not ethernet, ...) The shortname for this netif is "BT"

Parameters:
netifthe network interface to be initialized as RFC7668 netif
Returns:
ERR_OK if everything went fine

Definition at line 410 of file lwip_lowpan6_ble.c.

err_t rfc7668_input ( struct pbuf p,
struct netif netif 
)

Process a received raw payload from an L2CAP channel.

Parameters:
pthe received packet, p->payload pointing to the IPv6 header (maybe compressed)
netifthe network interface on which the packet was received
Returns:
ERR_OK if everything was fine

Definition at line 347 of file lwip_lowpan6_ble.c.

err_t rfc7668_output ( struct netif netif,
struct pbuf q,
const ip6_addr_t ip6addr 
)

Compress outgoing IPv6 packet and pass it on to netif->linkoutput.

Parameters:
netifThe lwIP network interface which the IP packet will be sent on.
qThe pbuf(s) containing the IP packet to be sent.
ip6addrThe IP address of the packet destination.
Returns:
See rfc7668_compress

Definition at line 328 of file lwip_lowpan6_ble.c.

err_t rfc7668_set_context ( u8_t  idx,
const ip6_addr_t context 
)

Set context id IPv6 address.

Store one IPv6 address to a given context id.

Parameters:
idxContext id
contextIPv6 addr for this context
Returns:
ERR_OK (if everything is fine), ERR_ARG (if the context id is out of range), ERR_VAL (if contexts disabled)

Definition at line 300 of file lwip_lowpan6_ble.c.