Use ID instead of username
This commit is contained in:
		
							
								
								
									
										8
									
								
								controller-client/camshader.glsl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								controller-client/camshader.glsl
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					#pragma lannguage glsl1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					vec4 effect(vec4 color, Image tex, vec2 texture_coords, vec2 screen_coords)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						vec4 textureColor = Texel(tex, texture_coords);
 | 
				
			||||||
 | 
						vec4 result = vec4(textureColor[2], textureColor[1], textureColor[0], textureColor[3]);
 | 
				
			||||||
 | 
						return result * color;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -22,11 +22,13 @@ function love.draw2()
 | 
				
			|||||||
		local scaledWidth = imageWidth * scale
 | 
							local scaledWidth = imageWidth * scale
 | 
				
			||||||
		local scaledHeight = imageHeight * scale
 | 
							local scaledHeight = imageHeight * scale
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							love.graphics.setShader(CamShader)
 | 
				
			||||||
		love.graphics.draw(BotState.camfeed,
 | 
							love.graphics.draw(BotState.camfeed,
 | 
				
			||||||
			(width - scaledWidth) / 2, (height - scaledHeight) / 2,
 | 
								(width - scaledWidth) / 2, (height - scaledHeight) / 2,
 | 
				
			||||||
			0,
 | 
								0,
 | 
				
			||||||
			scale, scale
 | 
								scale, scale
 | 
				
			||||||
		)
 | 
							)
 | 
				
			||||||
 | 
							love.graphics.setShader(nil)
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	-- Draw time
 | 
						-- Draw time
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,8 @@ package.loaded["draw"] = nil
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
require("draw")
 | 
					require("draw")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CamShader = nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
BotState = {
 | 
					BotState = {
 | 
				
			||||||
	lastMessage = 0,
 | 
						lastMessage = 0,
 | 
				
			||||||
	cpuBattery = nil,
 | 
						cpuBattery = nil,
 | 
				
			||||||
@@ -38,6 +40,8 @@ function formatSafe(format, value, ...)
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function love.load()
 | 
					function love.load()
 | 
				
			||||||
 | 
						CamShader = love.graphics.newShader("client/camshader.glsl")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	love.graphics.setFont(love.graphics.newFont(20))
 | 
						love.graphics.setFont(love.graphics.newFont(20))
 | 
				
			||||||
	love.window.setFullscreen(true)
 | 
						love.window.setFullscreen(true)
 | 
				
			||||||
	love.mqtt.subscribe("telemetry/#")
 | 
						love.mqtt.subscribe("telemetry/#")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -48,7 +48,7 @@ end
 | 
				
			|||||||
local function main()
 | 
					local function main()
 | 
				
			||||||
	client = mqtt.client {
 | 
						client = mqtt.client {
 | 
				
			||||||
		uri = "mqtt.seeseepuff.be",
 | 
							uri = "mqtt.seeseepuff.be",
 | 
				
			||||||
		username = "mqtt_controller-" .. math.random(0, maxClientId),
 | 
							id = "mqtt_controller-" .. math.random(0, maxClientId),
 | 
				
			||||||
		clean = true,
 | 
							clean = true,
 | 
				
			||||||
		reconnect = 5,
 | 
							reconnect = 5,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,8 +35,8 @@ end
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
client = mqtt.client {
 | 
					client = mqtt.client {
 | 
				
			||||||
	uri = "mqtt.seeseepuff.be",
 | 
						uri = "mqtt.seeseepuff.be",
 | 
				
			||||||
	username = "tools",
 | 
						username = "tool-get-image",
 | 
				
			||||||
	clean = true,
 | 
						id = true,
 | 
				
			||||||
	reconnect = 5,
 | 
						reconnect = 5,
 | 
				
			||||||
	version = mqtt.v311,
 | 
						version = mqtt.v311,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,7 +29,7 @@ end
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
client = mqtt.client {
 | 
					client = mqtt.client {
 | 
				
			||||||
	uri = "mqtt.seeseepuff.be",
 | 
						uri = "mqtt.seeseepuff.be",
 | 
				
			||||||
	username = "tools",
 | 
						id = "tool-get-ip",
 | 
				
			||||||
	clean = true,
 | 
						clean = true,
 | 
				
			||||||
	reconnect = 5,
 | 
						reconnect = 5,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,15 +21,16 @@ def handle_camera_event(cm):
 | 
				
			|||||||
def sendImage(plane):
 | 
					def sendImage(plane):
 | 
				
			||||||
	image = Image.frombytes("RGBA", (800, 600), plane.tobytes())
 | 
						image = Image.frombytes("RGBA", (800, 600), plane.tobytes())
 | 
				
			||||||
	pngBytes = io.BytesIO()
 | 
						pngBytes = io.BytesIO()
 | 
				
			||||||
	image.save(pngBytes, "png")
 | 
						image.convert("RGB").save(pngBytes, "jpeg")
 | 
				
			||||||
	mqttc.publish("spider/telemetry/camfeed", pngBytes.getvalue())
 | 
						mqttc.publish("spider/telemetry/camfeed", pngBytes.getvalue())
 | 
				
			||||||
 | 
						#mqttc.publish("spider/telemetry/camfeed", plane.tobytes())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def process_request(request):
 | 
					def process_request(request):
 | 
				
			||||||
	global camera, image_count
 | 
						global camera, image_count
 | 
				
			||||||
	global mqttc
 | 
						global mqttc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	image_count += 1
 | 
						image_count += 1
 | 
				
			||||||
	if image_count > 1:
 | 
						if image_count > 0:
 | 
				
			||||||
		image_count = 0
 | 
							image_count = 0
 | 
				
			||||||
		print(f'Request completed: {request}')
 | 
							print(f'Request completed: {request}')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,34 +1,33 @@
 | 
				
			|||||||
package.path = package.path .. ';./controller-host/?/init.lua;./controller-host/?.lua'
 | 
					package.path = package.path .. ';./controller-host/?/init.lua;./controller-host/?.lua'
 | 
				
			||||||
local mqtt = require("mqtt")
 | 
					local mqtt = require("mqtt")
 | 
				
			||||||
 | 
					local socket = require("socket")
 | 
				
			||||||
local client
 | 
					local client
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local fh = io.open("spider-image.bin", "rb")
 | 
				
			||||||
 | 
					local contents = fh:read("a")
 | 
				
			||||||
 | 
					fh:close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function onConnect(connack)
 | 
					local function onConnect(connack)
 | 
				
			||||||
	if connack.rc ~= 0 then
 | 
						if connack.rc ~= 0 then
 | 
				
			||||||
		print("Connection to broker failed:", connack:reason_string())
 | 
							print("Connection to broker failed:", connack:reason_string())
 | 
				
			||||||
		os.exit(1)
 | 
							os.exit(1)
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					 | 
				
			||||||
	--local length = 1000000
 | 
					 | 
				
			||||||
	-- 500000
 | 
					 | 
				
			||||||
	local length = 1000000
 | 
					 | 
				
			||||||
	-- 100000
 | 
					 | 
				
			||||||
	--while true do
 | 
					 | 
				
			||||||
	local payload = string.rep("b", length)
 | 
					 | 
				
			||||||
	--length = length + 100000
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	assert(client:publish {
 | 
						while true do
 | 
				
			||||||
		topic = "spider/telemetry/camfeed",
 | 
							assert(client:publish {
 | 
				
			||||||
		payload = payload,
 | 
								topic = "spider/telemetry/camfeed",
 | 
				
			||||||
		qos = 0
 | 
								payload = contents,
 | 
				
			||||||
	})
 | 
								qos = 0
 | 
				
			||||||
	--end
 | 
							})
 | 
				
			||||||
 | 
							socket.sleep(1)
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	print("Connected and subscribed")
 | 
						print("Connected and subscribed")
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
client = mqtt.client {
 | 
					client = mqtt.client {
 | 
				
			||||||
	uri = "mqtt.seeseepuff.be",
 | 
						uri = "mqtt.seeseepuff.be",
 | 
				
			||||||
	username = "tools",
 | 
						id = "tool-test-image",
 | 
				
			||||||
	clean = true,
 | 
						clean = true,
 | 
				
			||||||
	reconnect = 5,
 | 
						reconnect = 5,
 | 
				
			||||||
	version = mqtt.v311,
 | 
						version = mqtt.v311,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,7 +41,7 @@ end
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
client = mqtt.client {
 | 
					client = mqtt.client {
 | 
				
			||||||
	uri = "mqtt.seeseepuff.be",
 | 
						uri = "mqtt.seeseepuff.be",
 | 
				
			||||||
	username = "mqtt_controller",
 | 
						username = "tool-upload-controller",
 | 
				
			||||||
	clean = true,
 | 
						clean = true,
 | 
				
			||||||
	reconnect = 5,
 | 
						reconnect = 5,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user