This page was last modified 13:32, 31 December 2007.
To get the serial number of a SD card on Symbian OS v9
From Forum Nokia Wiki
class TCidDecoder { public: #define LO_NIBBLE(val) (val & 0x0F) #define HI_NIBBLE(val) ((val >> 4) & 0x0F) #define IS_ASCII(val) (val >= 0x20 && val < 0x7F) public: TCidDecoder(TDesC8& aBuf, TBool aSDCard) { iBuf.Copy(aBuf); iSDCard = aSDCard; }; // constructor which tries to deduce whether card is an MMC or SD card TCidDecoder(TDesC8& aBuf) { iBuf.Copy(aBuf); iSDCard = ETrue; if (HI_NIBBLE(iBuf[2]) != 0) iSDCard = EFalse; TInt sdMonth = LO_NIBBLE(iBuf[1]); if (sdMonth == 0 || sdMonth > 12) iSDCard = EFalse; // get this year so we can check for daft years TTime now; now.HomeTime(); TDateTime dateTime = now.DateTime(); TInt year = dateTime.Year(); TInt sdYear = HI_NIBBLE(iBuf[1]) + (LO_NIBBLE(iBuf[2]) << 4) + 2000; if (sdYear > year) // stupid year ? iSDCard = EFalse; // // Oid should be ascii for SD and binary for MMC - but this isn't always true // if (!IS_ASCII(iBuf[13]) || !IS_ASCII(iBuf[14])) // iSDCard = EFalse; }; void ManufacturingDate(TInt& aYear, TInt& aMonth) { if (iSDCard) { aYear = HI_NIBBLE(iBuf[1]) + (LO_NIBBLE(iBuf[2]) << 4) + 2000; aMonth = LO_NIBBLE(iBuf[1]); } else { aYear = LO_NIBBLE(iBuf[1]) + 1997; aMonth = HI_NIBBLE(iBuf[1]); } } TUint32 SerialNumber() { if (iSDCard) return( (iBuf[6]<<24) | (iBuf[5]<<16) | (iBuf[4]<<8) | (iBuf[3]) ); else return( (iBuf[5]<<24) | (iBuf[4]<<16) | (iBuf[3]<<8) | (iBuf[2]) ); } void ProductRevision(TInt& aMajor, TInt& aMinor) { if (iSDCard) { aMajor = (iBuf[7] & 0xF0) >> 4; aMinor = iBuf[7] & 0x0F; } else { aMajor = (iBuf[6] & 0xF0) >> 4; aMinor = iBuf[6] & 0x0F; } } void ProductName(TBuf<6>& aName) { aName.SetLength(5); aName[0] = iBuf[12]; aName[1] = iBuf[11]; aName[2] = iBuf[10]; aName[3] = iBuf[9]; aName[4] = iBuf[8]; if (!iSDCard) aName.Append(iBuf[7]); }; void Oid(TBuf<2>& aOid) { aOid.SetLength(2); aOid[0] = iBuf[14]; aOid[1] = iBuf[13]; }; TUint8 ManufactureID() { return iBuf[15]; } TBool IsSdCard() { return iSDCard; }; public: TBuf8<16> iBuf; TBool iSDCard; // MMC card if false, SD card otherwise };
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Serial Number for 3410 and 3510i SDK | an9rew | Mobile Java Tools & SDKs | 2 | 2003-07-15 11:59 |
| Serial Number for 7210 sdk v1_0 | Rameshwari | Symbian Tools & SDKs | 3 | 2007-11-14 09:07 |
| C++BuilderX + activation file or serial number | freebird110 | Symbian Tools & SDKs | 5 | 2008-05-24 16:16 |
| Please who can help me about this serial number? | Firener | Mobile Java General | 2 | 2004-01-25 13:38 |
| register Nokia Mobile Browser ? | stoill | Browsing and Mark-ups | 8 | 2008-04-05 23:15 |
