mruby/c 3.3 Standard I/O Class Support

Module Initialization

This is the RBoard program used to initialize the module via the serial console (PC->RBoard->Module).
For `dev`, specify the module's default value for `baud`.
Example: AMW037, BGX13P etc. are 115200

usb = UART.new( 1, baud:19200 )
dev = UART.new( 2, baud:19200 )
while true
  # PC -> RBoard -> Module
  if(usb.can_read_line())
    dev.write(usb.gets())
  end

  # Module -> RBoard -> PC
  if(dev.can_read_line())
    usb.write(dev.gets())
    # usb.write("> ")
  end
end

im920s

https://www.interplan.co.jp/solution/wireless/im920s/im920s.php

String Transmission


im = UART.new(19200)
while true
  im.puts("TXDA " + (23).to_s + "\r\n")
  sleep(5)
end

String Reception


im = UART.new(19200)
while true
  puts(im.gets())
  sleep(5)
end

Bluetooth

https://www.switch-science.com/catalog/5794/
set command can be used to set values and get command can be used to check the set values.
Commands: https://docs.silabs.com/gecko-os/1/bgx/latest/commands
Parameters: https://docs.silabs.com/gecko-os/1/bgx/latest/variables
Example: Baud rate setting command
set ua b 19200
Prepare an Android smartphone that supports Bluetooth 5.
Install the app "Serial Bluetooth Terminal".
Turn on the module's power (connect to RBoard, etc.).
In the smartphone's settings → Device connection → Pair new device, register the module.
Launch "Serial Bluetooth Terminal" and long-press the module's entry under Devices→Bluetooth LE. Edit → Custom → Select each of the three UUIDs.
You should be able to connect by pressing the "✓" in the upper right corner.

bluetooth = UART.new(19200)
while true
  bluetooth.puts("aaaa\r\n")
  sleep(5)
end

wifi

https://www.switch-science.com/catalog/5795/

cmd = "hge https://script.google.com/macros/s/xxxxxxxxxxxxxxxxxxx/exec?data1="
wifi = UART.new(19200)
wifi.puts("\r\n")
sleep(5)
while true
  wifi.puts(cmd + (1.to_s) + "\r\n")
  sleep(10)
  wifi.puts("stream_close 0\r\n")
  sleep(10)
end