Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

First voice command #49

Open
ABotelho23 opened this issue Mar 30, 2018 · 0 comments
Open

First voice command #49

ABotelho23 opened this issue Mar 30, 2018 · 0 comments

Comments

@ABotelho23
Copy link
Owner

ABotelho23 commented Mar 30, 2018

async def createRequest(request_type, node_address, node_resource, userPayload):
    
	protocol = await Context.create_client_context()
	
	if (request_type == 'GET'):
        print("SENDING GET REQUEST")
        targetURI = 'coap://' + node_address + node_resource

        request = Message(code=GET, uri=targetURI)

        try:
            response = await protocol.request(request).response
        except Exception as e:
            return e
        else:
            return response.payload
    else:
        print("SENDING PUT REQUEST START")
        targetURI = 'coap://' + node_address + node_resource
        payloadEnc = userPayload.encode()
        
		request = Message(code=PUT, uri=targetURI, payload=payloadEnc)

        try:
            response = await protocol.request(request).response
        except Exception as e:
            return e
        else:
            return response.payload
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant