Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Soft Access Point & Socket Data Streaming
#1
Hello:
I am new to this forum. I am having an issue trying to figure out how to do something seemingly simple, but spinning the wheels. I have searched as many resources as I can, but do not seem to able to find an example. Even books I have bought do not cover how to do this, they're really focused on running the device in 'station mode'.

The device I am using is the ESP32, which I want to act as a soft access data "server". Here's the objective:
-boot the ESP32 in WAP (soft access) mode
-controller begin processing data from the ADC
-wait for connection
-when connection is initiated, begin streaming data at rate 'x". For this I will use a controlled loop or a thread.
-the data will be integers in the range of int16's

At the other side (client) the laptop (for now) will launch a console application to connect to the soft point and receive data and display it in the console.

That's it! My weakness is with using sockets...what I have so far is below. Seems it should be something that is common application, but after many searches I cannot find a basic example. Huh

Can someone provide the missing pieces, or let me know of a resource that I could read to understand how to do this?

Thanks!
Gary

import socket
import network

ap = network.WLAN(network.AP_IF)
ap.active(True)
ap.config(essid='CPTS-A3D', authmode=network.AUTH_WPA_WPA2_PSK, password='password')
ap.ifconfig(('192.168.4.1', '255.255.255.0', '192.168.4.1', '192.168.4.1'))

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#pick a port...should this call be: s.bind(('0,0,0,0', 10000)) ??
s.bind(('', 10000))  
s.listen(5)

while True:
  conn, addr = s.accept()
  #display activity
  print('Got a connection from %s' % str(addr))
  #should this be less bytes for what I need to do?
  request = conn.recv(1024)  

  # THIS IS WHERE I AM TRYING TO FIGURE OUT 
  #HOW TO SEND DATA

  #the next line is part of the 'web server/html' code I found
  #not sure if it will be part of the solution
  conn.sendall(response)
  conn.close()

Quote
#2
I set it solved because I recognize now I posted a primitive question for everyone here. Sorry to bother you all.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  TCP socket, data transnission Simba 4 100 Dec-07-2019, 03:15 PM
Last Post: Simba
  Python_Windows_Wifi/access point samerou 2 526 Mar-31-2019, 07:37 PM
Last Post: samerou
  Send data BMP180 between client and server trought module socket smalhao 0 773 Jul-30-2018, 12:56 PM
Last Post: smalhao
  Python socket : Error receive data quanglnh1993 1 3,880 Mar-14-2018, 11:59 AM
Last Post: avorane
  Socket won't receive data suddenly with multiple clients SquareRoot 0 1,118 Sep-06-2017, 09:09 PM
Last Post: SquareRoot
  socket server with SSL accepting unencrypted data kopite 0 1,266 Apr-20-2017, 08:31 AM
Last Post: kopite

Forum Jump:


Users browsing this thread: 1 Guest(s)