示例#1
0
import sys
import pynvc

def testWuClass(destination):

  pynvc.sendcmd(destination, pynvc.WKPF_GET_WUCLASS_LIST, [0x05, 0x05]);
  print "--- Sent get"
  src, reply = pynvc.checkedReceive([pynvc.WKPF_GET_WUCLASS_LIST_R], 5000) # Receive reply: should be a WKPF_GET_WUCLASS_LIST_R
  print "--- Received reply"
  print "Reply:", [chr(c) for c in reply[1:]] 

	#wuclass:00~02,property:00~01
	#seq=05 05, wuclassID=00 02, roleID=a1, propertyID=01, value=aabbccdd
  pynvc.sendcmd(destination, pynvc.WKPF_WRITE_PROPERTY, [0x05, 0x05, 0x00, 0x02, 0xa1, 0x01, 0xaa, 0xbb, 0xcc, 0xdd]);
  print "--- Sent write"
  src, reply = pynvc.checkedReceive([pynvc.WKPF_WRITE_PROPERTY_R], 5000) # Receive reply: should be a WKPF_WRITE_PROPERTY
  print "--- Received reply"
  print "Reply:", [chr(c) for c in reply[1:]] 


  pynvc.sendcmd(destination, pynvc.WKPF_READ_PROPERTY, [0x05, 0x05, 0x00, 0x02, 0xa1, 0x00]);
  print "--- Sent read"
  src, reply = pynvc.checkedReceive([pynvc.WKPF_READ_PROPERTY_R], 5000) # Receive reply: should be a WKPF_READ_PROPERTY_R
  print "--- Received reply"
  print "Reply:", [chr(c) for c in reply[1:]] 



pynvc.init(0)
testWuClass(int(sys.argv[1]))
示例#2
0
#!/usr/bin/python

import sys
import pynvc



def testRot13(destination, input):
  print "--- Input: ", input
  pynvc.sendcmd(destination, pynvc.APPMSG, [ord(c) for c in input])
  print "--- Sent"
  src, reply = pynvc.receive(5000) # Receive reply
  print "--- Received reply"
  pynvc.sendcmd(destination, pynvc.APPMSG_R, [pynvc.APPMSG_STATUS_ACK])
  print "Reply:", [chr(c) for c in reply[1:]] # Strip of the leading 0x7e (APPMSG) command

pynvc.init()
testRot13(int(sys.argv[1]), sys.argv[2] if len(sys.argv)>2 else "Hallo")
示例#3
0
                        command=pynvc.REPRG_COMMIT,
                        allowedReplies=[pynvc.REPRG_COMMIT_R_RETRANSMIT,
                                        pynvc.REPRG_COMMIT_R_FAILED,
                                        pynvc.REPRG_COMMIT_R_OK],
                        payload=[pos/256, pos%256])
      if reply[0] == pynvc.REPRG_COMMIT_R_OK:
        print reply
        print "Commit OK."
      elif reply[0] == pynvc.REPRG_COMMIT_R_RETRANSMIT:
        pos = reply[1]*256 + reply[2]
        print "===========>Received REPRG_COMMIT_R_RETRANSMIT request to retransmit from ", pos
      else:
        print "Commit failed."
        return False
  src, reply = pynvc.sendWithRetryAndCheckedReceive(destination=destination,
                                                    command=pynvc.SETRUNLVL,
                                                    allowedReplies=[pynvc.SETRUNLVL_R],
                                                    payload=[pynvc.RUNLVL_RESET])
  if reply == None:
    print "Going to runlevel reset failed. :-("
    return False;
  else:
    return True;

if __name__ == "__main__":
  pynvc.init(0) # 0: zwave, 1: zigbee
  if not reprogramNvmdefault(int(sys.argv[1]), sys.argv[2]):
    print "Retrying after 5 seconds..."
    time.sleep(5)
    reprogramNvmdefault(int(sys.argv[1]), sys.argv[2])