Compiler Errors in TinyDuino SmartWatch Example

MitchLampert

  • Jr. Member
  • **
    • Posts: 7
    • View Profile
I am trying to compile the Smart Watch example code for Android, from this project:
https://tinycircuits.hackster.io/tbatey_tiny-circuits/tinyscreen-smartwatch-785938

I also added these to the libraries:
Tiny Screen: https://github.com/TinyCircuits/TinyCircuits-TinyScreen_Lib
Time, which I found referenced in another thread: https://github.com/PaulStoffregen/Time

But, I get this compile error:
variable 'setup_msgs' must be const in order to be put into read-only section by means of '__attribute__((progmem))'

Points to this line in UART.h:
static hal_aci_data_t setup_msgs[NB_SETUP_MESSAGES] PROGMEM = SETUP_MESSAGES_CONTENT;

If I make that line const, I get this error, instead:
invalid conversion from 'const hal_aci_data_t*' to 'hal_aci_data_t*' [-fpermissive]

Anyone know what is going on?


I am using Arduino 1.6.7


MagnusRunesson

  • Full Member
  • ***
    • Posts: 23
  • Eagerly awaiting TinyArcade!
    • View Profile
Hi Mitch,

I'm making a short answer long. :)

What does this line look like after you changed it?
static hal_aci_data_t setup_msgs[NB_SETUP_MESSAGES] PROGMEM = SETUP_MESSAGES_CONTENT;

I believe the correct way to define this is to define setup_msgs as const, like this:
static const hal_aci_data_t setup_msgs[NB_SETUP_MESSAGES] PROGMEM = SETUP_MESSAGES_CONTENT;

With this error message, provided it is at the line where you define setup_msgs
invalid conversion from 'const hal_aci_data_t*' to 'hal_aci_data_t*' [-fpermissive]

It seems like you've made SETUP_MESSAGES_CONTENT into a const, because the error message state that it is the right hand value of the assignment operator that is const, but the left hand value is not const.

If you've properly declared setup_msgs as const it is likely that there is a function somewhere that expects a hal_aci_data_t pointer but you're passing in a const hal_aci_data_t pointer. It seems like none of the functions expect a const pointer.

If you provide the line of code that generates the new error then maybe I can help out a bit more.


MitchLampert

  • Jr. Member
  • **
    • Posts: 7
    • View Profile
This isn't my code, and I wasn't intending to change any of it. I just wanted to get this demo working, before getting on with anything else.

I figured, I could crawl down the rabbit hole of figuring out the fundamental problem with the demo, fixing every line as I went along, if I had to. But, I couldn't believe that I was the first person to have this issue. Surely, others have run into this, and someone knew of a standard fix, of some sort? Searching forums and Google didn't help. So, I started this thread before going further.

For reference, this is the line, in UART.h, the second error points to:
aci_state.aci_setup_info.setup_msgs         = setup_msgs;

I was also thinking, perhaps, that this is an outdated demo? Perhaps there's a newer Bluetooth/Smart Watch demo around, that I missed, some how? If there is, I could go with that, instead of this one: https://tinycircuits.hackster.io/tbatey_tiny-circuits/tinyscreen-smartwatch-785938


Thanks!


tastewar

  • Full Member
  • ***
    • Posts: 26
    • View Profile
It could be a different Time library. TinyCircuits seem to like the "codebender" site, and when I ask to include <time.h> on their platform, it appears to include one that starts off like this:

/*
  time.c - low level time and date functions
  Copyright (c) Michael Margolis 2009

So I don't think they're using Paul's Time library...


MagnusRunesson

  • Full Member
  • ***
    • Posts: 23
  • Eagerly awaiting TinyArcade!
    • View Profile
It's probably wise of you not to go down the rabbit hole of fixing the demo. Fixing const correctness is almost always a bad idea. :)


MitchLampert

  • Jr. Member
  • **
    • Posts: 7
    • View Profile
Paul's library, that I am using, begins this way:

/*
  time.c - low level time and date functions
  Copyright (c) Michael Margolis 2009-2014


So, it's similar. But, I will try different ones, from CodeBender and perhaps a couple of others, soon.


MitchLampert

  • Jr. Member
  • **
    • Posts: 7
    • View Profile
Well, pulling the Time library from CodeBender into the Arduino environment didn't help.

But, I decided to compile and run the example from the browser-based CodeBender app, and THAT worked!

So, at least I got the demo working in one manner. However, I would prefer to program for the Bluetooth shield from within the Arduino environment. I suppose I'll just have to find code that works in there.

Thanks for the nudge in this direction, everyone!


Ben Rose

  • Administrator
  • Hero Member
  • *****
    • Posts: 392
    • View Profile
Hi Mitch and all,

Sorry about the late reply. This issue is related to the Nordic BLE code rather than the Time library. Unfortunately codebender is based around an older version of the Arduino IDE, which has different compiler options compared to the current IDE- new versions want small changes in constant declaration etc. At the moment we provide the example on codebender and most people modify it in that environment, so the problem actually does not come up very often. I would certainly like to provide it in an IDE-friendly way- I don't have a date, but I can say that we plan to do a smartwatch kit upgrade with TinyScreen+ after our current Kickstarter is fulfilled, and that will definitely include a software update for old and new hardware.

Thanks,
Ben


MitchLampert

  • Jr. Member
  • **
    • Posts: 7
    • View Profile
Thanks for the update, Ben.

(I figured the Time library probably didn't have anything to do with it.)


 

SMF spam blocked by CleanTalk