示例#1
0
SNMP_API_STAT_CODES SNMPClass::begin(const char *getCommName, const char *setCommName, const char *trapCommName, uint16_t port)
{
  //initialize request counter
    requestCounter = 1;
    _extra_data_size = 0;
    _udp_extra_data_packet = false;
    
  // set community name set/get sizes
  _setSize = strlen(setCommName);
  _getSize = strlen(getCommName);
  _trapSize = strlen(trapCommName);
  //
  // validate get/set community name sizes
  if ( _setSize > SNMP_MAX_NAME_LEN + 1 || _getSize > SNMP_MAX_NAME_LEN + 1 || _trapSize > SNMP_MAX_NAME_LEN + 1) {
    return SNMP_API_STAT_NAME_TOO_BIG;
  }
  //
  // set community names
  _getCommName = getCommName;
  _setCommName = setCommName;
  _trapCommName = trapCommName;
  
  // validate session port number
  if ( port == NULL || port == 0 ) port = SNMP_DEFAULT_PORT;
  //
  // init UDP socket
  Udp.stop();
  Udp.begin(port);

  return SNMP_API_STAT_SUCCESS;
}
示例#2
0
/*
 * Restart our ntp handler.  This is only done as part of restarting the
 * network.  As such, all we want to do is make sure udp is still working.
 * We dont need to issue a time request unless one was already outstanding
 * (not likely)
 */
void restartNtpTime() {

	Udp.stop();

	Udp.begin(8888);

	// If we were already waiting for a response, let's re-issue the request
	if (ntpState == WAITING_FOR_RESPONSE) {
		sendTimeRequest();
	}

}