Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Strings, Support to Ethernet & Bug Fixing #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Bolofofopt
Copy link

Improvements done:

Ethernet

This library was changed from WiFi to Ethernet

Strings

This library now sends Strings

void ESP32ZabbixSender::AddItemString(String key, String value) {
	zabbixItemListString[zabbixItemSizeString].key = key;
	zabbixItemListString[zabbixItemSizeString].val = value;
	zabbixItemSizeString++;
}```

```cpp
int ESP32ZabbixSender::createZabbixPacketString(void) { // [private] create ZabbixPacket
	int packetLen = 0;
	char s[16];
	String Json = "{\"request\":\"sender data\",\"data\":[";
	for (int i = 0; i < zabbixItemSizeString; i++) {
		if (i > 0) {
			Json += ",";
		}
		Json += "{\"host\":\"" + zItemHost + "\",\"key\":\"" + zabbixItemListString[i].key + "\",\"value\":\"" + zabbixItemListString[i].val + "\"}";
	}
	Json += "]}";

	for (int i = 0; i < ZABBIXMAXLEN; i++) {
		zabbixPacket[i] = 0;
	}
	zabbixPacket[0] = 'Z';
	zabbixPacket[1] = 'B';
	zabbixPacket[2] = 'X';
	zabbixPacket[3] = 'D';
	zabbixPacket[4] = 0x01;
	uint16_t JsonLen = Json.length();
	uint16_t remLen = JsonLen;
	for (int i = 0; i < 8; i++) {
		zabbixPacket[5 + i] = (remLen % 256);
		remLen = (uint16_t)remLen / 256;
	}
	Json.getBytes(&(zabbixPacket[13]), ZABBIXMAXLEN - 12);
	packetLen = 13 + JsonLen;
#ifndef SILENT
	Serial.print("request = ");
	for (int i = 0; i < packetLen; i++) {
		Serial.print((char)(zabbixPacket[i]));
	}
	Serial.println();
#endif
	return packetLen;
}

Bug fixing:

This library had a function that when the client was available it sends the package, and when it doesn't it freezes. That is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant