Use strtoul() instead of custom code.
A standard function exists to convert c-style strings to unsigned longs.
This commit is contained in:
1 parent
26c80f4b60
commit
dc0cbee5aa
1 file changed
+1
-10
@@ -300,7 +300,7 @@ void receivingMQTT(String topicNameRec, String callbackstring) {
|
|||||||
client.publish("home/ack", DataAck);
|
client.publish("home/ack", DataAck);
|
||||||
callbackstring.toCharArray(datacallback,32);
|
callbackstring.toCharArray(datacallback,32);
|
||||||
trc(datacallback);
|
trc(datacallback);
|
||||||
unsigned long data = char2Ulong(datacallback); // we will not be able to pass value > 4294967295
|
unsigned long data = strtoul(datacallback, NULL, 10); // we will not be able to pass value > 4294967295
|
||||||
trc(String(data));
|
trc(String(data));
|
||||||
|
|
||||||
if (topicNameRec == subjectMQTTto433){
|
if (topicNameRec == subjectMQTTto433){
|
||||||
@@ -332,15 +332,6 @@ void receivingMQTT(String topicNameRec, String callbackstring) {
|
|||||||
irsend.sendSAMSUNG(data, 32);
|
irsend.sendSAMSUNG(data, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long char2Ulong(char *str)
|
|
||||||
{
|
|
||||||
unsigned long result = 0; // Initialize result
|
|
||||||
// Iterate through all characters of input string and update result
|
|
||||||
for (int i = 0; str[i] != '\0'; ++i)
|
|
||||||
result = result*10 + str[i] - '0';
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//send MQTT data dataStr to topic topicNameSend
|
//send MQTT data dataStr to topic topicNameSend
|
||||||
void sendMQTT(String topicNameSend, String dataStr){
|
void sendMQTT(String topicNameSend, String dataStr){
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user