Beispiel #1
0
bool MqttSnClient::loop() {
   if(mCurrentState == DISCONNECTED || mCurrentState == LOST) {
      return false;
   }

   uint8_t buffer[I_RfPacketSocket::PAYLOAD_CAPACITY+1] = {0};
   if(handleLoop(buffer, PUBLISH)) {
      handlePublish(buffer);
   }

   unsigned long now = millis();

   if (((now - mLastReveiveActivity) > mKeepAliveTimerDuration) || ((now - mLastSendActivity) > mKeepAliveTimerDuration)) {
      BT_LOG_INFO("send PINGREQ ...");
      Pingreq* message = reinterpret_cast<Pingreq*>(buffer);
      message->initialize();
      if (!send(buffer, message->header.length))
      {
         BT_LOG_WARNING("send PINGREQ failed");
         changeState(LOST);
         return false;
      }
      if(!pollLoop(buffer, PINGRESP)) {
         BT_LOG_WARNING("wait for PINGRESP timeout");
         changeState(LOST);
         return false;
      }
      BT_LOG_INFO(" ... PINGRESP received");
   }

   return true;
}
Beispiel #2
0
bool MqttSnClient::pollLoop(uint8_t* oBuffer, uint8_t msgType) {
   unsigned long timeout = millis() + BT_MQTTSN_T_RETRY;
   while(!handleLoop(oBuffer, msgType)){
      if((BT_MQTTSN_T_RETRY != 0) &&  (millis() > timeout) ) {
         return false;
      }
   }

   return true;
}
Beispiel #3
0
  int
  BrepHandler::extractLoop(const DirectoryEntry* de, bool isOuter, int face) {
    debug("########################## E X T R A C T   L O O P");
    ParameterData params;
    _iges->getParameter(de->paramData(), params);

    int loop = handleLoop(isOuter, face);
    int numberOfEdges = params.getInteger(1);

    int i = 2; // extract the edge uses!
    for (int _i = 0; _i < numberOfEdges; _i++) {
      bool isVertex = (1 == params.getInteger(i)) ? true : false;
      Pointer edgePtr = params.getPointer(i+1);
      int index = params.getInteger(i+2);
      // need to get the edge list, and extract the edge info
      int edge = extractEdge(_iges->getDirectoryEntry(edgePtr), index);
      bool orientWithCurve = params.getLogical(i+3);

      // handle this edge
      handleEdgeUse(edge, orientWithCurve);

      // deal with param-space curves (not generally included in Pro/E output)
      int numCurves = params.getInteger(i+4);
      int j = i+5;
      list<PSpaceCurve> pCurveIndices;
      for (int _j = 0; _j < numCurves; _j++) {
	// handle the param-space curves, which are generally not included in MSBO
	Logical iso = params.getLogical(j);
	Pointer ptr = params.getPointer(j+1);
	pCurveIndices.push_back(PSpaceCurve(_iges,
					    this,
					    iso,
					    ptr));
	j += 2;
      }
      i = j;
    }
    return loop;
  }