mirror of https://github.com/lumapu/ahoy.git
				
				
			
			
			
				Browse Source
			
			
			
			
				
		removed wrong "inverter type can't be detected!" messages repaired NTP and static IP #459 MQTT status about availability and produce are retain messages nowpull/467/head
				 11 changed files with 96 additions and 87 deletions
			
			
		| @ -0,0 +1,29 @@ | |||
| //-----------------------------------------------------------------------------
 | |||
| // 2022 Ahoy, https://github.com/lumpapu/ahoy
 | |||
| // Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
 | |||
| //-----------------------------------------------------------------------------
 | |||
| 
 | |||
| #include "helper.h" | |||
| 
 | |||
| namespace ah { | |||
|     void ip2Arr(uint8_t ip[], const char *ipStr) { | |||
|         memset(ip, 0, 4); | |||
|         char *tmp = new char[strlen(ipStr)+1]; | |||
|         strncpy(tmp, ipStr, strlen(ipStr)+1); | |||
|         char *p = strtok(tmp, "."); | |||
|         uint8_t i = 0; | |||
|         while(NULL != p) { | |||
|             ip[i++] = atoi(p); | |||
|             p = strtok(NULL, "."); | |||
|         } | |||
|         delete[] tmp; | |||
|     } | |||
| 
 | |||
|     // note: char *str needs to be at least 16 bytes long
 | |||
|     void ip2Char(uint8_t ip[], char *str) { | |||
|         if(0 == ip[0]) | |||
|             str[0] = '\0'; | |||
|         else | |||
|             snprintf(str, 16, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); | |||
|     } | |||
| } | |||
| @ -0,0 +1,19 @@ | |||
| //-----------------------------------------------------------------------------
 | |||
| // 2022 Ahoy, https://ahoydtu.de
 | |||
| // Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
 | |||
| //-----------------------------------------------------------------------------
 | |||
| 
 | |||
| #ifndef __HELPER_H__ | |||
| #define __HELPER_H__ | |||
| 
 | |||
| #include <cstdint> | |||
| #include <cstring> | |||
| #include <stdio.h> | |||
| #include <stdlib.h> | |||
| 
 | |||
| namespace ah { | |||
|     void ip2Arr(uint8_t ip[], const char *ipStr); | |||
|     void ip2Char(uint8_t ip[], char *str); | |||
| } | |||
| 
 | |||
| #endif /*__HELPER_H__*/ | |||
					Loading…
					
					
				
		Reference in new issue