/* * use when update config,e.g. change wifi name or password or access point */ void Wifi::restartWifi() { stopWifi(); QElapsedTimer t; t.start(); while(t.elapsed()<5000) QCoreApplication::processEvents(); startWifi(); }
static void my_button_press(GtkWidget *widget, GdkEventButton *event, gpointer data) { int x, y; // bstate = PRESSED; x = event->x; y = event->y; #if MY_DEBUG_OUTPUT == 1 g_print("hello, x is:%d, y is:%d\n", x, y); #endif if(in_image1(x,y)) {/*browser*/ #if MY_DEBUG_OUTPUT == 1 g_print("pressed in the image1\n"); #endif //launchApp_simple("/usr/bin/midbrowser"); startBrowser(widget); } else if(in_image2(x,y)) {/*Audio*/ #if MY_DEBUG_OUTPUT == 1 g_print("pressed in the image2\n"); #endif //launchApp_simple("/usr/bin/ls -a");//这里启动程序 //launchApp_simple("/usr/bin/StartAudio.sh"); startAudio(widget); } else if(in_image3(x,y)) {/*Video*/ #if MY_DEBUG_OUTPUT == 1 g_print("pressed in the image3\n"); #endif //launchApp_simple("/usr/bin/echo good");//这里启动程序 //launchApp_simple("/usr/bin/StartVideo.sh"); startVideo(widget); } else if(in_image4(x,y)) {/*Wifi*/ #if MY_DEBUG_OUTPUT == 1 g_print("pressed in the image4\n"); #endif //launchApp_simple("/usr/bin/echo 'hello world'");//这里启动程序 //launchApp_simple("/usr/bin/StartWifi.sh");//这里启动程序 startWifi(widget); } else { #if MY_DEBUG_OUTPUT == 1 g_print("pressed out of all the image!\n"); #endif } }
/************************ Hiermee starten we de laadpaal op. ************************/ int main(){ struct arg *argument=malloc(sizeof argument); int error, socket2, useport; char *tekst=malloc(tekstlengte*sizeof(char)); void *buffer=malloc(bufferlengte*sizeof(char)); struct addrinfo hints; struct sockaddr_storage client_addr; struct arg input; socklen_t clilen; pthread_t thr; init(); me=startWifi(); usleep(10000000); input=startServer(poort, me); masterSlave(input); //close(input.socket1); //input=startServer(poort, me); printf("poort %i me %s\n",poort,me); useport=poort+1; input.hints.ai_flags=AI_PASSIVE; while(1){ memset(&client_addr, 0, sizeof(client_addr)); clilen=16; socket2=accept(input.socket1, (struct sockaddr *)&client_addr, &clilen); if(socket2<0){ printf("problemen bij oude accept, error nummer %i, boodschap: %s\n",socket2, gai_strerror(socket2)); return -5; } useport=(useport-poort)%max_poort+1+poort; sprintf(tekst,"%i\r\n",useport); error=send(socket2,tekst,strlen(tekst)*sizeof(char),hints.ai_flags); if(error<0){ printf("problemen bij verzenden van hetpakket\n"); } *argument=startServer(useport, me); argument->connection=useport; printf("De poort voor het oproepen van de pthread_create %i %i",useport,argument->connection); pthread_create(&thr,NULL,doeiets, (void*)argument); close(socket2); } close(input.socket1); free(buffer); return 0; }
task main() { long rate = 0; eraseDisplay(); bNxtLCDStatusDisplay = true; // Enable top status line display writeDebugStream("Scanning for wifi sensor: "); rate = scanBaudRate(); writeDebugStreamLine("%d baud", rate); startWifi(); // configureWiFi(); // set_verbose(false); // Receive(); // wait1Msec(100); /* closeAllConns(); wait1Msec(1000); clear_read_buffer(); startListen(80); SensorType[COLOUR] = sensorCOLORRED; clear_read_buffer(); parseInput(); */ // startDemon(); }
void setup() { pinMode(13, OUTPUT); Serial.begin(74880); Serial.println("Initializing..."); WiFi.mode(WIFI_AP_STA); WiFi.softAP("foobar", "12345678", 1, 0); if (startWifi(30)) { } else { Serial.println("failed to start wifi"); ESP.restart(); } uint8_t macaddr[6]; wifi_get_macaddr(STATION_IF, macaddr); Serial.print("mac address (STATION_IF): "); printMacAddress(macaddr); wifi_get_macaddr(SOFTAP_IF, macaddr); Serial.print("mac address (SOFTAP_IF): "); printMacAddress(macaddr); if (esp_now_init() == 0) { Serial.println("init"); } else { Serial.println("init failed"); ESP.restart(); return; } esp_now_set_self_role(ESP_NOW_ROLE_SLAVE); esp_now_register_recv_cb([](uint8_t *macaddr, uint8_t *data, uint8_t len) { // Serial.print("data: "); // for (int i = 0; i < len; i++) { // Serial.print(" 0x"); // Serial.print(data[i], HEX); // } // // Serial.println(""); // Serial.print("recv_cb length="); // Serial.print(len); // Serial.print(" from mac address: "); // printMacAddress(macaddr); // // exception... //send_data_t* send_data = static_cast<send_data_t*>(static_cast<void*>(data)); send_data_t send_data; memcpy(&send_data, data, sizeof(send_data)); // uint8_t data_len = (len - sizeof(send_data.chipId) - sizeof(send_data.battery)) / sizeof(uint32_t); // Serial.print("data_len: "); // Serial.println(data_len); data_queue.push_back(send_data); }); esp_now_register_send_cb([](uint8_t* macaddr, uint8_t status) { Serial.println("send_cb"); Serial.print("mac address: "); printMacAddress(macaddr); Serial.print("status = "); Serial.println(status); }); int res = esp_now_add_peer(mac, (uint8_t)ESP_NOW_ROLE_CONTROLLER,(uint8_t)WIFI_DEFAULT_CHANNEL, NULL, 0); // esp_now_unregister_recv_cb(); // esp_now_deinit(); }