cpp # include <WiFi.h> char ssid = ""; char password = ""; char * key = "Bearer "; //pretend these were filled out void setup() { Serial.begin(9600); if (!Serial) { delay(5000); } Serial.print("Connecting to WiFi\n"); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { continue; } Serial.print("Connected!\n"); WiFiSSLClient client; Serial.print("Connecting to OpenAI\n"); if (!client.connectSSL("api.openai.com", 443)) { Serial.print("Connection failed!"); return; } Serial.print("Connected!\n"); String payload = "{\ model: gpt-3.5-turbo,\ messages: [{\ role: system,\ content: Why is grass green?\ }]\ }"; client.println("POST /v1/chat/completions HTTPS/1.0"); client.println("Host: api.openai.com"); client.println("Content-Type: application/json"); client.print("Content-Length: "); client.println(payload.length()); client.print("Authorization: "); client.println(key); client.println();//separate data from headers client.println(payload); while (client.available()) { char c = client.read(); Serial.print(c); } if (!client.connected()) { Serial.print("disconnected\n"); client.stop(); } }This is the code I'm using ^^ I've tried a ton of stuff but I only ever get an error code 400.... For reference, here's the request working
bash curl https://api.openai.com/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: $KEY" -d '{ "model": "gpt-3.5-turbo", "messages": [ { "role": "system", "content": "Why is grass green?." } ] }'^^ the above command actually returns a ChatGPT-generated response
make -C /lib/modules/6.1.21-v8+/build M=/home/dietpi/r8152-2.16.3 modules make[1]: /lib/modules/6.1.21-v8+/build: No such file or directory. Stop. make: [Makefile:24: modules] Error 2
python pyautogui - attempt to move the cursor using pyautogui.moveTo(screen_width - 1, screen_height - 1) xdotool via subprocess - subprocess.run(["xdotool", "mousemove", str(screen_width - 1), str(screen_height - 1)]) - also tried to execute xdtool before initializing pygame: subprocess.run(["xdotool", "mousemove", "1919", "719"]) pynput - mouse.position = (screen_width - 1, screen_height - 1) evdev - ui.write(e.EV_REL, e.REL_X, screen_width - 1) ui.write(e.EV_REL, e.REL_Y, screen_height - 1) ui.syn()Nothing seems to make the cursor move out of the way - I am trying to move it to the lower right of the screen where it will be hidden. Any input is greatly appreciated.
bash Traceback (most recent call last): File "/home/raspberry/radio.py", line 11, in <module> CS = DigitalInOut(board.CE1) ^^^^^^^^^^^^^^^^^^^^^^^ (redacted traceback stuff) File "/usr/lib/python3/dist-packages/lgpio.py", line 458, in _u2i raise error(error_text(v)) lgpio.error: 'GPIO busy'code:
python import time import busio from digitalio import DigitalInOut, Direction, Pull import board import adafruit_rfm9x btnA = DigitalInOut(board.D17) btnA.direction = Direction.INPUT btnA.pull = Pull.UP CS = DigitalInOut(board.CE1) RESET = DigitalInOut(board.D25) spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) iter = 0 def send_data(): global iter print("send %s"%iter) iter+=1 def get_data(): global iter print("get %s"%iter) iter+=1 def main(): try: while True: if not btnA.value: # Button pressed send_data() else: get_data() except KeyboardInterrupt: pass if __name__ == '__main__': main()