Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Ethernet Gateway on Arduino Yún

Ethernet Gateway on Arduino Yún

Scheduled Pinned Locked Moved Development
ethernetyunarduinogateway
9 Posts 3 Posters 12.5k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    akbooer
    wrote on last edited by akbooer
    #1

    I'm trying to port the Ethernet Gateway sketch to an Arduino Yún using the Bridge library which connects the Yún to the on-board Linux processor (which will be running my controller.)

    I've prototyped a stand-alone server which works well, so I know how to use the gateway. The port seems as though it should be straight-forward:

    • no need to provide IP or MAC address, since this is handled on the Linux side
    • EthernetServer --> YunServer
    • EthernetClient --> YunClient
    • Ethernet.begin() --> Bridge.begin()
    • server.available() --> server.accept()

    However...

    I get a type conversion error at compile time on this line:

    void output(const char *fmt, ... ) {
       va_list args;
       va_start (args, fmt );
       vsnprintf_P(serialBuffer, MAX_SEND_LENGTH, fmt, args);
       va_end (args);
       Serial.print(serialBuffer);
       server.write(serialBuffer);  // <-- ERROR HERE
    }
    
    

    with this diagnostic

    Arduino: 1.7.6 (Mac OS X), Board: "Arduino Yún"
    
    YunMSGateway.ino: In function 'void output(const char*, ...)':
    YunMSGateway.ino:143:29: error: invalid conversion from 'char*' to 'uint8_t {aka unsigned char}' [-fpermissive]
    In file included from YunMSGateway.ino:83:0:
    /Users/akbooer/Documents/Arduino/Arduino 1.7.6.app/Contents/Java/libraries/Bridge/src/YunServer.h:35:20: error:   initializing argument 1 of 'virtual size_t YunServer::write(uint8_t)' [-fpermissive]
         virtual size_t write(uint8_t c);
                        ^
    Error compiling.
    

    So I guess the question is, simply, how do I coerce from char* to uint8_t ?

    I know next to nothing about C or C++, but I have tried the simple (uint8_t) prefix with similar errors. I'm sure this is trivial and (hopefully) the only thing standing between me and a fully functioning Ethernet Gateway on the Yún.

    Any help much appreciated.

    1 Reply Last reply
    0
    • AnticimexA Offline
      AnticimexA Offline
      Anticimex
      Contest Winner
      wrote on last edited by
      #2

      Generally you cannot. The types are not interchangeable.
      You try to pass a string buffer to a function that only accept a single character.
      You could try (assuming serialBuffer is a NULL-terminated string) this:

      void output(const char *fmt, ... ) {
          ...
          Serial.print(serialBuffer);
          for (int i = 0; serialBuffer[i] != '\0'; i++) {
              server.write((uint8_t)serialBuffer[i]);
          }
      }
      

      It could also be that server.write expects to also get the NULL byte in which case you also have to pass the that one like this:

      void output(const char *fmt, ... ) {
          ...
          Serial.print(serialBuffer);
          for (int i = 0; serialBuffer[i] != '\0'; i++) {
              server.write((uint8_t)serialBuffer[i]);
          }
          server.write((uint8_t)serialBuffer[i]);
      }
      

      Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

      1 Reply Last reply
      0
      • A Offline
        A Offline
        akbooer
        wrote on last edited by
        #3

        Ah, well, thank you for that anyway.

        Maybe it was the wrong question, but I hope to have solved the problem by discovering another server method 'print', which takes the right argument type. (A little knowledge is a dangerous thing.)

        1 Reply Last reply
        0
        • A Offline
          A Offline
          akbooer
          wrote on last edited by
          #4

          Wondering, now, how to wire up the NRF module to the Yún. I'm following the Ethernet Gateway guide at http://www.mysensors.org/build/ethernet_gateway, but, of course, the pin configuration is different from that shown.

          Am I right in assuming that I use the pins on the ICSP for SCK, MISO, and MOSI, then digital pins 5 and 6 for CE and CSN?

          Also supposing that there's no need for software SPI in this case?

          Advice most welcome! Thanks in advance.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            akbooer
            wrote on last edited by
            #5

            Success! I now have a functioning Ethernet Gateway running on a Yún using the Bridge library which connects the Arduino Yún to the on-board Linux processor.

            The software changes are broadly those outlined here in an earlier post. I am more than happy to put this up on GitHub if someone can advise the best way / place for this (ie. should it be a a new file, say YunEthernet, or a conditional compilation of the main gateway, or what?)

            It works with hardware SPI and again the wiring is as described previously (with earlier doubts now dispelled.)

            There's two possible configurations:

            • as a 'normal' gateway, addressable from the LAN (with the IP handing all done on the Linux processor)
            • as a 'private' gateway, only addressable from the local host processor (as a controller)

            The latter of the above options is the way I am currently running this, otherwise there's little point in using a Yún at all, with my own 'openLuup' Vera emulator running on the Linux processor using the standard Arduino plugin to link to the gateway.

            I don't know about the speed of the Arduino/Linux bridge (it is reported elsewhere as being notoriously slow) but it seems very adequate for the job I am currently using it for (perhaps not a very heavy network load.)

            1 Reply Last reply
            2
            • A Offline
              A Offline
              akbooer
              wrote on last edited by
              #6

              Just to put a footnote to the above (copied from another post - apologies, but it does belong here) ...

              GitHub fork with the Yun Gateway

              https://github.com/akbooer/Arduino/tree/development/libraries/MySensors/examples/GatewayYun

              1 Reply Last reply
              0
              • scalzS Offline
                scalzS Offline
                scalz
                Hardware Contributor
                wrote on last edited by
                #7

                @akbooer: hi.
                I hope to have some time to test your very interesting work :smiley:
                I have a dragino he, maybe I will hook a moteino mega.
                I have ordered this one too:
                http://www.seeedstudio.com/depot/LinkIt-Smart-7688-Duo-p-2574.html
                Same price as dragino but there is 32u4 onboard :smiley:
                what do you think about it? I am very curious, plus it seems a little bit more powerful, but not the same chip.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  akbooer
                  wrote on last edited by
                  #8

                  That's a really good price! A whole lot better than a Yún. I've not tried a Dragino but they seem to offer similar functionalities. I'm not sure about the details of the serial link handling for the bridge - if the bridge library has the same calls, it should work OK.

                  1 Reply Last reply
                  0
                  • scalzS Offline
                    scalzS Offline
                    scalz
                    Hardware Contributor
                    wrote on last edited by scalz
                    #9

                    thx for reply :smile:
                    yes dragino HE works like yun I think.
                    for linkit as the product seems new, there is a little bit less docs. but I will see, price was so interesting that it was too much tempting lol.
                    I will tell you what I can get...
                    for fun, I have not presented yet, but I have a board in progress for raildin : 8x relays + 8inputs for yun and I added ethernet connector+hub usb chip

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    14

                    Online

                    11.7k

                    Users

                    11.2k

                    Topics

                    113.0k

                    Posts


                    Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • MySensors
                    • OpenHardware.io
                    • Categories
                    • Recent
                    • Tags
                    • Popular