
SE59XX-SDK
Software development Kit
User Manual
Data Structure
Documentation
114 {
115 // read key from ini
116 dictionary *ini = iniparser_load(ini_file_name);
117 if (ini==NULL) {
118 fprintf(stderr, "Cannot open %s\n",ini_file_name);
119 return -1;
120 }
121
122 // setting key_mgmt mode by user input
123 switch (mode) {
124 case 0 :
125 iniparser_set(ini, "network:key_mgmt", "None");
126 break;
127
128 case 1 :
129 iniparser_set(ini, "network:key_mgmt", "WPA-PSK");
130 break;
131
132 case 2 :
133 iniparser_set(ini, "network:key_mgmt", "WPA2-PSK");
134 break;
135
136 default :
137 printf("Input error!\n");
138 printf("0 : Disable\n");
139 printf("1 : WPA-PSK\n");
140 printf("2 : WPA2-PSK\n");
141 break;
142 }
143
144 // write key_mgmt into ini
145 FILE *fin = fopen("/jffs2/tmpFile", "w");
146 iniparser_dump_ini(ini, fin);
147 iniparser_freedict(ini);
148
149 fclose(fin);
150 remove(ini_file_name);
151 rename("/jffs2/tmpFile", ini_file_name);
152 return 0;
153 }
7.13.9
int set_psk (char psk_name)
API
: set_psk
Arguments
: psk_name: string of psk to be saved in ini file - (char)
Function
: writes psk to ini file
Returns
: int:
-1 : Error – cannot open file, Invalid command, wrong length
0 : Successful
Example code
:
185 {
186 char *key_mgmt;
187
188 // read key from ini
189 dictionary *ini = iniparser_load(ini_file_name);
190 if (ini==NULL) {
191 fprintf(stderr, "Cannot open %s\n",ini_file_name);
192 return -1;
193 }
194
195 // cannot set psk, if key_mgmt is disable
196 key_mgmt = iniparser_getstring(ini, "network:key_mgmt", NULL);
197 if ( strcmp(key_mgmt,"None")==0 ) {
198 printf("Invalid commend!\nkey_mgmt is disable\n");
199 iniparser_freedict(ini);
200 return -1;
201 }
202
203 // write psk into ini, if it's lengh between 8 and 63
Содержание SE59XX-SDK
Страница 11: ...SE59XX SDK Software development Kit User Manual V1 2...
Страница 13: ...SE59XX SDK Software development Kit User Manual V1 2 libatop so 1 0 0 ATOP library binary...
Страница 17: ...SE59XX SDK Software development Kit User Manual V1 2 Figure 2 5 SE5904DB o ot loadermenu...
Страница 33: ...SE59XX SDK Software development Kit User Manual V1 2...
Страница 35: ...SE59XX SDK Software development Kit User Manual V1 2 SE5901B SE5908 16...
Страница 36: ...SE59XX SDK Software development Kit User Manual V1 2 SE5908A 16A...
Страница 37: ...SE59XX SDK Software development Kit User Manual V1 2...
Страница 43: ...SE59XX SDK Software development Kit User Manual V1 2 5 SG Signal Ground SG Signal Ground SG Signal Ground...
Страница 52: ...SE59XX SDK Software development Kit User Manual V1 2...