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
  socket.gaierror: [Errno 11001] Johnygo 3 131 Aug-07-2019, 02:49 PM
Last Post: Johnygo
  Send raw string via socket with out any changes john36 18 473 Aug-01-2019, 07:54 AM
Last Post: john36
  Server and Network (socket) [WinError 10053] Timxxx 0 122 Jul-17-2019, 11:50 PM
Last Post: Timxxx
  Question concerning function of a a socket pkm 4 1,133 Jun-04-2019, 07:48 AM
Last Post: DeaD_EyE
  socket.gaierror: [Errno -2] Name or service not known seokangwoo99 5 495 May-25-2019, 02:36 PM
Last Post: DeaD_EyE
  socket programming ConnectionRefusedError error srm 3 355 May-16-2019, 08:07 PM
Last Post: LavaCreeperKing
  Socket reading script Will86 4 407 Apr-17-2019, 06:57 AM
Last Post: Will86
  Server and Network (socket) [WinError 10053] SheeppOSU 2 568 Apr-13-2019, 09:23 PM
Last Post: SheeppOSU
  Python_Windows_Wifi/access point samerou 2 355 Mar-31-2019, 07:37 PM
Last Post: samerou
  Async socket server and ports Pengwyn 1 435 Feb-28-2019, 12:13 AM
Last Post: DeaD_EyE

Forum Jump:


Users browsing this thread: 1 Guest(s)