def send_command_ack(self, device_id, action):
        """Send command, wait for gateway to repond with acknowledgment."""
        # serialize commands
        yield from self._ready_to_send.acquire()
        acknowledgement = None
        try:
            self._command_ack.clear()
            self.send_command(device_id, action)

            log.debug('waiting for acknowledgement')
            try:
                yield from asyncio.wait_for(self._command_ack.wait(),
                                            TIMEOUT.seconds, loop=self.loop)
                log.debug('packet acknowledged')
            except concurrent.futures._base.TimeoutError:
                acknowledgement = {'ok': False, 'message': 'timeout'}
                log.warning('acknowledge timeout')
            else:
                acknowledgement = self._last_ack.get('ok', False)
        finally:
            # allow next command
            self._ready_to_send.release()

        return acknowledgement
def send_command_ack ( self , device_id , action ) : yield from self . _ready_to_send . acquire ( ) acknowledgement = None try : self . _command_ack . clear ( ) self . send_command ( device_id , action ) log . debug ( 'waiting for acknowledgement' ) try : yield from asyncio . wait_for ( self . _command_ack . wait ( ) , TIMEOUT . seconds , loop = self . loop ) log . debug ( 'packet acknowledged' ) except concurrent . futures . _base . TimeoutError : acknowledgement = { 'ok' : False , 'message' : 'timeout' } log . warning ( 'acknowledge timeout' ) else : acknowledgement = self . _last_ack . get ( 'ok' , False ) finally : self . _ready_to_send . release ( ) return acknowledgement
Send command, wait for gateway to repond with acknowledgment.