示例#1
0
 def test_from_hex(self):
     profile = Sigfox("UPLINK", "ACK ON ERROR", 1)
     h = "0f08000000000000"
     ack = ACK.parse_from_hex(profile, h)
     self.assertEqual(
         ack.to_string(),
         "0000111100001000000000000000000000000000000000000000000000000000")
     self.assertEqual(ack.rule_id, "00")
     self.assertEqual(ack.dtag, "0")
     self.assertEqual(ack.w, "01")
     self.assertEqual(ack.c, "1")
     self.assertEqual(ack.bitmap, "1100001")
     self.assertTrue(is_monochar(ack.padding) and ack.padding[0] == '0')
示例#2
0
    def is_receiver_abort(self):
        ack_string = self.to_string()
        l2_word_size = self.profile.L2_WORD_SIZE
        header = ack_string[:len(self.rule_id + self.dtag + self.w + self.c)]
        padding = ack_string[len(self.rule_id + self.dtag + self.w + self.c):ack_string.rfind('1') + 1]
        padding_start = padding[:-l2_word_size]
        padding_end = padding[-l2_word_size:]

        if padding_end == "1" * l2_word_size:
            if padding_start != '' and len(header) % l2_word_size != 0:
                return is_monochar(padding_start) and padding_start[0] == '1'
            else:
                return len(header) % l2_word_size == 0
        else:
            return False
示例#3
0
 def is_sender_abort(self):
     fcn = self.header.FCN
     padding = self.payload.decode()
     # return fcn[0] == '1' and is_monochar(fcn) and '1' not in padding
     return fcn[0] == '1' and is_monochar(fcn) and padding[0] == '0' and is_monochar(padding)
示例#4
0
 def is_all_0(self):
     fcn = self.header.FCN
     return fcn[0] == '0' and is_monochar(fcn)
示例#5
0
 def is_all_1(self):
     fcn = self.header.FCN
     payload = self.payload.decode()
     return fcn[0] == '1' and is_monochar(fcn) and not (payload[0] == '0' and is_monochar(payload))