Python Forum
Soft Access Point & Socket Data Streaming
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()
Reply
#2
I set it solved because I recognize now I posted a primitive question for everyone here. Sorry to bother you all.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Socket to stream data and tranmit and revieve data kiyoshi7 0 1,469 Aug-11-2022, 10:52 PM
Last Post: kiyoshi7
  how to split socket data onto multiple clients for separate processing ConcealedFox70 0 1,142 Jan-11-2022, 08:26 PM
Last Post: ConcealedFox70
  M4S file extensin in Streaming video. How to download and use in Python Man_from_India 0 2,182 Aug-20-2020, 07:48 AM
Last Post: Man_from_India
  socket without blocking loop and automatically retrieve data from the port RubenP 3 2,004 Jun-21-2020, 10:59 PM
Last Post: Gribouillis
  online audio streaming experimental 0 1,543 Dec-18-2019, 07:59 PM
Last Post: experimental
  TCP socket, data transnission Simba 4 2,359 Dec-07-2019, 03:15 PM
Last Post: Simba
  Python_Windows_Wifi/access point samerou 2 2,261 Mar-31-2019, 07:37 PM
Last Post: samerou
  Send data BMP180 between client and server trought module socket smalhao 0 2,181 Jul-30-2018, 12:56 PM
Last Post: smalhao
  Python socket : Error receive data quanglnh1993 1 11,644 Mar-14-2018, 11:59 AM
Last Post: avorane
  Socket won't receive data suddenly with multiple clients SquareRoot 0 2,279 Sep-06-2017, 09:09 PM
Last Post: SquareRoot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020