This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
HaddockDev's profile picture

SimpleAdore - wireless made easy

Started by HaddockDev, 21 August 2017 - 01:48 AM
HaddockDev #1
Posted 21 August 2017 - 03:48 AM
adore the not so amazing

SimpleAdore

wireless made kinda simple, i guess


So… what is this again?
This is a rapid prototyping wireless library thingy that makes wireless easier.
You only need to call about 3 or so functions to get on the air, plus transmitting and receiving is a lot easier, considering you just call the Recieve function or the Transmit function and it does all the work for you.

Why is SimpleAdore named SimpleAdore?
tl;dr recycling code
I was developing a Door Lock API named Adore, and nothing worked so I rewrote it but 90% of it was non-door-lock code stuff so I took that out, cleaned it up a bit and here we are.

What can this be used for?
Anything that uses modems/rednet. For testing, I used this to make a what-you-see-is-what-you-get wireless door lock (which will be released soon).
And guess what? It is 78 lines smaller than my door lock without the library on the server side, and it is 61 lines smaller on the client side.

Also, for the license: this is under a GPLv3 license.
You may use this in your program, just attribute me and you're in the clear.

Where can I download this?
From PasteBin - pastebin get mXGfG7Kw SimpleAdore

DocsWrapModem(side) - Sets up a modem for use. The auto detection feature is a little touchy, so you should give it a side.
AddChannel(name, channel) - Adds a channel for use, and opens it on the modem. You don't really need to do this but it might be useful for organization.
GetChannels() - Returns a list of channels available.
Transmit(channel, data) - Transmits data on channel. If you pass it a table, it automatically serializes it.
Recieve(channel) - Returns the message, and distance of the first message recieved when sender channel is channel.

Current issues:
  • No check for if you actually setup the modem by running WrapModem
  • Automatic modem discovery thingy is touchy/doesn't work
Edited on 23 August 2017 - 08:49 PM
Dave-ee Jones #2
Posted 22 August 2017 - 02:10 AM
You may find that this is basically the exact same as the modem API, which you knew because you are using it to create this.

<modem>.open(channel)
<modem>.close(channel)
<modem>.transmit(channelToBroadcastOn, channelToReceiveBroadcastOn, message)

And to receive messages you deal with the "modem_message" API.

However you did make it easier for people to receive a message on a channel. Where you have '_1' that is the side that the message came in on, and '_2' is the channel you are asked to reply on, so that would be the channel the sender would have open so it can catch your reply.

It's a good start though, and it certainly makes it a bit easier for people to use for simple purposes, so I would say you achieved your goal.
Lupus590 #3
Posted 22 August 2017 - 11:09 AM
And to receive messages you deal with the "modem_message" API event.

fixed it for you
Dave-ee Jones #4
Posted 23 August 2017 - 04:35 AM
And to receive messages you deal with the "modem_message" API event.

fixed it for you

Ah thanks..Little bit on the tired side :P/>
HaddockDev #5
Posted 23 August 2017 - 10:55 PM
–snip
However you did make it easier for people to receive a message on a channel. Where you have '_1' that is the side that the message came in on, and '_2' is the channel you are asked to reply on, so that would be the channel the sender would have open so it can catch your reply.

It's a good start though, and it certainly makes it a bit easier for people to use for simple purposes, so I would say you achieved your goal.
Yep, you got it right. I made this to make it easier for prototyping (and doors) but it could be used for simple modem projects.
The side and the reply channel aren't used because of my standards of modem thingys (throwaway the side, and assume reply channel is sender channel + 1) but in a way it kinda makes it easier, I guess.
Edited on 23 August 2017 - 08:57 PM