1## Introduction 2 3This library extends the common libPhyComv1 providing the low level 4communications mechanism between the devices and the 2G4 phy 5 6Note that this Phy only supports BLE or 2006 802.15.4 DSS like modulations, 7or interferers. 8So it cannot be used for WLAN (or other OFDMA like) 9 10## 2G4 IPC protocol 11 12You can find the sequence diagrams here: 13[2G4 IPC sequence diagrams](2G4_libPhyComv1_protocol.svg) 14 15![2G4 IPC sequence diagrams (for GitHub web rendering)](https://raw.githubusercontent.com/BabbleSim/ext_2G4_libPhyComv1/master/docs/2G4_libPhyComv1_protocol.svg?sanitize=true) 16<!--The ?sanitize=true is an ugly thing for GitHub to enable the svg to be 17rendered into the markdown preview--> 18 19The content of these structures, which are sent between the devices and phy, 20can be found in [bs_pc_2G4_types.h](../src/bs_pc_2G4_types.h) 21 22### v2 API Updates 23 24Note: The old API is still supported, and remains ABI compatible 25The v2 API is a superset of the old API aiming at providing support for 26different protocols, and more features. 27 28If desired, devices which supported the old API can be mapped to the new API 29without loss of functionality (see instructions on each structure in the header 30file). But at this point it is not recommended to do this, as the new API is 31still in alpha state. 32 33#### Txv2: 34A p2G4_txv2_t structure from the device, is followed by a byte array of 35packet_size bytes. 36A p2G4_txv2_t is followed by a p2G4_tx_done_t from the Phy. 37 38#### Rxv2: 39A p2G4_rxv2_t structure from the device is followed by a p2G4_rxv2_addr_t, 40containing p2G4_rxv2_t.n_addr elements. 41 42When p2G4_rxv2_t.resp_type = 0, the Phy responds with a p2G4_rx_done_t, 43and dependending on status, a bytearray of p2G4_rx_done_t.packet_size bytes 44with the possibly received packet. 45 46#### RSSI measurements during abort reevaluations 47During an Rx abort reevaluation, the device may now both send back a new abort 48structure (after a RERESP_ABORTREEVAL) or also request an immediate RSSI 49measurement (and follow it with another abort structure) 50 51#### CCA procedure 52To better support systems with CCA, a new API is introduced. 53The device may do a seach for compabile modulations and/or an (average) energy 54measument. 55This is done periodically by looking for a compatible transmitter 56and simultaneously measuring the RRSI level. 57The device may also select to stop the measurement as soon as either the RSSI 58measurement is over a predefined threshold, or, the RSSI measurement is over 59another threshold and a compatible modulation is found in the air. 60 61#### Coded Phy and other multi-modulation and/or multi-payload packets 62Coded Phy packets shall be handled as two back to back transmissions. 63Where the 1st transmission covers the {preamble + address + CI + term} 64and the 2nd transmissions covers the {training sequence + header + CRC}. 65For each consecutive transmission the following must be true: 66 67* {1st tx}.end_tx_time = {1st tx}.end_packet_time 68* {2nd tx}.start_tx_time = {1st tx}.end_tx_time + 1 69* {2nd tx}.start_tx_time = {2nd tx}.start_packet_time 70 71In the receive side, similarly 2 receptions will be performed. 72Where the 1st reception will attempt to receive only the 1st transmission, 73and the 2nd reception must be configured with prelocked_tx set to true. 74In this case, the receiver will continue automatically with the same 75transmitter it sync'ed to last time. 76It is the responsability of the device to properly set the modulation of the 772nd reception to match the transmitter 2nd transmission. 78 79For coded phy, the 2nd/piggybacking Rx pream_and_addr_duration should be set to 800, acceptable_pre_truncation = 0, scan_duration = 1, 81sync_threshold = UINT16_MAX. 82 83This can be expanded to any number of sub-payloads with the same or different 84modulations. 85 86## API 87 88A description of the library API can be found in 89[bs_pc_2G4.h](../src/bs_pc_2G4.h) 90