def get_mds_parser(self): self.timestamp = Struct("utc_timestamp", SBInt32("day"), UBInt32("sec"), UBInt32("msec")) self.waveform_data = Struct( "wfm", Array(128, Per2048(UBInt16("average_wfm_if_corr_ku"))), Padding(172)) self.mds_record = Struct("mds_record", self.timestamp, SBInt8("quality_indicator"), Padding(3), UBInt32("source_packet_counter"), Padding(8), Array(20, self.waveform_data)) self.mds = Array(self.n_records, self.mds_record) return self.mds
def get_mds_parser(self): self.timestamp = Struct("utc_timestamp", SBInt32("day"), UBInt32("sec"), UBInt32("msec")) self.waveform_data = Struct( "wfm", Array(128, Per2048(UBInt16("average_wfm_if_corr_ku"))), Array(2, Per2048(UBInt16("central_filters_if_corr_ku"))), Array(64, Per8096(UBInt16("average_wfm_if_corr_s"))), Array(2, SBInt16("indexes_of_2_dft_samples")), Per256(SBInt16("delta_offset_fft_filter_units")), Padding(18), Per2048(SBInt16("noise_power_measurement")), OneHundredth(SBInt16("agc_of_noise_power_measurement")), OneHundredthDecibel(UBInt16("reference_power_value")), Padding(10)) self.mds_record = Struct("mds_record", self.timestamp, SBInt8("quality_indicator"), Padding(3), UBInt32("source_packet_counter"), Padding(8), Array(20, self.waveform_data)) self.mds = Array(self.n_records, self.mds_record) return self.mds
from construct import Struct from construct import Array from empower.datatypes.etheraddress import EtherAddress from empower.core.module import Module from empower.core.resourcepool import CQM from empower.core.resourcepool import ResourceBlock from empower.lvapp import PT_VERSION from empower.main import RUNTIME POLLER_ENTRY_TYPE = Sequence("img_entries", Bytes("addr", 6), UBInt8("last_rssi_std"), SBInt8("last_rssi_avg"), UBInt32("last_packets"), UBInt32("hist_packets"), SBInt8("mov_rssi")) POLLER_REQUEST = Struct("poller_request", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("hwaddr", 6), UBInt8("channel"), UBInt8("band")) POLLER_RESPONSE = Struct("poller_response", UBInt8("version"), UBInt8("type"),
metadata_switch), ), ), Const(UBInt8("terminator"), 0x7f), ) # Build faces, used during dig and build. faces = { "noop": -1, "-y": 0, "+y": 1, "-z": 2, "+z": 3, "-x": 4, "+x": 5, } face = Enum(SBInt8("face"), **faces) packets = { 0: Struct("ping"), 1: Struct( "login", UBInt32("protocol"), AlphaString("username"), AlphaString("unused"), SBInt64("seed"), UBInt8("dimension"), ), 2: Struct(
def get_mds_parser(self): self.timestamp = Struct("utc_timestamp", SBInt32("day"), UBInt32("sec"), UBInt32("msec")) self.time_orbit = Struct( "time_orbit", self.timestamp, SBInt8("quality_indicator"), Padding(3), MicroDeg(SBInt32("latitude")), MicroDeg(SBInt32("longitude")), UBInt32("source_packet_counter"), UBInt32("instrument_mode_id"), BitStruct("measurement_confidence_data", Array(32, Bit("flag"))), MilliMeter(UBInt32("altitude")), Array(20, MilliMeter(SBInt16("18hz_altitude_differences"))), MilliMeter(SBInt16("instantaneous_altitude_rate")), Padding(50)) self.range_information = Struct( "range_information", Array(20, MilliMeter(UBInt32("18hz_tracker_range_no_doppler_ku"))), Padding(80), UBInt32("map_valid_points_tracker_ku"), Padding(4), MilliMeter(UBInt32("ocean_range_ku")), Padding(580), Array(20, TenMicroDeg(SBInt16("18hz_latitude_differences"))), Array(20, TenMicroDeg(SBInt16("18hz_longitude_differences")))) self.range_correction = Struct( "range_correction", Array(20, MilliMeter(SBInt16("18Hz_ku_range_instrumental"))), Padding(40), Array(20, MilliMeter(SBInt16("18Hz_ku_range_doppler"))), Padding(40), Array(20, MilliMeter(SBInt16("18Hz_ku_range_doppler_slope"))), Padding(40), MilliMeter(SBInt16("dry_troposphere")), MilliMeter(SBInt16("inverse_barometric")), MilliMeter(SBInt16("wet_troposphere_model")), MilliMeter(SBInt16("wet_troposphere_mwr")), MilliMeter(SBInt16("ra2_ionosphere_ku")), Padding(2), MilliMeter(SBInt16("doris_ionosphere_ku")), Padding(2), MilliMeter(SBInt16("model_ionosphere_ku")), Padding(2), MilliMeter(SBInt16("sea_state_bias_ku")), Padding(2), MilliMeter(SBInt16("dib_hf")), Padding(10)) self.significant_wave_height = Padding(268) self.backscatter = Struct( "backscatter", Padding(340), Array(20, OneHundredthDecibel(SBInt16("18hz_sea_ice_sigma_ku"))), Padding(40)) self.backscatter_correction = Padding(12) self.off_nadir_information = Padding(364) self.geophysical_information = Struct( "geophysical_information", MilliMeter(SBInt32("mean_sea_surface_height")), MilliMeter(SBInt32("geoid_height")), MilliMeter(SBInt32("ocean_depth_land_elevation")), MilliMeter(SBInt16("total_geocentric_ocean_tide_1")), MilliMeter(SBInt16("total_geocentric_ocean_tide_2")), MilliMeter(SBInt16("ocean_tide_long_period")), MilliMeter(SBInt16("ocean_loading_tide_2")), MilliMeter(SBInt16("solid_earth_tide")), MilliMeter(SBInt16("geocentric_polar_tide")), TenPascal(SBInt16("model_surface_atmospheric_pressure")), OneHundredth(SBInt16("mwr_water_vapour_content")), OneHundredth(SBInt16("mwr_liquid_water_content")), OneTenths(SBInt16("ra2_total_electron_content")), MilliMeter(SBInt16("ra2_wind_speed")), MilliMeter(SBInt16("model_wind_vector_u")), MilliMeter(SBInt16("model_wind_vector_v")), MilliMeter(SBInt16("ocean_loading_tide_1")), Padding(8)) self.mwr_information = Padding(10) self.flags = Struct("flag", UBInt16("average_ku_chirp_band"), Padding(112), UBInt16("altimeter_surface_type"), UBInt16("radiometer_land_ocean"), Padding(6), UBInt8("sea_ice"), Padding(5)) self.mds_record = Struct("mds_record", self.time_orbit, self.range_information, self.range_correction, self.significant_wave_height, self.backscatter, self.backscatter_correction, self.off_nadir_information, self.geophysical_information, self.mwr_information, self.flags) self.mds = Array(self.n_records, self.mds_record) return self.mds
from empower.core.module import Module from empower.core.module import ModuleLVAPPWorker from empower.main import RUNTIME PT_ADD_SUMMARY = 0x22 PT_SUMMARY = 0x23 PT_DEL_SUMMARY = 0x24 ADD_SUMMARY = Struct("add_summary", UBInt8("version"), UBInt8("type"), UBInt16("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("addrs", 6), Bytes("hwaddr", 6), UBInt8("channel"), UBInt8("band"), SBInt16("limit"), UBInt16("period")) SUMMARY_ENTRY = Sequence("frames", Bytes("addr", 6), UBInt64("tsft"), UBInt16("seq"), SBInt8("rssi"), UBInt8("rate"), UBInt8("type"), UBInt8("subtype"), UBInt32("length")) SUMMARY_TRIGGER = Struct("summary", UBInt8("version"), UBInt8("type"), UBInt16("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("wtp", 6), UBInt16("nb_entries"), Array(lambda ctx: ctx.nb_entries, SUMMARY_ENTRY)) DEL_SUMMARY = Struct("del_summary", UBInt8("version"), UBInt8("type"), UBInt16("length"), UBInt32("seq"), UBInt32("module_id")) class Summary(Module): """ Summary object. """
def get_mds_parser(self): self.timestamp = Struct("utc_timestamp", SBInt32("day"), UBInt32("sec"), UBInt32("msec")) self.time_orbit = Struct( "time_orbit", self.timestamp, SBInt8("quality_indicator"), Padding(3), MicroDeg(SBInt32("latitude")), MicroDeg(SBInt32("longitude")), UBInt32("source_packet_counter"), UBInt32("instrument_mode_id"), BitStruct("measurement_confidence_data", Array(32, Bit("flag"))), MilliMeter(UBInt32("altitude")), Array(20, MilliMeter(SBInt16("18hz_altitude_differences"))), MilliMeter(SBInt16("instantaneous_altitude_rate")), Padding(50)) self.range_information = Struct( "range_information", Array(20, MilliMeter(UBInt32("18hz_tracker_range_no_doppler_ku"))), Array(20, MilliMeter(UBInt32("18hz_tracker_range_no_doppler_s"))), UBInt32("map_valid_points_tracker_ku"), Padding(4), MilliMeter(UBInt32("ocean_range_ku")), MilliMeter(UBInt32("band_ocean_range_s")), Array(20, MilliMeter(UBInt32("18hz_ocean_range_ku"))), Array(20, MilliMeter(UBInt32("18hz_ocean_range_s"))), MilliMeter(UBInt16("sd_18hz_ocean_range_ku")), MilliMeter(UBInt16("sd_18hz_ocean_range_s")), UBInt16("18hz_n_valid_ocean_ku"), UBInt16("18hz_n_valid_ocean_s"), BitStruct("18hz_valid_points_ocean_ku", Array(32, Bit("flag"))), BitStruct("18hz_valid_points_ocean_s", Array(32, Bit("flag"))), Array(20, MilliMeter(UBInt32("18Hz_ice1_range_ku"))), Array(20, MilliMeter(UBInt32("18Hz_ice1_range_s"))), Array(20, MilliMeter(UBInt32("18Hz_ice2_range_ku"))), Array(20, MilliMeter(UBInt32("18Hz_ice2_range_s"))), Array(20, MilliMeter(UBInt32("18Hz_sea_ice_range_ku"))), Array(20, TenMicroDeg(SBInt16("18hz_latitude_differences"))), Array(20, TenMicroDeg(SBInt16("18hz_longitude_differences")))) self.range_correction = Struct( "range_correction", Array(20, MilliMeter(SBInt16("18Hz_ku_range_instrumental"))), Array(20, MilliMeter(SBInt16("18Hz_s_range_instrumental"))), Array(20, MilliMeter(SBInt16("18Hz_ku_range_doppler"))), Array(20, MilliMeter(SBInt16("18Hz_s_range_doppler"))), Array(20, MilliMeter(SBInt16("18Hz_ku_range_doppler_slope"))), Array(20, MilliMeter(SBInt16("18Hz_s_range_doppler_slope"))), MilliMeter(SBInt16("dry_troposphere")), MilliMeter(SBInt16("inverse_barometric")), MilliMeter(SBInt16("wet_troposphere_model")), MilliMeter(SBInt16("wet_troposphere_mwr")), MilliMeter(SBInt16("ra2_ionosphere_ku")), MilliMeter(SBInt16("ra2_ionosphere_s")), MilliMeter(SBInt16("doris_ionosphere_ku")), MilliMeter(SBInt16("doris_ionosphere_s")), MilliMeter(SBInt16("model_ionosphere_ku")), MilliMeter(SBInt16("model_ionosphere_s")), MilliMeter(SBInt16("sea_state_bias_ku")), MilliMeter(SBInt16("sea_state_bias_s")), MilliMeter(SBInt16("dib_hf")), Padding(10)) self.significant_wave_height = Struct( "significant_wave_height", MilliMeter(SBInt32("swh_square_ku")), MilliMeter(SBInt32("swh_square_s")), MilliMeter(SBInt16("swh_ku")), MilliMeter(SBInt16("swh_s")), MilliMeter(SBInt16("swh_sd_18hz_ku")), MilliMeter(SBInt16("swh_sd_18hz_s")), UBInt16("shw_18hz_n_valid_ku"), UBInt16("shw_18hz_n_valid_s"), BitStruct("slope_model_present", Array(32, Bit("flag"))), Centimeter(SBInt32("1hz_elevation_echo_point")), Array(20, Centimeter(SBInt16("18hz_elevation_difference"))), Array(20, TenMicroDeg(SBInt16("18hz_slope_latitude_diff"))), Array(20, TenMicroDeg(SBInt16("18hz_slope_longitude_diff"))), Array(20, MilliMeter(SBInt16("18hz_ice2_leading_edge_width_ku"))), Array(20, MilliMeter(SBInt16("18hz_ice2_leading_edge_width_s"))), Padding(40)) self.backscatter = Struct( "backscatter", Array(20, OneHundredthDecibel(SBInt16("18hz_ku_k_cal_ku"))), Array(20, OneHundredthDecibel(SBInt16("18hz_s_k_cal_s"))), BitStruct("map_valid_k_cal_ku", Array(32, Bit("flag"))), Padding(4), OneHundredthDecibel(SBInt16("ocean_sigma_corr_ku")), OneHundredthDecibel(SBInt16("ocean_sigma_corr_s")), OneHundredthDecibel(SBInt16("sd_18hz_ocean_sigma_ku")), OneHundredthDecibel(SBInt16("sd_18hz_ocean_sigma_s")), UBInt16("n_valid_18hz_ocean_sigma_ku"), UBInt16("n_valid_18hz_ocean_sigma_s"), Array(20, OneHundredthDecibel(SBInt16("18hz_ice1_sigma_ku"))), Array(20, OneHundredthDecibel(SBInt16("18hz_ice1_sigma_s"))), Array(20, OneHundredthDecibel(SBInt16("18hz_ice2_le_sigma_ku"))), Array(20, OneHundredthDecibel(SBInt16("18hz_ice2_le_sigma_s"))), Array(20, OneHundredthDecibel(SBInt16("18hz_ice2_sigma_ku"))), Array(20, OneHundredthDecibel(SBInt16("18hz_ice2_sigma_s"))), Array(20, OneHundredthDecibel(SBInt16("18hz_sea_ice_sigma_ku"))), Padding(40)) self.backscatter_correction = Struct( "backscatter_correction", OneHundredthDecibel(SBInt16("agc_net_instrumental_ku")), OneHundredthDecibel(SBInt16("agc_net_instrumental_s")), OneHundredthDecibel(SBInt16("atmospheric_attenuation_ku")), OneHundredthDecibel(SBInt16("atmospheric_attenuation_s")), OneHundredthDecibel(SBInt32("rain_attenuation_ku"))) self.off_nadir_information = Struct( "off_nadir_angle", TenThousands(SBInt16("square_angle_from_platform_data")), TenThousands(SBInt16("square_angle_from_waveform_data")), Array(20, SBInt32("slope_ice2_first_trailing_edge_ku")), Array(20, SBInt32("slope_ice2_first_trailing_edge_s")), Array(20, SBInt32("slope_ice2_second_trailing_edge_ku")), Array(20, SBInt32("slope_ice2_second_trailing_edge_s")), Padding(40)) self.geophysical_information = Struct( "geophysical_information", MilliMeter(SBInt32("mean_sea_surface_height")), MilliMeter(SBInt32("geoid_height")), MilliMeter(SBInt32("ocean_depth_land_elevation")), MilliMeter(SBInt16("total_geocentric_ocean_tide_1")), MilliMeter(SBInt16("total_geocentric_ocean_tide_2")), MilliMeter(SBInt16("ocean_tide_long_period")), MilliMeter(SBInt16("ocean_loading_tide_2")), MilliMeter(SBInt16("solid_earth_tide")), MilliMeter(SBInt16("geocentric_polar_tide")), TenPascal(SBInt16("model_surface_atmospheric_pressure")), OneHundredth(SBInt16("mwr_water_vapour_content")), OneHundredth(SBInt16("mwr_liquid_water_content")), OneTenths(SBInt16("ra2_total_electron_content")), MilliMeter(SBInt16("ra2_wind_speed")), MilliMeter(SBInt16("model_wind_vector_u")), MilliMeter(SBInt16("model_wind_vector_v")), MilliMeter(SBInt16("ocean_loading_tide_1")), Padding(8)) self.mwr_information = Struct( "mwr_information", OneHundredth(SBInt16("mwr_brightness_temp_23_8ghz")), OneHundredth(SBInt16("mwr_brightness_temp_36_5ghz")), OneHundredth(SBInt16("mwr_sd_brightness_temp_23_8ghz")), OneHundredth(SBInt16("mwr_sd_brightness_temp_36_5ghz")), Padding(2)) self.flags = Struct( "flag", UBInt16("average_ku_chirp_band"), BitStruct("ku_chirp_band_id", Array(64, Bit("flag"))), BitStruct("error_chirp_band_id", Array(32, Bit("flag"))), BitStruct("instrument", Array(32, Bit("flag"))), BitStruct("fault_identifier", Array(64, Bit("flag"))), Padding(8), BitStruct("waveform_fault_identifier", Array(64, Bit("flag"))), BitStruct("instrument_mode_id", Array(96, Bit("flag"))), UBInt16("n_measures_flight_calibration_s"), UBInt16("n_measures_flight_calibration_ku"), BitStruct("mwr_instrument_quality", Array(16, Bit("flag"))), Padding(6), Padding(8), Padding(8), BitStruct("ocean_retracking_quality_ku", Array(32, Bit("flag"))), BitStruct("ocean_retracking_quality_s", Array(32, Bit("flag"))), BitStruct("ice1_retracking_quality_ku", Array(32, Bit("flag"))), BitStruct("ice1_retracking_quality_s", Array(32, Bit("flag"))), BitStruct("ice2_retracking_quality_ku", Array(32, Bit("flag"))), BitStruct("ice2_retracking_quality_s", Array(32, Bit("flag"))), BitStruct("sea_ice_retracking_quality_ku", Array(32, Bit("flag"))), OneThousands(UBInt16("1hz_pulse_peakiness_ku")), OneThousands(UBInt16("1hz_pulse_peakiness_s")), UBInt16("altimeter_surface_type"), UBInt16("radiometer_land_ocean"), UBInt16("mwr_quality_interpolation"), UBInt16("altimeter_rain"), UBInt16("interpolation"), UBInt8("sea_ice"), BitStruct("membership_01", Array(8, Bit("flag"))), BitStruct("membership_02", Array(8, Bit("flag"))), BitStruct("membership_03", Array(8, Bit("flag"))), BitStruct("membership_04", Array(8, Bit("flag"))), Padding(1)) self.mds_record = Struct("mds_record", self.time_orbit, self.range_information, self.range_correction, self.significant_wave_height, self.backscatter, self.backscatter_correction, self.off_nadir_information, self.geophysical_information, self.mwr_information, self.flags) self.mds = Array(self.n_records, self.mds_record) return self.mds
Bytes("hwaddr", 6), UBInt8("channel"), UBInt8("band"), SBInt16("limit"), UBInt16("period")) SUMMARY_ENTRY = Sequence("frames", Bytes("ra", 6), Bytes("ta", 6), UBInt64("tsft"), BitStruct("flags", Padding(6), Bit("mcs"), Padding(9)), UBInt16("seq"), SBInt8("rssi"), UBInt8("rate"), UBInt8("type"), UBInt8("subtype"), UBInt32("length")) SUMMARY_TRIGGER = Struct("summary", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("wtp", 6), UBInt16("nb_entries"), Array(lambda ctx: ctx.nb_entries, SUMMARY_ENTRY)) DEL_SUMMARY = Struct("del_summary", UBInt8("version"),
R_EQ = 'EQ' R_GE = 'GE' R_LE = 'LE' RELATIONS = {R_EQ: 0, R_GT: 1, R_LT: 2, R_GE: 3, R_LE: 4} PT_ADD_RSSI = 0x19 PT_RSSI = 0x20 PT_DEL_RSSI = 0x21 ADD_RSSI_TRIGGER = Struct("add_rssi_trigger", UBInt8("version"), UBInt8("type"), UBInt16("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("addr", 6), Bytes("hwaddr", 6), UBInt8("channel"), UBInt8("band"), UBInt8("relation"), SBInt8("value")) RSSI_TRIGGER = Struct("rssi_trigger", UBInt8("version"), UBInt8("type"), UBInt16("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("wtp", 6), Bytes("addr", 6), UBInt8("relation"), SBInt8("value"), SBInt8("current")) DEL_RSSI_TRIGGER = Struct("del_rssi_trigger", UBInt8("version"), UBInt8("type"), UBInt16("length"), UBInt32("seq"), UBInt32("module_id")) class RSSI(Module): """ RSSI trigger object. """ MODULE_NAME = "rssi"
R_LE = 'LE' RELATIONS = {R_EQ: 0, R_GT: 1, R_LT: 2, R_GE: 3, R_LE: 4} PT_ADD_RSSI = 0x19 PT_RSSI = 0x20 PT_DEL_RSSI = 0x21 ADD_RSSI_TRIGGER = Struct("add_rssi_trigger", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("sta", 6), UBInt8("relation"), SBInt8("value"), UBInt16("period")) RSSI_TRIGGER = Struct("rssi_trigger", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("wtp", 6), Bytes("hwaddr", 6), UBInt8("channel"), UBInt8("band"), SBInt8("current")) DEL_RSSI_TRIGGER = Struct("del_rssi_trigger", UBInt8("version"), UBInt8("type"),
def _encode(self, obj, context): c = Container(data=[], terminator=None) for k, v in obj.iteritems(): t, value = v d = Container(id=Container(data_type=metadata_types.index(t), identifier=k), value=value, peeked=None) c.data.append(d) c.data[-1].peeked = 127 return c # Metadata inner container. metadata_switch = { 0: SBInt8("value"), 1: SBInt16("value"), 2: SBInt32("value"), 3: BFloat32("value"), 4: AlphaString("value"), 5: slotdata, 6: Struct( "int_tup", SBInt32("x"), SBInt32("y"), SBInt32("z"), ), } # Metadata subconstruct. entity_metadata = MetadataAdapter(
from empower.main import RUNTIME PT_ADD_SUMMARY = 0x23 PT_SUMMARY = 0x24 PT_DEL_SUMMARY = 0x25 ADD_SUMMARY = Struct("add_summary", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("addr", 6), Bytes("hwaddr", 6), UBInt8("channel"), UBInt8("band"), SBInt16("limit"), UBInt16("period")) SUMMARY_ENTRY = Sequence( "frames", Bytes("ra", 6), Bytes("ta", 6), UBInt64("tsft"), BitStruct("flags", Padding(6), Bit("mcs"), Padding(9)), UBInt16("seq"), SBInt8("rssi"), UBInt8("rate"), UBInt8("type"), UBInt8("subtype"), UBInt32("length")) SUMMARY_TRIGGER = Struct("summary", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("wtp", 6), UBInt16("nb_entries"), Array(lambda ctx: ctx.nb_entries, SUMMARY_ENTRY)) DEL_SUMMARY = Struct("del_summary", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id")) class Summary(ModuleScheduled): """ Summary object. """
), Const(UBInt8("terminator"), 0x7f), ), ) # Build faces, used during dig and build. faces = { "noop": -1, "-y": 0, "+y": 1, "-z": 2, "+z": 3, "-x": 4, "+x": 5, } face = Enum(SBInt8("face"), **faces) # World dimension. dimensions = { "earth": 0, "sky": 1, "nether": 255, } dimension = Enum(UBInt8("dimension"), **dimensions) # Difficulty levels difficulties = { "peaceful": 0, "easy": 1, "normal": 2, "hard": 3,
def make_packet(packet_id, **kwargs): payload = parsers[packet_id].build(Container(**kwargs)) return chr(packet_id) + payload parsers = { 0x01: Struct( 'login_request', SBInt32('protocol_version'), BetaString('username'), BetaString('not_used1'), SBInt32('not_used2'), SBInt32('not_used3'), SBInt8('not_used4'), UBInt8('not_used5'), UBInt8('not_used6'), ), 0x02: Struct('handshake', BetaString('username_and_host')), 0xFE: Struct('server_list_ping'), 0xFF: Struct('kick', BetaString('reason')), } class BetaProtocol(Protocol): def __init__(self): self.state = STATE_UNAUTHENTICATED
# Metadata subconstruct. metadata = StringAdapter(RepeatUntil(lambda obj, ctx: obj == "\x7f", Field("metadata", 1))) # Build faces, used during dig and build. faces = { "noop": -1, "-y": 0, "+y": 1, "-z": 2, "+z": 3, "-x": 4, "+x": 5, } face = Enum(SBInt8("face"), **faces) packets = { 0: Struct("ping"), 1: Struct("login", UBInt32("protocol"), AlphaString("username"), AlphaString("unused"), SBInt64("seed"), UBInt8("dimension"), ), 2: Struct("handshake", AlphaString("username"), ), 3: Struct("chat", AlphaString("message"),
R_LT = 'LT' R_EQ = 'EQ' R_GE = 'GE' R_LE = 'LE' RELATIONS = {R_EQ: 0, R_GT: 1, R_LT: 2, R_GE: 3, R_LE: 4} PT_ADD_RSSI = 0x20 PT_RSSI = 0x21 PT_DEL_RSSI = 0x22 ADD_RSSI_TRIGGER = Struct("add_rssi_trigger", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("sta", 6), UBInt8("relation"), SBInt8("value"), UBInt16("period")) RSSI_TRIGGER = Struct("rssi_trigger", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("wtp", 6), Bytes("hwaddr", 6), UBInt8("channel"), UBInt8("band"), SBInt8("current")) DEL_RSSI_TRIGGER = Struct("del_rssi_trigger", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id")) class RSSI(ModuleTrigger): """ RSSI trigger object. """ MODULE_NAME = "rssi"