Good news! Found a way to do it! (
John, maybe you find it usefull to add to the Enhanced FW)
After digging in the FW, this is what I got:
- Apperantly, an IOMapWrite only writes to the IOMap, which produces a change in the screen but
not in the Bluetooth device. This makes sense.
- On the other hand, the FW command SETBTNAME, which is invoqued by the NXC function SysCommExecuteFunction with Cmd = INTF_SETBTNAME,
only updates the brick name in the Bluetooth device, by copying the one stored in the IOMap.
So, combining both, we get the name actually changed:
Code: Select all
task main(){
byte data[];
IOMapWriteType IOargs;
CommExecuteFunctionType Fargs;
IOargs.ModuleName = CommModuleName;
IOargs.Offset = CommOffsetBrickDataName;
ArrayBuild(data, "Ricardo");
IOargs.Buffer = data;
SysIOMapWrite(IOargs);
Fargs.Cmd = INTF_SETBTNAME;
SysCommExecuteFunction(Fargs);
while(true);
}
But now, looking deeper in the firmware, the variable UBYTE *pName, is anyway passed to the function cCommReq, which makes it quite trivial to use the element Name in the structure CommExecuteFunctionType to actually change the name of the brick only using SysCommExecuteFunction().
I changed a couple of lines, not more, and made it work. I added the following lines to the FW (in "case: SETBTNAME", c_comm.c):
Code: Select all
cCommInsertBtName(IOMapComm.BrickData.Name, pName);
pMapUi->Flags |= UI_REDRAW_STATUS;
...and removed the same lines from the case "SETBRICKNAME", c_comm.c, which were being executed for the remote control request (like used in Diagnostics).
Now, the NXC code looks like:
Code: Select all
task main(){
CommExecuteFunctionType Fargs;
Fargs.Cmd = INTF_SETBTNAME;
Fargs.Name = "Ricardo";
SysCommExecuteFunction(Fargs);
while(true);
}
I guess this peice of code is similar to the old "SetBrickName". I am not an expert in the FW stuff, but it seems a worth change(?).