NFC: Workaround nfcpy message debug exception

The current nfcpy version does not support new WSC connection handover
message format and the handover server fails to process the request due
to a debug print. As a temporary workaround, override
HandoverServer::_process_request() with a version that avoids pretty()
print of the handover messages. This can be removed once nfcpy has been
updated to support the new format.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2014-02-13 16:14:04 +02:00 committed by Jouni Malinen
parent 6ceb95c950
commit 7ae7a84eef
3 changed files with 51 additions and 0 deletions

View file

@ -113,6 +113,23 @@ class HandoverServer(nfc.handover.HandoverServer):
self.ho_server_processing = False self.ho_server_processing = False
self.success = False self.success = False
# override to avoid parser error in request/response.pretty() in nfcpy
# due to new WSC handover format
def _process_request(self, request):
summary("received handover request {}".format(request.type))
response = nfc.ndef.Message("\xd1\x02\x01Hs\x12")
if not request.type == 'urn:nfc:wkt:Hr':
summary("not a handover request")
else:
try:
request = nfc.ndef.HandoverRequestMessage(request)
except nfc.ndef.DecodeError as e:
summary("error decoding 'Hr' message: {}".format(e))
else:
response = self.process_request(request)
summary("send handover response {}".format(response.type))
return response
def process_request(self, request): def process_request(self, request):
summary("HandoverServer - request received") summary("HandoverServer - request received")
try: try:

View file

@ -263,6 +263,23 @@ class HandoverServer(nfc.handover.HandoverServer):
self.ho_server_processing = False self.ho_server_processing = False
self.success = False self.success = False
# override to avoid parser error in request/response.pretty() in nfcpy
# due to new WSC handover format
def _process_request(self, request):
summary("received handover request {}".format(request.type))
response = nfc.ndef.Message("\xd1\x02\x01Hs\x12")
if not request.type == 'urn:nfc:wkt:Hr':
summary("not a handover request")
else:
try:
request = nfc.ndef.HandoverRequestMessage(request)
except nfc.ndef.DecodeError as e:
summary("error decoding 'Hr' message: {}".format(e))
else:
response = self.process_request(request)
summary("send handover response {}".format(response.type))
return response
def process_request(self, request): def process_request(self, request):
self.ho_server_processing = True self.ho_server_processing = True
clear_raw_mode() clear_raw_mode()

View file

@ -142,6 +142,23 @@ class HandoverServer(nfc.handover.HandoverServer):
self.ho_server_processing = False self.ho_server_processing = False
self.success = False self.success = False
# override to avoid parser error in request/response.pretty() in nfcpy
# due to new WSC handover format
def _process_request(self, request):
summary("received handover request {}".format(request.type))
response = nfc.ndef.Message("\xd1\x02\x01Hs\x12")
if not request.type == 'urn:nfc:wkt:Hr':
summary("not a handover request")
else:
try:
request = nfc.ndef.HandoverRequestMessage(request)
except nfc.ndef.DecodeError as e:
summary("error decoding 'Hr' message: {}".format(e))
else:
response = self.process_request(request)
summary("send handover response {}".format(response.type))
return response
def process_request(self, request): def process_request(self, request):
self.ho_server_processing = True self.ho_server_processing = True
summary("HandoverServer - request received") summary("HandoverServer - request received")