Hi, I want to turn my mono into the ultimate wifi remote control. Can you point me in direction of information about opening TCP socket, reading and writing data.
Hi hekras, Kristoffer is back at the office Friday and I'm sure he can point you in the right direction. We have to prioritize shipment of the reminding mono's, so bare with us if we need a little more time.
said in Socket programminig:
Can you point me in direction of information about opening TCP socket, reading and writing data.
Hi @hekras, it is certainly possible with our wireless module. I have worked on the networking layer, but I had to prioritize HTTP calls and connecting to an wifi access point. So at this point I still need to code a network abstraction layer. I will write an example of how to use the Wifi (without abstraction layer) friday.
However, the code is there when you install mono's toolchain. You can browse it here: https://github.com/getopenmono/mono_framework/blob/master/wireless/redpine_module.h
The setup is to first initialize the SPI communication to the module using mbed SPI class:
// Object initialization (merged .h and .cpp files here! mbed::SPI wifiSpi(RP_SPI_MOSI,RP_SPI_MISO, RP_SPI_CLK); mono::redpine::ModuleSPICommunication wifiComm(wifiSpi, RP_SPI_CS, RP_nRESET, RP_INTERRUPT); // run this in monoWakeAfterReset() mono::redpine::Module *redpine = redpine::Module::Instance(); bool redpineOk = redpine->initialize(&wifiComm); // connect to a network mono::redpine::setupWifiOnly("MY_SSID", "MY_PASSWORD"); //download google.com mono::network::HttpClient client("google.com"); client.setDataReadyCallback<MyClass>(this, &MyClass::MyCallbackMethod);
I have added a quick wifi tutorial on developer.openmono.com, that explains the steps to do a HTTP GET request.
Its only HTTP, HTTPS is coming later - its more complex.
Just got my mono and looking forward to using it with the HTTPS. Any chance you need a use case for it? I'd love for it to connect to the Maker channel on IFTTT, that would enable loads of functionality for Mono.
Hi @stoffera, I have tried following your WiFi tutorial, but it fails when this line is added:
And by "fails" I mean that the display flashes and the speaker beeps twice.
I have added the "return true;" line that @raute_at mentioned in this thread: https://community.openmono.com/topic/19/status-of-wifi-api
Otherwise, it failed on the ModuleSPICommunication constructor.
Any idea what could be wrong?
Here is all the code I have added to the Hello World program:
// app_controller.h mbed::SPI spi; redpine::ModuleSPICommunication spiComm; // app_controller.c (contructor) spi(RP_SPI_MOSI, RP_SPI_MISO, RP_SPI_CLK), spiComm(spi, RP_SPI_CS, RP_nRESET, RP_INTERRUPT) // app_controller.c (monoWakeFromReset) redpine::Module::initialize(&spiComm);
Also, is there any way to check that my Mono actually supports WiFi? I should have the Mono Maker with WiFi and Bluetooth, but there is no indications on the box.
Hi, the problem is in the Makefile that comes with monomake. Until we get that fixed, you can make sure that the build directory in your project is clean by simply deleting it. On MacOS/Linux you would do like this:
$ rm -rf build/
Hi @jp, I have already tried that, but unfortunately it didn't help.
It did solve another problem I had, though.
You can identify the model of your Mono in several ways. On the box it says which model you have:
On the back of Mono, it says which model you have:
Inside Mono, if there is a big shiny encapsulation, it is the Wifi module:
Hi @jp, thanks.
I have the same Mono maker m3 (and I also have the RF shield inside) so I guess that's not the problem, but it's good to be sure.
@emil.melgaard Hi, just out of curiosity. Did you manage to solve the issue (crashing when initializing the wifi module)?