digistump / OakCore

Arduino/Platformio Core for Oak including Particle library
GNU Lesser General Public License v2.1
55 stars 28 forks source link

BOUNTY: Particle.variable(); with double doesn't compile #25

Closed digistump closed 8 years ago

digistump commented 8 years ago

Skills Required: Intermediate at C/C++ Difficulty: Easy to Moderate

Challenges/Thoughts:

Fix Variables functions as reported here: http://digistump.com/board/index.php/topic,1997.0.html for all accepted input types (String, char*, double, int) - see comments below for more notes.

To test:

Install Python 2.7 and ensure it is in your path Install the latest Oak core via board manager, download this repository and copy over the files found at APP_DATA/packages/digistump/hardware/oak/XXX where APP_DATA is where your system keeps the Arduino data and XXX is the current Oak core version. Use a sketch the utilizes Particle.variable with double, char*, and string types Make changes to the core to achieve the above task. Connect your Oak using a 3.3v USB to Uart adapter, connect Pin2 to GND before powering on to enter Serial bootloader mode (after an upload the code with automatically run and you'll have to power cycle it to go back to bootloader mode. Disconnect Pin2 to GND to have it run the code on next power up) ONCE: Grab OakRestore (https://github.com/digistump/OakRestore) and run python esptool.py --baud 115200 --port YOUR_COM_PORT write_flash -fs 32m 0x1000 blank.bin 0x2000 oaksetup_restore.bin 0x0081000 oakupdate_restore.bin 0x101000 blank.bin 0x102000 blank.bin 0x202000 blank.bin replacing YOUR_COM_PORT with your com port, to restore the Oak to factory setup so that the Serial upload will work and the Oak will boot to it. Use "Upload Using" "Serial" in the Arduino tools menu. Upload from the IDE and test

Bounty

$50 cash or $100 credit or 10 Oaks

If you are sure you can do this, and able to do this quickly - please feel free to respond to this issue and say that you are working on it and when you will complete it, so that others don't waste their time on it. If you are just entertaining the idea/unsure if you can do it, please don't "claim" it until you are sure.

Cash or credit is your choice. Cash to be paid via Paypal. Credit has no expiration but can only be applied to a single order and does not cover shipping (because that is how our shopping cart works, not because we want to be limiting). Oaks reward includes shipping.

You may credit yourself in the files as well, leaving in tact existing licenses and credits.

Legal Stuff: We will choose a winner at our sole discretion. The winner will be the first pull request that submits fully working code meeting the above requirements and following good coding practices, based on the timestamp of the pull request. Bounty will be awarded (or in the case of Oaks, sent) within 48 hours of confirming winner. Cash awards will be made in USD. This is not an offer for hire. All work submitted becomes the property of Digistump LLC to be used at our discretion in compliance with any associated licenses. Void where prohibited by law.

digistump commented 8 years ago

@DarkLotus @danielmawhirter @povrazor - Would any of you folks with much better C++ foo then me be willing to take a look at this - looking at Particle's original code for this (https://github.com/spark/firmware/blob/35a78512e983e667e3b9a1696396f42b82c66465/wiring/inc/spark_wiring_cloud.h) it seems like it should work but I'm guessing there is a scope/template issue going on here where the linker can't connect it all together...

danielmawhirter commented 8 years ago

It looks like a version of https://github.com/spark/firmware/blob/35a78512e983e667e3b9a1696396f42b82c66465/wiring/inc/spark_wiring_cloud.h#L134-L137 needs to be added for double? I don't see one in that file.

mikekasprzak commented 8 years ago

Yeah, there's an Int and String version, but no double.

It needs something like:

    static inline bool variable(const char *varKey, const double& userVar, const CloudVariableTypeDouble& userVarType)
    {
        return CLOUD_FN(spark_variable(varKey, (const void*)&userVar, CloudVariableTypeDouble::value(), NULL), false);
    }

That's untested though.

I'm also not exactly sure the right combination of &'s, since I don't know the other code.

digistump commented 8 years ago

Thank you both - that was my thought too - but that doesn't seem to do it (or I'm doing it wrong) in addition the spark code linked works for doubles on particle/spark devices and doesn't have it - my for variables code is essentially a verbatim copy of theirs with some scope changes, so that's where I get lost - I'm going to add a small bounty to this and see if that makes it worth anyone's time to dig in a bit and figure it out (as I'm about to do an update announcing a bunch of bounties)

Thanks again!

digistump commented 8 years ago

Closing awarded to DarkLotus