Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
RadioCfg.h
00001 #ifndef _RADIO_CONFIG_H_ 00002 #define _RADIO_CONFIG_H_ 00003 00004 #include <stdio.h> 00005 #include <stdlib.h> 00006 #include <string.h> 00007 #include <vector> 00008 #include "stdint.h" 00009 #include "jsmn.h" 00010 00011 #define RADIO_NAME_LEN 100 00012 struct RadioSlave 00013 { 00014 uint64_t radioID; 00015 char name[RADIO_NAME_LEN]; 00016 00017 uint16_t temp_pin; 00018 uint16_t humid_pin; 00019 uint16_t lumin_pin; 00020 uint16_t sprinkler_pin; 00021 uint16_t hthreshold; 00022 00023 RadioSlave() 00024 :radioID(0), 00025 temp_pin(0), 00026 humid_pin(0), 00027 lumin_pin(0), 00028 sprinkler_pin(0), 00029 hthreshold(0) 00030 { 00031 memset(&name[0], 0, RADIO_NAME_LEN); 00032 } 00033 void debug() 00034 { 00035 printf("Slave ID : %lld\r\n", radioID); 00036 printf("Name : \"%s\"\r\n", &name[0]); 00037 printf("Temperature Pin: %d\r\n", temp_pin); 00038 printf("Humidity Pin: %d\r\n", humid_pin); 00039 printf("Luminance Pin: %d\r\n", lumin_pin); 00040 printf("Sprinkler Pin: %d\r\n", sprinkler_pin); 00041 printf("Humidity Threshold: %d\r\n", hthreshold); 00042 } 00043 }; 00044 00045 struct RadioCfg 00046 { 00047 uint64_t radioID; 00048 char name[RADIO_NAME_LEN]; 00049 char country[RADIO_NAME_LEN]; 00050 uint32_t utc_offset; 00051 std::vector<RadioSlave> radios; 00052 00053 RadioCfg() 00054 :radioID(0), 00055 utc_offset(0) 00056 { 00057 memset(&name[0], 0, RADIO_NAME_LEN); 00058 memset(&country[0], 0, RADIO_NAME_LEN); 00059 radios.clear(); 00060 } 00061 00062 inline void debug() 00063 { 00064 printf("Radio ID: %lld\r\n", radioID); 00065 printf("Name : \"%s\"\r\n", &name[0]); 00066 printf("Country : \"%s\"\r\n", &country[0]); 00067 printf("UTC Offset: %d\r\n", utc_offset); 00068 std::vector<RadioSlave>::iterator it; 00069 for(it = radios.begin(); it != radios.end(); it++) 00070 { 00071 (*it).debug(); 00072 } 00073 } 00074 00075 }; 00076 00077 int parseradioconfig(const char * jsonstring, RadioCfg &); 00078 00079 #endif
Generated on Tue Jul 12 2022 18:06:46 by
1.7.2