:py:mod:`expliot.core.interfaces.zbauditor` =========================================== .. py:module:: expliot.core.interfaces.zbauditor .. autoapi-nested-parse:: Wrapper for ZbAuditor interface. Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 nrf52840/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: expliot.core.interfaces.zbauditor.NRF52840 expliot.core.interfaces.zbauditor.ZbAuditor .. py:class:: NRF52840(channel=0, page=0) Bases: :py:obj:`expliot.core.interfaces.common_services.ZbAuditorServices` Driver for NRF52840 Zigbee Auditor Hardware. .. py:attribute:: USB_DIR_OUT :annotation: = 64 .. py:attribute:: USB_DIR_IN :annotation: = 192 .. py:attribute:: USB_DATA_EP :annotation: = 131 .. py:attribute:: USB_VID :annotation: = 6421 .. py:attribute:: USB_PID :annotation: = 21018 .. py:attribute:: USB_READ_TIMEOUT_MIN :annotation: = 100 .. py:attribute:: USB_READ_TIMEOUT_MAX :annotation: = 2000 .. py:attribute:: USB_MAX_BYTE_READ :annotation: = 64 .. py:attribute:: SRV_GET_FW_VER :annotation: = 1 .. py:attribute:: SRV_GET_FW_SRV :annotation: = 2 .. py:attribute:: SRV_POWER_ON :annotation: = 32 .. py:attribute:: SRV_GET_POWER_STATUS :annotation: = 33 .. py:attribute:: SRV_SET_CHANNEL :annotation: = 34 .. py:attribute:: SRV_SET_SNIFF_START :annotation: = 35 .. py:attribute:: SRV_SET_SNIFF_STOP :annotation: = 36 .. py:attribute:: SRV_SEND_PACKET_INJECT :annotation: = 37 .. py:attribute:: SRV_ZB_NWKSCAN_REQ :annotation: = 49 .. py:attribute:: SERVICE_RESP_MASK :annotation: = 128 .. py:attribute:: SRV_GET_FW_VER_RESP .. py:attribute:: SRV_GET_FW_SRV_RESP .. py:attribute:: SRV_GET_POWER_STATUS_RESP .. py:attribute:: SRV_ZB_NWKSCAN_RESP .. py:attribute:: SRV_GET_FW_VER_RESP_LEN :annotation: = 5 .. py:attribute:: SRV_GET_FW_SRV_RESP_LEN :annotation: = 6 .. py:attribute:: SRV_ZB_NWKSCAN_RESP_MIN_LEN :annotation: = 3 .. py:attribute:: SRV_ZB_NWKSCAN_RESP_DATA_LEN :annotation: = 1 .. py:attribute:: SRV_RESP_BYTE_1 :annotation: = 2 .. py:attribute:: SRV_RESP_BYTE_2 :annotation: = 3 .. py:attribute:: SRV_RESP_BYTE_3 :annotation: = 4 .. py:attribute:: SRV_RESP_BYTE_4 :annotation: = 5 .. py:attribute:: SRV_ZB_NWKSCAN_RESP_LEN_INDEX :annotation: = 1 .. py:attribute:: SRV_ZB_NWKSCAN_RESP_NUM_DEV_INDEX :annotation: = 3 .. py:attribute:: SRV_ZB_NWKSCAN_RESP_DEV_NUM_LEN :annotation: = 1 .. py:attribute:: SRV_SET_CH_CHNG_BIT :annotation: = 1 .. py:attribute:: SRV_RAW_CAPTURE_BIT :annotation: = 2 .. py:attribute:: SRV_RAW_INJECT_BIT :annotation: = 4 .. py:attribute:: SRV_NWK_SCAN_BIT :annotation: = 8 .. py:attribute:: SRV_SUPP_FREQ_2400_BIT :annotation: = 1 .. py:attribute:: SERVICE_STATUS_OK :annotation: = 0 .. py:attribute:: SERVICE_STATUS_END :annotation: = 1 .. py:attribute:: MAC_POWER_ON_STATUS :annotation: = 1 .. py:attribute:: MAC_24GHZ_CHANNEL_11 :annotation: = 11 .. py:attribute:: MAC_24GHZ_CHANNEL_26 :annotation: = 26 .. py:attribute:: MAC_24GHZ_DEFAULT_PAGE :annotation: = 0 .. py:attribute:: SOF_BYTE :annotation: = 0 .. py:attribute:: BEACON_INFO_LEN :annotation: = 28 .. py:attribute:: USB_OPERATION_TIMEOUT :annotation: = 110 .. py:method:: get_device_fw_rev() Read and validate response to GET Firmware Revision Service. :return: Firmware version array (3 bytes) .. py:method:: get_device_fw_rev_str() "Return firmware revision in string format. .. py:method:: read_supported_service() Read and validate response to GET Firmware Capability Service. :return: Firmware Capability .. py:method:: _device_set_channel() Set the channel in the device MAC hardware. .. py:method:: device_set_channel(channel, page=0) Set channel locally and of device hardware. .. py:method:: device_radio_on() Turn on radio and MAC layer. .. py:method:: device_sniffer_on(channel=None, page=0) Start sniffer service. .. py:method:: calculate_crc(data) :staticmethod: Return CRC of data. CRC algorithm implementation is based on pseudo code from Frank da Cruz (June 1986), Kermit Protocol Manual, Sixth Edition Refer: http://reveng.sourceforge.net/crc-catalogue/16.htm#crc.cat.crc-16-kermit :return: a CRC that is the FCS for the frame, as two hex bytes in little-endian order. .. py:method:: _process_sniffer_response(rxframe) Return dictionary of Zigbee packet and timestamp. :param array: Frame data array :return: dictionary {"packet": zbpacket, "timestamp": 32bit timestamp} .. py:method:: device_read(timeout=100) Read packet from USB interface. If Zigbee packet length is less than 56 bytes process the packet If Zigbee packet length is more than 56 bytes, waits for next chunk :param timeout: Time out for read operation :return: Zigbee packet and timestamp as {"packet": packet, "timestamp": timestamp (32bit) } .. py:method:: process_scan_response(response) Return dictionary of number of deivces found in scan and device zigbee beacon info. :param array: Frame data array :return: Result of Network scan as {"Device Count": 1, "Beacons": [{ ... }]} .. py:method:: device_scan_zigbee_network(mask=134215680) Set device in IEEE802.15.4 network scan mode. Also, the IEEE 802.15.4 channels are scan for beacon and data :param mask: channel mask, channel 25 => 0x07000000 .. channel 11 => 0x00000800 :return: network scan data .. py:method:: device_inject_packet(packet) Inject packet too device. :param packet: byte array .. py:method:: device_sniffer_off() Turn off sniffer service. .. py:method:: device_radio_off() Turn off sniffer and radio. .. py:method:: usb_cntrl_read(brequest, wvalue=0, windex=0, data_or_wlength=None, timeout=100) USB Control Transfer, EP0 DIR IN. :param brequest: usb bRequest :param wvalue: usb wValue :param windex: usb wIndex :param data_or_wlength: usb data to be write :param timeout: timeout for write transaction :return: bytes read from driver (array object) .. py:method:: usb_cntrl_write(brequest, wvalue=0, windex=0, data_or_wlength=None, timeout=200) USB Control Transfer, EP0 DIR OUT. :param brequest: usb bRequest :param wvalue: usb wValue :param windex: usb wIndex :param data_or_wlength: usb data to be write :param timeout: timeout for write transaction :return: number of bytes written .. py:method:: usb_read(size_or_buffer, timeout=200) USB Bulk read for EP3. :param size_or_buffer: data buffer or size to be read :param timeout: Timeout for read transaction :return: bytes read from driver (array object) .. py:method:: get_device_name() Return the device name. .. py:method:: get_radio_on_flag() Returns radio_on flag value. .. py:method:: set_radio_on_flag(flag) Set radio_on flag value. :param flag: True or False .. py:method:: get_sniffer_on_flag() Return the sniffer_on flag value. .. py:method:: set_sniffer_on_flag(flag) Set sniffer_on flag value. .. py:method:: get_device_serial_num() Return the device serial number. .. py:method:: close() Turn off sniffer and radio before closing. .. py:method:: __del__() Close device. .. py:class:: ZbAuditor Zigbee Auditor Class. .. py:method:: get_interface_info() Return Device information in dictionary format. :return: Dictionary of Device Name, FW Revision, Services .. py:method:: set_channel(channel, page=0) Validate and Set Channel to Device. .. py:method:: get_channel() Return Channel from Device. .. py:method:: get_radio_on_flag() Return status of radio_on flag. .. py:method:: set_radio_on_flag(flag) Set radio_on flag. .. py:method:: get_sniffer_on_flag() Return status of sniffer_on flag. .. py:method:: set_sniffer_on_flag(flag) Set sniffer_on flag. .. py:method:: radio_on() Turn on device radio. .. py:method:: sniffer_on(channel, page=0) Turn on device sniffer service. .. py:method:: packet_read(timeout=100) Read data from device. .. py:method:: radio_off() Turn off device radio. .. py:method:: sniffer_off() Turn off device sniffer service. .. py:method:: inject_packet(packet) Inject packet to Device. .. py:method:: scan_zb_network(mask) Set Device in network scan mode. Additionally it return network scan result as dictionary. .. py:method:: get_rxcount() Return packet receive count from driver. :return: rx count .. py:method:: get_txcount() Return packet transmit count from driver. :return: tx count .. py:method:: __del__() Close the driver.