Transceiver
Transceiver allows to receive an IDentification Code (IDC) from a Garage Door Opener (GDO) through an active stargate on a configured frequency. Transceiver can be configured to listen on a specific frequency and for a specific IDC. It is also able to send an IDC on the configured frequency. When the transceiver receives a signal on the configured frequency, it will raise a computercraft event transceiver_transmission_received. Although the transceiver is able to validate only a single IDC, the computer can perform the validation itself by checking the received IDC from the event. The transceiver can listen only on a single frequency. More transceivers can be used to listen on different frequencies simultaneously.
It is a standalone peripheral (do not use the stargate interface). It can be placed next to the computer or connected using the wired modem.
local transceiver = peripheral.find("transceiver")
setFrequency(frequency)
source
Sets the frequency at which the transceiver will listen.
Parameters
number
: The frequency to set
Usage
- Set the frequency to
1234
local FREQUENCY = 1234 transceiver.setFrequency(FREQUENCY)
setCurrentCode(idc)
source
Sets the IDentification Code (IDC) which the transceiver will validate or transmit. Currently, the IDC is string
so it can be any string. However, note that the GDO can send only numbers.
Parameters
string
: The IDC to set
Usage
- Set the IDC to
4321
(it must be a string)local IDC = "4321" transceiver.setCurrentCode(IDC)
sendTransmission()
source
Sends a transmission. The transceiver will transmit the current IDC on the configured frequency.
Usage
- Send the IDC on frequency
local IDC = 4321 local FREQUENCY = 1234 transceiver.setFrequency(FREQUENCY) transceiver.setCurrentCode(IDC) transceiver.sendTransmission()
checkConnectedShielding()
source
Transceiver searches for a nearest stargate and checks the state of the iris on the other side of the Stargate connection. It does not matter if the connection is incoming or outgoing.
Returns
number
: The percentage of the iris closing on the other side of the Stargate connectionnil
if there is no Stargate in range or the nearest Stargate is not connected
0
if the iris on the other side is fully open or there is no iris
100
if the iris on the other side is fully closed
Usage
- Check the iris state on the other side of the Stargate connection
local state = transceiver.checkConnectedShielding() if state == nil then print("No Stargate in range or the nearest Stargate is not connected") elseif state == 0 then print("The iris on the other side is fully open or there is no iris") elseif state == 100 then print("The iris on the other side is fully closed") else print("The iris on the other side is closed at " .. state .. "%") end
getCurrentCode()
source
Returns the currently set IDentification Code (IDC).
Returns
string
The current IDC, empty string if not set
Usage
- Print the current IDC
local idc = transceiver.getCurrentCode() print("Current IDC: " .. idc)
getFrequency()
source
Returns the current frequency on which the transceiver is listening.
Returns
number
The current frequency
Usage
- Print the current frequency
local frequency = transceiver.getFrequency() print("Transceiver is listening on frequency: " .. frequency)