void PortBIntHandler (void)	// Interrupt handler called upon IR receive
{
	// Reset delay counter
	waitTime=0;		

	// Turn on Status light upon first IR receive
	GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_0,0x01);	
	
	// skip repeating IR pulse sequences
	if(!checkProtocol())							
		return;
		
	// 2 second delay between button presses	
	if(waitTime2 < 20000)							
	{
		flag = 1;
	}
	else
	{
		flag = 0;
	}
			
	// parse IR pulse sequence data
	getData();
	
	// concatenate corresponding character to display buffer
	decodeLetter(decode(string));

	
	// clear interrupt
	GPIOPinIntClear(GPIO_PORTB_BASE, GPIO_PIN_1);
	
	// reset delay between button presses
	waitTime2=0;
}
Exemple #2
0
BOOL metaCheckProtocol(char *szProto, MCONTACT hContact, WORD eventType)
{
	MCONTACT hSubContact=NULL;

	if (bMetaProtoEnabled && szProto && !strcmp(META_PROTO, szProto))
		if (hSubContact = db_mc_getMostOnline(hContact))
			szProto = GetContactProto(hSubContact);

	return checkProtocol(szProto) && checkIgnore(hSubContact?hSubContact:hContact, eventType);
}
Exemple #3
0
bool SceneDeserializer::run(QJsonObject in, Graph* graph, Info* info)
{
    if (!checkType(in, info))
        return false;

    if (!checkProtocol(in, info))
        return false;

    // Make sure there's a "nodes" array
    if (in.find("nodes") == in.end() || !in["nodes"].isArray())
    {
        if (info)
            info->error_message = "File does not contain any nodes.";
        return false;
    }

    deserializeGraph(in["nodes"].toArray(), graph, info);
    return true;
}
void PortBIntHandler (void) // Interrupt handler called upon IR receive
{
		char str[10];
	
    // Reset delay counter
    waitTime=0;     

    
    // skip repeating IR pulse sequences
    if(!checkProtocol())
		{	
			GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_0,0x00);
			GPIOPinIntClear(GPIO_PORTB_BASE, GPIO_PIN_1);
				//displayAccel();
        return;
		}
    // 2 second delay between button presses    
    if(waitTime2 < 20000)                           
    {
        flag = 1;
    }
    else
    {
        flag = 0;
    }
            
    // parse IR pulse sequence data
    getData();
    
		
    // concatenate corresponding character to display buffer
    decodeLetter(decode(string));
		RIT128x96x4StringDraw(display2, 0, 80, 15);
    
    GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_0,0x01);
  
    // reset delay between button presses
    waitTime2=0;
		GPIOPinIntClear(GPIO_PORTB_BASE, GPIO_PIN_1);
		//displayAccel();
}
// Interrupt handler called upon IR receive
void PortBIntHandler (void)	
{
	
	unsigned long ulStatus;
	// Reset delay counter
	waitTime=0;		
	
	// skip repeating IR pulse sequences
	if(!checkProtocol())							
		return;
		
	// 2 second delay between button presses	
	if(waitTime2 < 20000)							
	{
		flag = 1;
	}
	else
	{
		flag = 0;
	}
	
	
	// parse IR pulse sequence data
	getData();
	
	// concatenate corresponding character to display buffer
	decodeLetter(decode(string));

	
	// clear interrupt
	GPIOPinIntClear(GPIO_PORTB_BASE, GPIO_PIN_1);
     ulStatus = UARTIntStatus(UART0_BASE, true);
    UARTIntClear(UART0_BASE, ulStatus);
	
	// reset delay between button presses
	waitTime2=0;
}
Exemple #6
0
//NOTE: UDP will drop anything that does not fit in the buffer size! so the buffer size must be the maximum
//possible size that this program will send a packet!
void UDP_Socket::receivePackets()
{
	int i = 0;
	while (true)
	{
		int protocolHandler = 0;
#if PLATFORM == WINDOWS
		int receiveLength = sizeof(receive);
#else
		unsigned int receiveLength = sizeof(receive);
#endif
		int bytes = recvfrom(socketHandle, messageBuffer, MAX_PACKET_SIZE, 0, (sockaddr*)&receive, &receiveLength);
		if (bytes <= 0 || (protocolHandler = checkProtocol()) == 0)
			break;
		messageBuffer[bytes] = '\0';
		sendACK();
		//TODO: Save these!
		unsigned int receiveAddress = ntohl(receive.sin_addr.s_addr);
		unsigned int receivePort = ntohs(receive.sin_port);
		parseMessages(messageBuffer, i, bytes);
		i++;
	}
	sortMessageBuffer();
}
bool
Handler::process (const Json::Value &msg, Json::Value &_response)
{
  Json::Value error;
  std::string methodName;

  if (!checkProtocol (msg, error) ) {
    _response = error;
    return false;
  }

  _response[JSON_RPC_ID] = msg.isMember (JSON_RPC_ID) ? msg[JSON_RPC_ID] :
                           Json::Value::null;
  _response[JSON_RPC_PROTO] = JSON_RPC_PROTO_VERSION;

  methodName = msg[JSON_RPC_METHOD].asString();

  if (methodName != "" && methods.find (methodName) != methods.end() ) {
    Method &method = methods[methodName];
    Json::Value response;

    try {
      method (msg[JSON_RPC_PARAMS], response);

      if (!msg.isMember (JSON_RPC_ID) || msg[JSON_RPC_ID] == Json::Value::null) {
        if (response != Json::Value::null) {
          throw JsonRpc::CallException (ErrorCode::SERVER_ERROR_INIT,
                                        "Ignoring response because of a notification request",
                                        response);
        }

        _response = Json::Value::null;
      } else {
        _response[JSON_RPC_RESULT] = response;
      }

      return true;
    } catch (CallException &e) {
      Json::Value error;
      Json::Value data;

      error[JSON_RPC_ERROR_CODE] = e.getCode();
      error[JSON_RPC_ERROR_MESSAGE] = e.getMessage();

      data = e.getData();

      if (data != Json::Value::null) {
        error[JSON_RPC_ERROR_DATA] = data;
      }

      _response[JSON_RPC_ERROR] = error;
    } catch (std::string &e) {
      Json::Value error;

      error[JSON_RPC_ERROR_CODE] = INTERNAL_ERROR;
      error[JSON_RPC_ERROR_MESSAGE] =
        std::string ("Unexpected error while processing method: ") + e;

      _response[JSON_RPC_ERROR] = error;
    } catch (std::exception &e) {
      Json::Value error;

      error[JSON_RPC_ERROR_CODE] = INTERNAL_ERROR;
      error[JSON_RPC_ERROR_MESSAGE] =
        std::string ("Unexpected error while processing method: ") + e.what();

      _response[JSON_RPC_ERROR] = error;
    } catch (...) {
      Json::Value error;

      error[JSON_RPC_ERROR_CODE] = INTERNAL_ERROR;
      error[JSON_RPC_ERROR_MESSAGE] = "Unexpected error while processing method";

      _response[JSON_RPC_ERROR] = error;
    }

    return false;
  }

  error[JSON_RPC_ERROR_CODE] = METHOD_NOT_FOUND;
  error[JSON_RPC_ERROR_MESSAGE] = "Method not found.";
  _response[JSON_RPC_ERROR] = error;

  return false;
}