packet_tx

Mono Wireless Inc.

packet_tx

This class is a wrapper class for the tsTxDataApp structure of the TWENET C library, and objects of derived classes based on this class are obtained from network behaviors or on_tx_comp().

if (auto&& pkt = the_twelite.network.use<NWK_SIMPLE>().prepare_tx_packet()) {
    pkt << tx_addr(0x00)
        << tx_retry(0x1)
        << tx_packet_delay(0,50,10);
        
    pack_bytes(pkt.get_payload()
        , make_pair("APP1", 4)
        , uint8_t(u8DI_BM)
    );
  
  pkt.transmit();
}

Generating objects

This is done by the network behavior .prepare_tx_packet().

if (auto&& pkt = the_twelite.network.use<NWK_SIMPLE>().prepare_tx_packet()) {
  ...
}

In the above example, the_twelite.network.use<NWK_SIMPLE>() retrieves an object of the network behavior. The object pkt is created by .prepare_tx_packet() of this object. It is a derived class of packet_tx, although the type name is inferred by auto&&.

This pkt object first returns true or false in the if(). A false return occurs when the queue for sending is full and no more requests can be added.

Transmission Settings

Various settings are configured in the radio packet to deliver the packet to the destination, including destination information. To configure the settings, an object containing the settings is given as the right-hand side value of the << operator.

pkt << tx_addr(0x00)
      << tx_retry(0x1)
    << tx_packet_delay(0,50,10);

The following is a description of the objects used for configuration.

The availability and implications of each setting depend on the network behavior specification.

tx_addr

tx_addr(uint32_t addr)

Specify the destination address addr. See the Network Behavior specification for the destination address value.

tx_retry

tx_retry(uint8_t u8count, bool force_retry = false)

Specifies the number of retransmissions. The number of retransmissions is specified by u8count. force_retry is a setting to retransmit a specified number of times regardless of whether the transmission is successful or not.

tx_packet_delay

tx_packet_delay(uint16_t u16DelayMin,
                uint16_t u16DelayMax,
                uint16_t u16RetryDur)

Sets the delay between sending packets and the retransmission interval. Specify two values, u16DelayMin and u16DelayMax, in milliseconds [ms]. Transmission will be started at some point during this interval after a transmission request is made. Specify the retransmission interval as the value of u16RetryDur in milliseconds[ms]. The retransmission interval is constant.

The transmission process may not start at the specified timing due to internal processing. In addition, IEEE802.15.4 processing also causes time blurring before packets are created. These timing blurs are an effective means of avoiding packet collisions in many systems.

Strict timing of packet transmission should be considered an exception due to the nature of the IEEE802.15.4 standard.

tx_process_immediate

tx_process_immediate()

This setting requests that packet transmission be performed “as quickly as possible.” Packet transmission processing in TWENET is performed from the TickTimer, which runs every 1 ms. By setting this parameter, the packet transmission request is processed as soon as possible after the request is made. Of course, any setting other than tx_packet_delay(0,0,0) is a meaningless specification.

If other packet transmission processing is in progress, it will be processed as usual.

tx_ack_required

tx_ack_required()

In wireless packet communications, there is a transmission method in which a short radio message called ACK (ACK) is obtained from the destination after the transmission is completed to indicate that the transmission was successful. By setting this option, transmission with ACK is performed.

tx_addr_broadcast

tx_addr_broadcast()

Specify broadcast.

tx_packet_type_id

tx_packet_type_id(uint8_t)

Specify the type ID of the TWENET radio packet that can be 0..7.