Skip to content

Commit

Permalink
Fixes #18.
Browse files Browse the repository at this point in the history
Quick fix solution.
  • Loading branch information
shortbloke committed Jul 7, 2022
1 parent 69995ec commit 6679e43
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG for SNMP Manager For ESP8266/ESP32/Arduino

## 1.1.7

- Fixes #18 support OID that use large integers, up to 4 bytes.

## 1.1.6

- Allow non standard port to be used when making SNMP requests. Default UDP port 161 can be overridden using `setPort(<port number>)`.
Expand Down
8 changes: 4 additions & 4 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name=SNMP Manager
version=1.1.6
version=1.1.7
author=Martin Rowan <martin@martinrowan.co.uk>
maintainer=Martin Rowan <martin@martinrowan.co.uk>
sentence=A SNMP Manager for esp32/esp8266 to send SNMP requests to other SNMP enabled devices.
paragraph=Supports SNMP v1 and v2c, sending SNMP GET requests and decoding the GET-RESPONSE for INTEGER, OCTET STRING, OID, COUNTER, COUNTER64, TIMETICKS and GUAGE data types.
sentence=An SNMP Manager library to make SNMP requests to other SNMP enabled devices.
paragraph=Supporting SNMP v1 and v2, SNMP requests can be sent (GetRequest) and their responses received (GetResponse) for various SNMP data types.
category=Communication
url=https://github.com/shortbloke/Arduino_SNMP_Manager
architectures=esp32,esp8266
architectures=*
includes=Arduino_SNMP_Manager.h
21 changes: 14 additions & 7 deletions src/BER.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,23 +315,30 @@ class OIDType : public BER_CONTAINER
strncpy(tempBuf, start, end - start + 1);
long tempVal;
tempVal = atoi(tempBuf);
if (tempVal > 127)
if (tempVal < 128)
{
_length += 1;
*ptr++ = (char)tempVal;
}
else
{
// Serial.print("large num: ");Serial.println(tempVal);
// FIXME: This will only encode integers upto 4 bytes. Ideall this should be a loop.
if (tempVal / 128 / 128 > 128)
{
*ptr++ = ((tempVal / 128 / 128 / 128 ) | 0x80) & 0xFF;
_length += 1;
}
if (tempVal / 128 > 128)
{
*ptr++ = ((tempVal / 128 / 128) | 0x80) & 0xFF; // dodgy
*ptr++ = ((tempVal / 128 / 128) | 0x80) & 0xFF;
_length += 1;
}
*ptr++ = ((tempVal / 128) | 0x80) & 0xFF;

*ptr++ = tempVal % 128 & 0xFF;
_length += 2;
}
else
{
_length += 1;
*ptr++ = (char)tempVal;
}

valuePtr = end + 1;

Expand Down

0 comments on commit 6679e43

Please sign in to comment.