forlotto wrote:}
else if ( fname == F("temp") && num_args > 0 ) {
// function temp(sensor #)
// set return value
sensors.requestTemperatures();
*value = sensors.getTempCByIndex(args[0]);
return PARSER_TRUE;
}
@forlotto: This is so AWESOME!!! I figured out the library and what it is doing. Most of my assumptions were correct (except that there is no device code look-up table as it's derived with each call by brute force). It's no mystery to me at all now. I would propose addition of two functions. One to return all device codes on the wire (in a space separated string for easy handling with word()) and one to retrieve temperature readings by device code. Please understand that I'm very rusty with the particular C like dialects in play here (spending most of my time with PHP and Javascript). These won't run as written, but you'll get the idea.
void function getDevCodes()
{
DeviceAddress deviceAddress;
uint8_t index;
char* strptr;
// here we have to initialize strptr to the start of a character buffer
for (index=0; getAddress(deviceAddress,index); index++)
{
uint8ToHex(strptr,deviceAddress); // Fictitious function to convert 8 byte device code to 16 byte string and advance strptr
(*strptr++)=" "; // Add a space separator
}
if (index>0) strptr--; // Don't need a trailing space
(*strptr)="\0"; // Add 0 terminator
} // result is returned in character buffer as space separated device codes
function getTempByDevCode((string*)devCode)
{
DeviceAddress deviceAddress; // create 8 byte storage area for device code
hexToUint8( deviceAddress, devCode ); // Fictitious function to convert 16 byte hex character string to 8 byte address
return getTempC(deviceAddress);
}
If these are written on the library level, they look different than if written as the BASIC interpreter code (which would use "sensor."). I haven't figured out how the arg[] array works yet or exactly how I should handle strings or if my "fictitious" conversion functions actually exist elsewhere already, but if I had more time, I think I could figure out how to do this straight in the BASIC code. I'm on a roll but 4:00am came too quickly.