Beispiel #1
0
  def __init__(self):
    self.argparser = argparse.ArgumentParser(
      fromfile_prefix_chars="@",
      description="Test throughput over 2 serial D7 modems"
    )

    self.argparser.add_argument("-n", "--msg-count", help="number of messages to transmit", type=int, default=10)
    self.argparser.add_argument("-p", "--payload-size", help="number of bytes of (appl level) payload to transmit", type=int, default=50)
    self.argparser.add_argument("-sw", "--serial-transmitter", help="serial device /dev file transmitter node", default=None)
    self.argparser.add_argument("-sr", "--serial-receiver", help="serial device /dev file receiver node", default=None)
    self.argparser.add_argument("-r", "--rate", help="baudrate for serial device", type=int, default=115200)
    self.argparser.add_argument("-uid", "--unicast-uid", help="UID to use for unicast transmission, "
                                                              "when not using receiver "
                                                              "(in hexstring, for example 0xb57000009151d)", default=None)
    self.argparser.add_argument("-to", "--receiver-timeout", help="timeout for the receiver (in seconds)", type=int, default=10)
    self.argparser.add_argument("-v", "--verbose", help="verbose", default=False, action="store_true")
    self.config = self.argparser.parse_args()

    configure_default_logger(self.config.verbose)

    if self.config.serial_transmitter == None and self.config.serial_receiver == None:
      self.argparser.error("At least a transmitter or receiver is required.")

    if self.config.serial_receiver == None and self.config.unicast_uid == None:
      self.argparser.error("When running without receiver a --unicast-uid parameter is required.")

    if self.config.serial_transmitter == None:
      self.transmitter_modem = None
      print("Running without transmitter")
    else:
      self.transmitter_modem = Modem(self.config.serial_transmitter, self.config.rate, None)
      access_profile = AccessProfile(
        channel_header=ChannelHeader(channel_band=ChannelBand.BAND_868,
                                     channel_coding=ChannelCoding.PN9,
                                     channel_class=ChannelClass.NORMAL_RATE),
        sub_profiles=[SubProfile(subband_bitmap=0x01, scan_automation_period=CT(exp=0, mant=0)), SubProfile(), SubProfile(), SubProfile()],
        sub_bands=[SubBand(
          channel_index_start=0,
          channel_index_end=0,
          eirp=10,
          cca=86 # TODO
        )]
      )

      print("Write Access Profile")
      write_ap_cmd = Command.create_with_write_file_action_system_file(file=AccessProfileFile(access_profile=access_profile, access_specifier=0))
      self.transmitter_modem.execute_command(write_ap_cmd, timeout_seconds=1)

    if self.config.serial_receiver == None:
      self.receiver_modem = None
      print("Running without receiver")
    else:
      self.receiver_modem = Modem(self.config.serial_receiver, self.config.rate, self.receiver_cmd_callback)
      self.receiver_modem.execute_command(Command.create_with_write_file_action_system_file(DllConfigFile(active_access_class=0x01)), timeout_seconds=1)
      print("Receiver scanning on Access Class = 0x01")
Beispiel #2
0
 def test_default_constructor(self):
     f = AccessProfileFile()
     self.assertEqual(f.access_specifier, 0)
     self.assertEqual(f.access_profile, None)
Beispiel #3
0
 def bad():
     AccessProfileFile(access_specifier=21)  # can be max 14
class SystemFiles:
    files = {
        SystemFileIds.UID: UidFile(),
        SystemFileIds.FIRMWARE_VERSION: FirmwareVersionFile(),
        SystemFileIds.DLL_CONFIG: DllConfigFile(),
        SystemFileIds.ACCESS_PROFILE_0: AccessProfileFile(access_specifier=0),
        SystemFileIds.ACCESS_PROFILE_1: AccessProfileFile(access_specifier=1),
        SystemFileIds.ACCESS_PROFILE_2: AccessProfileFile(access_specifier=2),
        SystemFileIds.ACCESS_PROFILE_3: AccessProfileFile(access_specifier=3),
        SystemFileIds.ACCESS_PROFILE_4: AccessProfileFile(access_specifier=4),
        SystemFileIds.ACCESS_PROFILE_5: AccessProfileFile(access_specifier=5),
        SystemFileIds.ACCESS_PROFILE_6: AccessProfileFile(access_specifier=6),
        SystemFileIds.ACCESS_PROFILE_7: AccessProfileFile(access_specifier=7),
        SystemFileIds.ACCESS_PROFILE_8: AccessProfileFile(access_specifier=8),
        SystemFileIds.ACCESS_PROFILE_9: AccessProfileFile(access_specifier=9),
        SystemFileIds.ACCESS_PROFILE_10:
        AccessProfileFile(access_specifier=10),
        SystemFileIds.ACCESS_PROFILE_11:
        AccessProfileFile(access_specifier=11),
        SystemFileIds.ACCESS_PROFILE_12:
        AccessProfileFile(access_specifier=12),
        SystemFileIds.ACCESS_PROFILE_13:
        AccessProfileFile(access_specifier=13),
        SystemFileIds.ACCESS_PROFILE_14:
        AccessProfileFile(access_specifier=14),
    }

    def get_all_system_files(self):
        return sorted(self.files, key=lambda t: t.value)
Beispiel #5
0
class SystemFiles:
    files = {
        SystemFileIds.UID:
        UidFile(),
        SystemFileIds.FACTORY_SETTINGS:
        FactorySettingsFile(),
        SystemFileIds.FIRMWARE_VERSION:
        FirmwareVersionFile(),
        SystemFileIds.DEVICE_CAPACITY:
        NotImplementedFile(SystemFileIds.DEVICE_CAPACITY.value, 19),
        SystemFileIds.DEVICE_STATUS:
        NotImplementedFile(SystemFileIds.DEVICE_STATUS, 9),
        SystemFileIds.ENGINEERING_MODE:
        EngineeringModeFile(),
        SystemFileIds.VID:
        VidFile(),
        SystemFileIds.RFU_07:
        NotImplementedFile(SystemFileIds.RFU_07, 0),
        SystemFileIds.PHY_CONFIG:
        NotImplementedFile(SystemFileIds.PHY_CONFIG, 9),
        SystemFileIds.PHY_STATUS:
        NotImplementedFile(SystemFileIds.PHY_STATUS,
                           24),  # TODO assuming 3 channels for now
        SystemFileIds.DLL_CONFIG:
        DllConfigFile(),
        SystemFileIds.DLL_STATUS:
        NotImplementedFile(SystemFileIds.DLL_STATUS, 12),
        SystemFileIds.NWL_ROUTING:
        NotImplementedFile(SystemFileIds.NWL_ROUTING,
                           1),  # TODO variable routing table
        SystemFileIds.NWL_SECURITY:
        NotImplementedFile(SystemFileIds.NWL_SECURITY, 5),
        SystemFileIds.NWL_SECURITY_KEY:
        SecurityKeyFile(),
        SystemFileIds.NWL_SSR:
        NotImplementedFile(SystemFileIds.NWL_SSR,
                           4),  # TODO 0 recorded devices
        SystemFileIds.NWL_STATUS:
        NotImplementedFile(SystemFileIds.NWL_STATUS, 20),
        SystemFileIds.TRL_STATUS:
        NotImplementedFile(SystemFileIds.TRL_STATUS, 1),  # TODO 0 TRL records
        SystemFileIds.SEL_CONFIG:
        NotImplementedFile(SystemFileIds.SEL_CONFIG, 6),
        SystemFileIds.FOF_STATUS:
        NotImplementedFile(SystemFileIds.FOF_STATUS, 10),
        SystemFileIds.RFU_14:
        NotImplementedFile(SystemFileIds.RFU_14, 0),
        SystemFileIds.RFU_15:
        NotImplementedFile(SystemFileIds.RFU_15, 0),
        SystemFileIds.RFU_16:
        NotImplementedFile(SystemFileIds.RFU_16, 0),
        SystemFileIds.LOCATION_DATA:
        NotImplementedFile(SystemFileIds.LOCATION_DATA,
                           1),  # TODO 0 recorded locations
        SystemFileIds.D7AALP_RFU_18:
        NotImplementedFile(SystemFileIds.D7AALP_RFU_18, 0),
        SystemFileIds.D7AALP_RFU_19:
        NotImplementedFile(SystemFileIds.D7AALP_RFU_19, 0),
        SystemFileIds.D7AALP_RFU_1A:
        NotImplementedFile(SystemFileIds.D7AALP_RFU_1A, 0),
        SystemFileIds.D7AALP_RFU_1B:
        NotImplementedFile(SystemFileIds.D7AALP_RFU_1B, 0),
        SystemFileIds.D7AALP_RFU_1C:
        NotImplementedFile(SystemFileIds.D7AALP_RFU_1C, 0),
        SystemFileIds.D7AALP_RFU_1D:
        NotImplementedFile(SystemFileIds.D7AALP_RFU_1D, 0),
        SystemFileIds.D7AALP_RFU_1E:
        NotImplementedFile(SystemFileIds.D7AALP_RFU_1E, 0),
        SystemFileIds.D7AALP_RFU_1F:
        NotImplementedFile(SystemFileIds.D7AALP_RFU_1F, 0),
        SystemFileIds.ACCESS_PROFILE_0:
        AccessProfileFile(access_specifier=0),
        SystemFileIds.ACCESS_PROFILE_1:
        AccessProfileFile(access_specifier=1),
        SystemFileIds.ACCESS_PROFILE_2:
        AccessProfileFile(access_specifier=2),
        SystemFileIds.ACCESS_PROFILE_3:
        AccessProfileFile(access_specifier=3),
        SystemFileIds.ACCESS_PROFILE_4:
        AccessProfileFile(access_specifier=4),
        SystemFileIds.ACCESS_PROFILE_5:
        AccessProfileFile(access_specifier=5),
        SystemFileIds.ACCESS_PROFILE_6:
        AccessProfileFile(access_specifier=6),
        SystemFileIds.ACCESS_PROFILE_7:
        AccessProfileFile(access_specifier=7),
        SystemFileIds.ACCESS_PROFILE_8:
        AccessProfileFile(access_specifier=8),
        SystemFileIds.ACCESS_PROFILE_9:
        AccessProfileFile(access_specifier=9),
        SystemFileIds.ACCESS_PROFILE_10:
        AccessProfileFile(access_specifier=10),
        SystemFileIds.ACCESS_PROFILE_11:
        AccessProfileFile(access_specifier=11),
        SystemFileIds.ACCESS_PROFILE_12:
        AccessProfileFile(access_specifier=12),
        SystemFileIds.ACCESS_PROFILE_13:
        AccessProfileFile(access_specifier=13),
        SystemFileIds.ACCESS_PROFILE_14:
        AccessProfileFile(access_specifier=14)
    }

    def get_all_system_files(self):
        return sorted(self.files, key=lambda t: t.value)
argparser.add_argument("-e", "--eirp", help="EIRP in dBm", type=int, default=14)
argparser.add_argument("-s", "--specifier", help="specifier for access profile. Default 0 is continuous scan, 1 is bg scan, 2+ is no scan", type=int, default=0)
argparser.add_argument("-sp", "--scan_automation_period", help="period in ms of scanning (786 ~ total 1 sec), 0 is continuous scan ", type=int, default=0)
argparser.add_argument("-sb", "--subband_bitmap", help="subband bitmap of subprofiles, 0 is default, 1 is scanning", type=int, default=0)
config = argparser.parse_args()
configure_default_logger(config.verbose)

ch = ChannelID.from_string(config.channel_id)

modem = Modem(config.device, config.rate, unsolicited_response_received_callback=received_command_callback)
modem.connect()

channel_header = ChannelHeader(
  channel_class=ch.channel_header.channel_class,
  channel_coding=ch.channel_header.channel_coding,
  channel_band=ch.channel_header.channel_band
)

access_profile = AccessProfile(
  channel_header=channel_header,
  sub_profiles=[SubProfile(subband_bitmap=config.subband_bitmap, scan_automation_period=CT.compress(config.scan_automation_period))] * 4,
  sub_bands=[SubBand(eirp=config.eirp, channel_index_start=ch.channel_index, channel_index_end=ch.channel_index)] * 8
)

modem.execute_command(
  alp_command=Command.create_with_write_file_action_system_file(
    file=AccessProfileFile(access_profile=access_profile, access_specifier=config.specifier)
  )
)