Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
BKnight

How to set modem's address

Question

Hello

In the documentation modem.send() uses an address:string that identifies the receiver's destination. But modem's addresses are lonnng numbers. I've tried sending messages with just the first characters of the address, but that doesn't seem to work.
It's impractical to use the long default address created for the modem. Is there a way to set this address to something smaller and more practical? Or do I really have to work with the looong default address?

Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

I didn't find a way to replace those addresses, but if u want to get an address easily, you have the sender(s) and the server which receive the message, but the sender need an address, so at the beginning of the infinite loop I put a 

component.modem.open(urport)
_,_,address = event.pull("modem_message")

function sendMsg(data,data2,data3)
  component.modem.send(address,port,data1,data2,data3)
end

And in the server which receive, you put in the infinite loop :

component.modem.open(port)
compoment.modem.broadcast(port)

Of course replace port by ur port ^^

It's not the best way because it send a broadcast message to everyone each loop but u can make something that when the address as been receive you can stop the broadcast

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.