예제 #1
0
    def test_encoding_7_bit_header(self):
        from smspdu.pdu import pack7bit
        input = b'abcd'
        # a = 0b1100001
        # b = 0b1100010
        # c = 0b1100011
        # d = 0b1100100
        # packed is     01100001 11110001 10011000 00001100
        output_bytes = [0x61, 0xf1, 0x98, 0x0c]
        output = bytes(output_bytes)
        self.assertEqual(pack7bit(input)[1], output)

        # packed is     01000000 01011000 00111100 00100110 00000011

        output_bytes = [0x40, 0x58, 0x3c, 0x26, 0x03]
        output = bytes(output_bytes)
        self.assertEqual(pack7bit(input, 1)[1], output)
예제 #2
0
파일: test_sms.py 프로젝트: SciF0r/smspdu
    def test_encoding_7_bit_header(self):
        from smspdu.pdu import pack7bit
        input = 'abcd'
        # a = 0b1100001
        # b = 0b1100010
        # c = 0b1100011
        # d = 0b1100100
        # packed is     01100001 11110001 10011000 00001100
        output_bytes = [0x61,    0xf1,    0x98,    0x0c]
        output = ''.join(chr(x) for x in output_bytes)
        self.assertEquals(pack7bit(input)[1], output)

        # packed is     01000000 01011000 00111100 00100110 00000011

        output_bytes = [0x40,    0x58,    0x3c,    0x26,    0x03]
        output = ''.join(chr(x) for x in output_bytes)
        self.assertEquals(pack7bit(input, 1)[1], output)
예제 #3
0
파일: test_sms.py 프로젝트: SciF0r/smspdu
    def test_encoding_7_bit(self):
        from smspdu.pdu import pack7bit
        input = 'hellohello'
        # h = 0b1101000
        # e = 0b1100101
        # l = 0b1101100
        # o = 0b1101111
        # packed is    11101000 00110010 10011011 1111101 110

        # packed is    11101000 00110010 10011011 11111101 01000110 
        output_bytes =[0xE8,    0x32,    0x9B,    0xFD,    0x46,    0x97, 0xD9, 0xEC, 0x37]
        output = ''.join(chr(x) for x in output_bytes)
        self.assertEquals(pack7bit(input)[1], output)
예제 #4
0
    def test_encoding_7_bit(self):
        from smspdu.pdu import pack7bit
        input = b'hellohello'
        # h = 0b1101000
        # e = 0b1100101
        # l = 0b1101100
        # o = 0b1101111
        # packed is    11101000 00110010 10011011 1111101 110

        # packed is    11101000 00110010 10011011 11111101 01000110
        output_bytes = [0xE8, 0x32, 0x9B, 0xFD, 0x46, 0x97, 0xD9, 0xEC, 0x37]
        output = bytes(output_bytes)
        self.assertEqual(pack7bit(input)[1], output)
예제 #5
0
def check_o2_balance():
    """Check o2 balance"""
    ser = serial.Serial(find_device())
    code = "*#10#"
    data="AT+CUSD=1,%s,15" % pdu.pack7bit(code)[1].encode('hex').upper()
    ser.write(data + "\r")
    start = int(os.times()[4])
    while start + 10 > int(os.times()[4]):
        line = ser.readline().replace('"',"")
        if "+CUSD:" in line:
            response = line.split(",")[1]
            result = gsm0338().decode(pdu.unpack7bit(response.decode('hex')))[0]
            result = result[:-1].replace(u'Your balance is \xa3','')
            logging.debug("Balance is %s" %result)
            return float(result)
    return -1
예제 #6
0
def check_o2_balance():
    """Check o2 balance"""
    ser = serial.Serial(find_device())
    code = "*#10#"
    data = "AT+CUSD=1,%s,15" % pdu.pack7bit(code)[1].encode('hex').upper()
    ser.write(data + "\r")
    start = int(os.times()[4])
    while start + 10 > int(os.times()[4]):
        line = ser.readline().replace('"', "")
        if "+CUSD:" in line:
            response = line.split(",")[1]
            result = gsm0338().decode(pdu.unpack7bit(
                response.decode('hex')))[0]
            result = result[:-1].replace(u'Your balance is \xa3', '')
            logging.debug("Balance is %s" % result)
            return float(result)
    return -1
예제 #7
0
파일: test_sms.py 프로젝트: SciF0r/smspdu
 def test_textAddress(self):
     from smspdu.pdu import pack7bit
     self.assertEquals(smspdu.SMS_SUBMIT.determineAddress('1test'),
         (10, 0xd0, pack7bit('1test')[1]))
예제 #8
0
 def test_textAddress(self):
     from smspdu.pdu import pack7bit
     self.assertEqual(smspdu.SMS_SUBMIT.determineAddress('1test'),
                      (10, 0xd0, pack7bit(b'1test')[1]))