hostapd debugging

sudo hostapd -dd /etc/hostapd/hostapd.conf

tells you if your config file is broken. Which helps.

Sample hostapd.conf for wpa-password protected access point:

ssid=myssid
interface=wlan0
driver=nl80211
hw_mode=g
channel=1
wpa=2
wpa_passphrase=mypass
wpa_key_mgmt=WPA-PSK
# makes the SSID visible and broadcasted
ignore_broadcast_ssid=0

Notes on uploading images via sinatra in ruby

In case it’s useful to anyone else. I got tips via this post which has a snippet that allows you to see what files are open.

ObjectSpace.each_object(File) do |f|
  unless f.closed?
    puts "This file is still open: %s: %d\n" % [f.path, f.fileno]
  end
end

It turned out I was leaving my temporary file open. The upload code is from here.

post '/image' do
 cross_origin
  name = params[:name]
  my_file = params[:my_file]
  unless params[:my_file] && (tmpfile = params[:my_file][:tempfile])
    @error = "No file selected"
    return haml(:upload)
  end
  STDERR.puts "Uploading file, original name #{name}"
  directory = "public/data"
  path = File.join(directory, name+".jpg")
  File.open(path, 'wb') do |f|
    while chunk = tmpfile.read(65536)
      f.write(chunk)
    end
  tmpfile.close
  end
  "Upload complete\n"
 end

or more concisely (thanks @andrewn)


post '/image' do
 cross_origin
  name = params[:name]
  my_file = params[:my_file]
  unless params[:my_file] && (tmpfile = params[:my_file][:tempfile])
    @error = "No file selected"
    return haml(:upload)
  end
  STDERR.puts "Uploading file, original name #{name}"
  directory = "public/data"
  path = File.join(directory, name+".jpg")
  FileUtils.mv(tmpfile, path)
  "Upload complete\n"
 end

and on the other side, the curl command is:

curl http://example.com/image -F my_file=@"/run/shm/image.jpg" -F "name=new_name"